# This file is part of Indico.
# Copyright (C) 2002 - 2020 CERN
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.

from indico.core.signals.event import _signals


sidemenu = _signals.signal('sidemenu', """
Expected to return ``MenuEntryData`` objects to be added to the event side menu.
A single entry can be returned directly, multiple entries must be yielded.
""")

deleted = _signals.signal('deleted', """
Called when an event is deleted. The *sender* is the event object.
The `user` kwarg contains the user performing the deletion if available.
""")

updated = _signals.signal('updated', """
Called when basic data of an event is updated. The *sender* is the event.
A dict of changes is passed in the `changes` kwarg, with ``(old, new)``
tuples for each change. Note than the `person_links` change may happen
with `old` and `new` being the same lists for technical reasons. If the
key is present, it should be assumed that something changed (usually
the order or some data on the person link).
""")

cloned = _signals.signal('cloned', """
Called when an event is cloned. The *sender* is the `Event` object of
the old event, the new event is passed in the `new_event` kwarg.
""")

type_changed = _signals.signal('type-changed', """
Called when the type of an event is changed. The `sender` is the event,
the old type is passed in the `old_type` kwarg.
""")

moved = _signals.signal('moved', """
Called when an event is moved to a different category. The `sender` is the event,
the old category is in the `old_parent` kwarg.
""")

created = _signals.signal('created', """
Called when a new event is created. The `sender` is the new Event.
""")

session_updated = _signals.signal('session-updated', """
Called when a session is updated. The *sender* is the session.
""")

session_deleted = _signals.signal('session-deleted', """
Called when a session is deleted. The *sender* is the session.
""")

session_block_deleted = _signals.signal('session-block-deleted', """
Called when a session block is deleted. The *sender* is the session block.
This signal is called before the ``db.session.delete()`` on the block is
executed.
""")

timetable_buttons = _signals.signal('timetable-buttons', """
Expected to return a list of tuples ('button_name', 'js-call-class').
Called when building the timetable view.
""")

get_log_renderers = _signals.signal('get-log-renderers', """
Expected to return `EventLogRenderer` classes.
""")

get_feature_definitions = _signals.signal('get-feature-definitions', """
Expected to return `EventFeature` subclasses.
""")

metadata_postprocess = _signals.signal('metadata-postprocess', """
Called right after a dict-like representation of an event is created,
so that plugins can add their own fields.

The *sender* is a string parameter specifying the source of the metadata.
The *event* kwarg contains the event object. The metadata is passed in
the `data` kwarg.

The signal should return a dict that will be used to update the
original representation (fields to add or override).
""")

