Metadata-Version: 2.5
Name: cone.calendar
Version: 2.1.0
Summary: jQuery Fullcalendar integration for cone.app
Project-URL: Homepage, http://github.com/conestack/cone.calendar
Author-email: Cone Contributors <dev@conestack.org>
License: Simplified BSD
License-File: LICENSE.rst
Keywords: cone,node,pyramid,web
Classifier: Environment :: Web Environment
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.10
Requires-Dist: cone-app>2.1.99
Requires-Dist: yafowil-widget-cron>1.99
Provides-Extra: test
Requires-Dist: pytest; extra == 'test'
Requires-Dist: zope-pytestlayer; extra == 'test'
Description-Content-Type: text/x-rst

.. image:: https://img.shields.io/pypi/v/cone.calendar.svg
    :target: https://pypi.python.org/pypi/cone.calendar
    :alt: Latest PyPI version

.. image:: https://img.shields.io/pypi/dm/cone.calendar.svg
    :target: https://pypi.python.org/pypi/cone.calendar
    :alt: Number of PyPI downloads

.. image:: https://github.com/conestack/cone.calendar/actions/workflows/test.yml/badge.svg
    :target: https://github.com/conestack/cone.calendar/actions/workflows/test.yml
    :alt: Test cone.calendar


This package provides a calendar integration in to cone.app.
It utilizes jQuery Fullcalendar
(https://github.com/fullcalendar/fullcalendar).

Currently, version 6.1 is included (see ``package.json``). See
(https://github.com/fullcalendar/fullcalendar/releases).


Calendar Widget
---------------

The calendar widget integration is done via
``cone.calendar.browser.CalendarTile`` which is registered by name ``calendar``.

The overall calendar configuration is done via model properties.

.. code-block:: python

    from cone.app.model import BaseNode
    from cone.app.model import Properties

    class MyCalendar(BaseNode):

        @property
        def properties(self):
            props = Properties()
            props.default_content_tile = 'calendar'
            props.calendar_header = {
                'left': 'month,agendaWeek,agendaDay',
                'center': 'title',
                'right': 'today prev,next'
            }
            return props

For a full list of available calendar options read
``cone.calendar.browser.CalendarTile`` documentation.

A calendar rendered on several kinds of nodes can say what it shows. Set
``calendar_title`` on a ``CalendarTile`` subclass, it is rendered as card
header above the calendar. ``None`` by default, no header then.

.. code-block:: python

    from cone.calendar.browser import CalendarTile
    from cone.tile import tile

    @tile(
        name='calendar',
        path='cone.calendar.browser:calendar.pt',
        interface=IMyCalendar,
        permission='view')
    class MyCalendarTile(CalendarTile):

        @property
        def calendar_title(self):
            return f'Calendar: {self.model.metadata.title}'


Calendar Events
---------------

In order to display events in the calendar, one or more event data sources
must be provided.

Concrete event data implementation must derive from
``cone.calendar.browser.CalendarEvents`` and provide ``events`` function.

The default event data source is expected as JSON view registered by name
``calendar_events`` for a dedictaed model context.

.. code-block:: python

    from cone.calendar.browser import CalendarEvents
    from datetime import datetime
    from pyramid.view import view_config
    import uuid

    @view_config(
        name='calendar_events',
        context=MyCalendar,
        accept='application/json',
        renderer='json',
        permission='view')
    class MyEvents(CalendarEvents):

        def events(self, start, end):
            events = [{
                'id': uuid.uuid4(),
                'title': 'Title',
                'start': datetime(2020, 4, 29, 17, 40),
                'end': datetime(2020, 4, 29, 18, 0),
            }]
            return events

For a full list of available event options read
``cone.calendar.browser.CalendarEvents`` documentation.

Multiple event data sources are defined via model properties.

.. code-block:: python

    class MyCalendar(BaseNode):

        @property
        def properties(self):
            props = Properties()
            props.calendar_sources = [{
                'events': 'event_data_1',
                'color': 'green'
            }, {
                'events': 'event_data_2',
                'color': 'red'
            }]
            return props

For a full list of available event source options read
``cone.calendar.browser.CalendarTile`` documentation.


Locales
-------

The calendar locale can be set via ``calendar_locale`` on model properties.

.. code-block:: python

    class MyCalendar(BaseNode):

        @property
        def properties(self):
            props = Properties()
            props.calendar_locale = 'de'
            return props

Default calendar locale is ``en``. The desired locales must be delivered to
the browser in order to work correctly. Locales to deliver are defined in the
application ini config as comma separated list of locale names.

.. code-block:: ini

    cone.calendar.locales = de,fr

For a complete list of available locales see ``browser/static/fullcalendar/locales``
folder of this package.


Contributors
============

- Robert Niederreiter
- Johannes Raggam


Changes
=======

2.1.0 (2026-11-09)
------------------

- The views ``calendar_event_drop`` and ``calendar_event_resize`` only accept
  ``POST`` requests, an event gets moved or resized with this method.
  [rnix]

- The JSON views answer with a general message if computing fails, the traceback
  goes to the log. Requires ``cone.app`` 2.2.0.
  [rnix]


2.0.1 (2026-10-31)
------------------

- Fix the calendar context menu being cut off at the bottom and staying in
  place while the calendar scrolled beneath it. The menu is rendered beside
  the calendar instead of in ``body`` and scrolls along with it, so it stays
  at the date it was opened for. It opens below and right of the click
  position if it fits into the visible part of the page - the viewport cut by
  the scrolling ancestors of the calendar, the content area of cone.app - else
  above or left of it, else as far inside as its size allows. The wrapper and
  its overlay are gone: the overlay caught the wheel events. A click or right
  click outside closes the menu.
  [rnix]

- Add ``disabled``, ``tooltip`` and ``cssclass`` to calendar actions, and
  ``Calendar.prepare_actions``, which prepares the targets of actions for a
  menu opened by the caller. ``Calendar.add_menu_item`` takes the menu and the
  action only.
  [rnix]

- Fix the calendar context menu closing on a click on its padding. Closing the
  menu by an item click, a click outside of it, opening another menu or
  destroying the calendar unregisters the outside click listener now.
  [rnix]

- Fix HTML injection via ``icon`` and ``title`` of calendar context menu
  actions. The icon is set as CSS class, the title as text.
  [rnix]

- Fix the outside click handler of the calendar context menu treating clicks
  inside the menu as outside clicks. The menu was compared as jQuery object
  with the DOM nodes of the event path.
  [rnix]

- Extend the JS tests to 100 % coverage, all modules including bundles are
  loaded by the tests now.
  [rnix]

- Lint and format the JS code with biome. ``make check`` runs ``biome check``,
  ``make format`` runs ``biome check --write`` (see ``include.mk``). Behavior
  unchanged.
  [rnix]

- JS tooling: Commit ``pnpm-lock.yaml``. Upgrade ``@web/test-runner`` to 1.0
  and run the JS tests headless in Chromium via Playwright, installed in the JS
  CI workflow. Pin patched versions of vulnerable transitive dependencies via
  ``pnpm.overrides``.
  [rnix]

- Replace the deprecated ``datetime.utcfromtimestamp``.
  [rnix]

- Sort the imports with ruff (one per line, ``from`` imports first, no
  sections) and format the code with ``ruff format`` (90 characters per line,
  single quotes).
  [rnix]

- Add import sorting (``I`` rules) and the formatter settings to the ruff
  configuration in ``pyproject.toml``.
  [rnix]


2.0.0 (2026-10-24)
------------------

- Add optional ``CalendarTile.calendar_title``, rendered as card header above
  the calendar. For a calendar shown on several kinds of nodes, where what it
  shows depends on the node. ``None`` by default, the markup is unchanged then.
  [rnix]

- Modernise the code ruff flags as outdated: ``class X(object)``. Remove
  unused import. Behaviour unchanged. ``super(Class, self)`` is kept, see
  ``cone.app``.
  [rnix]

- Add ``qa.ruff`` domain to Makefile and pin the ruff rule selection in
  ``pyproject.toml``, ``make check`` runs ``ruff check``.
  [rnix]

- Bootstrap 5 Styles.


1.1.1 (2026-04-28)
------------------

- Fix span tag receiving icon class in calendar contextmenu.
  [lenadax]


1.1.0 (2026-02-03)
------------------

- Refactor package layout to use ``pyproject.toml`` and implicit namespace packages.
  [rnix]

- Setup Makefile.
  [lenadax]

- Run tests with pytest.
  [lenadax]


1.0a1 (2023-05-15)
------------------

- Use ``webresource`` for resource registration.
  [rnix]


0.4 (2025-10-25)
----------------

- Pin upper versions of dependencies.
  [rnix]


0.3 (2022-10-06)
----------------

- Modernize JavaScript.
  [rnix]


0.2 (2020-07-09)
----------------

- Add ``show_contextmenu`` to ``CalendarTile``. Defaults to ``False``.
  [rnix]

- Also check for action length when handling actions dropdown in JS.
  [rnix]


0.1 (2020-05-30)
----------------

- Initial.
  [rnix, thet]


License
=======

Copyright (c) 2017-2021, BlueDynamics Alliance, Austria
Copyright (c) 2021-2025, Cone Contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this
  list of conditions and the following disclaimer in the documentation and/or
  other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