[((11, 11, 14, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(11, 27, 11, 37): '"""sidemenu"""', (11, 39, 14, 3): '"""\nExpected to return ``MenuEntryData`` objects to be added to the event side menu.\nA single entry can be returned directly, multiple entries must be yielded.\n"""'}, {}), '(\'sidemenu\',\n    """\nExpected to return ``MenuEntryData`` objects to be added to the event side menu.\nA single entry can be returned directly, multiple entries must be yielded.\n"""\n    )', False, 'from indico.core.signals.event import _signals\n'), ((16, 10, 19, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(16, 26, 16, 35): '"""deleted"""', (16, 37, 19, 3): '"""\nCalled when an event is deleted. The *sender* is the event object.\nThe `user` kwarg contains the user performing the deletion if available.\n"""'}, {}), '(\'deleted\',\n    """\nCalled when an event is deleted. The *sender* is the event object.\nThe `user` kwarg contains the user performing the deletion if available.\n"""\n    )', False, 'from indico.core.signals.event import _signals\n'), ((21, 10, 28, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(21, 26, 21, 35): '"""updated"""', (21, 37, 28, 3): '"""\nCalled when basic data of an event is updated. The *sender* is the event.\nA dict of changes is passed in the `changes` kwarg, with ``(old, new)``\ntuples for each change. Note than the `person_links` change may happen\nwith `old` and `new` being the same lists for technical reasons. If the\nkey is present, it should be assumed that something changed (usually\nthe order or some data on the person link).\n"""'}, {}), '(\'updated\',\n    """\nCalled when basic data of an event is updated. The *sender* is the event.\nA dict of changes is passed in the `changes` kwarg, with ``(old, new)``\ntuples for each change. Note than the `person_links` change may happen\nwith `old` and `new` being the same lists for technical reasons. If the\nkey is present, it should be assumed that something changed (usually\nthe order or some data on the person link).\n"""\n    )', False, 'from indico.core.signals.event import _signals\n'), ((30, 9, 33, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(30, 25, 30, 33): '"""cloned"""', (30, 35, 33, 3): '"""\nCalled when an event is cloned. The *sender* is the `Event` object of\nthe old event, the new event is passed in the `new_event` kwarg.\n"""'}, {}), '(\'cloned\',\n    """\nCalled when an event is cloned. The *sender* is the `Event` object of\nthe old event, the new event is passed in the `new_event` kwarg.\n"""\n    )', False, 'from indico.core.signals.event import _signals\n'), ((35, 15, 38, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(35, 31, 35, 45): '"""type-changed"""', (35, 47, 38, 3): '"""\nCalled when the type of an event is changed. The `sender` is the event,\nthe old type is passed in the `old_type` kwarg.\n"""'}, {}), '(\'type-changed\',\n    """\nCalled when the type of an event is changed. The `sender` is the event,\nthe old type is passed in the `old_type` kwarg.\n"""\n    )', False, 'from indico.core.signals.event import _signals\n'), ((40, 8, 43, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(40, 24, 40, 31): '"""moved"""', (40, 33, 43, 3): '"""\nCalled when an event is moved to a different category. The `sender` is the event,\nthe old category is in the `old_parent` kwarg.\n"""'}, {}), '(\'moved\',\n    """\nCalled when an event is moved to a different category. The `sender` is the event,\nthe old category is in the `old_parent` kwarg.\n"""\n    )', False, 'from indico.core.signals.event import _signals\n'), ((45, 10, 47, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(45, 26, 45, 35): '"""created"""', (45, 37, 47, 3): '"""\nCalled when a new event is created. The `sender` is the new Event.\n"""'}, {}), '(\'created\',\n    """\nCalled when a new event is created. The `sender` is the new Event.\n""")', False, 'from indico.core.signals.event import _signals\n'), ((49, 18, 51, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(49, 34, 49, 51): '"""session-updated"""', (49, 53, 51, 3): '"""\nCalled when a session is updated. The *sender* is the session.\n"""'}, {}), '(\'session-updated\',\n    """\nCalled when a session is updated. The *sender* is the session.\n""")', False, 'from indico.core.signals.event import _signals\n'), ((53, 18, 55, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(53, 34, 53, 51): '"""session-deleted"""', (53, 53, 55, 3): '"""\nCalled when a session is deleted. The *sender* is the session.\n"""'}, {}), '(\'session-deleted\',\n    """\nCalled when a session is deleted. The *sender* is the session.\n""")', False, 'from indico.core.signals.event import _signals\n'), ((57, 24, 61, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(57, 40, 57, 63): '"""session-block-deleted"""', (57, 65, 61, 3): '"""\nCalled when a session block is deleted. The *sender* is the session block.\nThis signal is called before the ``db.session.delete()`` on the block is\nexecuted.\n"""'}, {}), '(\'session-block-deleted\',\n    """\nCalled when a session block is deleted. The *sender* is the session block.\nThis signal is called before the ``db.session.delete()`` on the block is\nexecuted.\n"""\n    )', False, 'from indico.core.signals.event import _signals\n'), ((63, 20, 66, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(63, 36, 63, 55): '"""timetable-buttons"""', (63, 57, 66, 3): '"""\nExpected to return a list of tuples (\'button_name\', \'js-call-class\').\nCalled when building the timetable view.\n"""'}, {}), '(\'timetable-buttons\',\n    """\nExpected to return a list of tuples (\'button_name\', \'js-call-class\').\nCalled when building the timetable view.\n"""\n    )', False, 'from indico.core.signals.event import _signals\n'), ((68, 20, 70, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(68, 36, 68, 55): '"""get-log-renderers"""', (68, 57, 70, 3): '"""\nExpected to return `EventLogRenderer` classes.\n"""'}, {}), '(\'get-log-renderers\',\n    """\nExpected to return `EventLogRenderer` classes.\n""")', False, 'from indico.core.signals.event import _signals\n'), ((72, 26, 74, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(72, 42, 72, 67): '"""get-feature-definitions"""', (72, 69, 74, 3): '"""\nExpected to return `EventFeature` subclasses.\n"""'}, {}), '(\'get-feature-definitions\',\n    """\nExpected to return `EventFeature` subclasses.\n""")', False, 'from indico.core.signals.event import _signals\n'), ((76, 23, 86, 4), 'indico.core.signals.event._signals.signal', '_signals.signal', ({(76, 39, 76, 61): '"""metadata-postprocess"""', (76, 63, 86, 3): '"""\nCalled right after a dict-like representation of an event is created,\nso that plugins can add their own fields.\n\nThe *sender* is a string parameter specifying the source of the metadata.\nThe *event* kwarg contains the event object. The metadata is passed in\nthe `data` kwarg.\n\nThe signal should return a dict that will be used to update the\noriginal representation (fields to add or override).\n"""'}, {}), '(\'metadata-postprocess\',\n    """\nCalled right after a dict-like representation of an event is created,\nso that plugins can add their own fields.\n\nThe *sender* is a string parameter specifying the source of the metadata.\nThe *event* kwarg contains the event object. The metadata is passed in\nthe `data` kwarg.\n\nThe signal should return a dict that will be used to update the\noriginal representation (fields to add or override).\n"""\n    )', False, 'from indico.core.signals.event import _signals\n')]