code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def get_css_url(event, force_theme=None, for_preview=False): """Build the URL of a CSS resource. :param event: The `Event` to get the CSS url for :param force_theme: The ID of the theme to override the custom CSS resource only if it exists :param for_preview: Whether the URL is ...
Build the URL of a CSS resource. :param event: The `Event` to get the CSS url for :param force_theme: The ID of the theme to override the custom CSS resource only if it exists :param for_preview: Whether the URL is used in the CSS preview page :return: The URL to the CSS resourc...
get_css_url
python
indico/indico
indico/modules/events/layout/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/layout/util.py
MIT
def get_js_url(event, force_theme=None, for_preview=False): """Build the URL of a JS resource. :param event: The `Event` to get the JS url for :param force_theme: The ID of the theme to import the custom JS resource only if it exists :param for_preview: Whether the URL is used i...
Build the URL of a JS resource. :param event: The `Event` to get the JS url for :param force_theme: The ID of the theme to import the custom JS resource only if it exists :param for_preview: Whether the URL is used in the JS preview page :return: The URL to the JS resource
get_js_url
python
indico/indico
indico/modules/events/layout/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/layout/util.py
MIT
def get_theme_global_settings(event, theme): """Get the global settings for a theme. Some global theme settings such as 'show_notes' may be overridden by the event-specific user settings ('user_settings' in themes.yaml). These are saved in the event's layout settings under timetable_theme_settings. ...
Get the global settings for a theme. Some global theme settings such as 'show_notes' may be overridden by the event-specific user settings ('user_settings' in themes.yaml). These are saved in the event's layout settings under timetable_theme_settings.
get_theme_global_settings
python
indico/indico
indico/modules/events/layout/__init__.py
https://github.com/indico/indico/blob/master/indico/modules/events/layout/__init__.py
MIT
def get_non_inheriting_objects(root): """Get a set of child objects that do not inherit protection. :param root: An event object (`Event`, `Session`, `Contribution` or `AttachmentFolder`) which may contain objects with a different protection. """ def _query_folders(obj...
Get a set of child objects that do not inherit protection. :param root: An event object (`Event`, `Session`, `Contribution` or `AttachmentFolder`) which may contain objects with a different protection.
get_non_inheriting_objects
python
indico/indico
indico/modules/events/management/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/management/util.py
MIT
def flash_if_unregistered(event, get_person_links): """Flash message when adding users with no Indico account. :param event: Current event :param get_person_links: Callable returning list of person links to check """ old_non_users = {pl for pl in get_person_links() if p...
Flash message when adding users with no Indico account. :param event: Current event :param get_person_links: Callable returning list of person links to check
flash_if_unregistered
python
indico/indico
indico/modules/events/management/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/management/util.py
MIT
def calculate(self, formdata): """Calculate dates of cloned events. :return: a ``(dates, last_day_of_month)`` tuple """ form = self.form_class(self.event, formdata=formdata) if form.validate(): return self._calculate(form) else: raise ValueError('...
Calculate dates of cloned events. :return: a ``(dates, last_day_of_month)`` tuple
calculate
python
indico/indico
indico/modules/events/management/controllers/cloning.py
https://github.com/indico/indico/blob/master/indico/modules/events/management/controllers/cloning.py
MIT
def category_chain_overlaps(cls, category_ids): """ Create a filter that checks whether the event has any of the provided category ids in its parent chain. Warning: This method cannot be used in a negated filter. :param category_ids: A list of category ids or a single ...
Create a filter that checks whether the event has any of the provided category ids in its parent chain. Warning: This method cannot be used in a negated filter. :param category_ids: A list of category ids or a single category id
category_chain_overlaps
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def is_visible_in(cls, category_id): """ Create a filter that checks whether the event is visible in the specified category. """ cte = Category.get_visible_categories_cte(category_id) return (db.exists(db.select([1])) .where(db.and_(cte.c.id == Event.categ...
Create a filter that checks whether the event is visible in the specified category.
is_visible_in
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def start_dt_display(self): """ The 'displayed start dt', which is usually the actual start dt, but may be overridden for a conference. """ if self.type_ == EventType.conference and self.start_dt_override: return self.start_dt_override else: return...
The 'displayed start dt', which is usually the actual start dt, but may be overridden for a conference.
start_dt_display
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def end_dt_display(self): """ The 'displayed end dt', which is usually the actual end dt, but may be overridden for a conference. """ if self.type_ == EventType.conference and self.end_dt_override: return self.end_dt_override else: return self.end_...
The 'displayed end dt', which is usually the actual end dt, but may be overridden for a conference.
end_dt_display
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def logging_disabled(self): """Temporarily disable event logging. This is useful when performing actions e.g. during event creation or at other times where adding entries to the event log doesn't make sense. """ self.__logging_disabled = True try: yie...
Temporarily disable event logging. This is useful when performing actions e.g. during event creation or at other times where adding entries to the event log doesn't make sense.
logging_disabled
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def happens_between(self, from_dt=None, to_dt=None): """Check whether the event takes place within two dates.""" if from_dt is not None and to_dt is not None: # any event that takes place during the specified range return overlaps((self.start_dt, self.end_dt), (from_dt, to_dt), i...
Check whether the event takes place within two dates.
happens_between
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def starts_between(self, from_dt=None, to_dt=None): """Check whether the event starts within two dates.""" if from_dt is not None and to_dt is not None: return from_dt <= self.start_dt <= to_dt elif from_dt is not None: return self.start_dt >= from_dt elif to_dt i...
Check whether the event starts within two dates.
starts_between
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def get_relative_event_ids(self): """Get the first, last, previous and next event IDs. Any of those values may be ``None`` if there is no matching event or if it would be the current event. :return: A dict containing ``first``, ``last``, ``prev`` and ``next``. """ if se...
Get the first, last, previous and next event IDs. Any of those values may be ``None`` if there is no matching event or if it would be the current event. :return: A dict containing ``first``, ``last``, ``prev`` and ``next``.
get_relative_event_ids
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def get_verbose_title(self, show_speakers=False, show_series_pos=False): """Get the event title with some additional information. :param show_speakers: Whether to prefix the title with the speakers of the event. :param show_series_pos: Whether to suffix the title w...
Get the event title with some additional information. :param show_speakers: Whether to prefix the title with the speakers of the event. :param show_series_pos: Whether to suffix the title with the position and total count in the event's ...
get_verbose_title
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def get_sorted_tracks(self): """Return tracks and track groups in the correct order.""" track_groups = self.track_groups tracks = [track for track in self.tracks if not track.track_group] return sorted(tracks + track_groups, key=attrgetter('position'))
Return tracks and track groups in the correct order.
get_sorted_tracks
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def get_session_block(self, id_, scheduled_only=False): """Get a session block of the event.""" from indico.modules.events.sessions.models.blocks import SessionBlock query = SessionBlock.query.filter(SessionBlock.id == id_, SessionBlock.session.has(event...
Get a session block of the event.
get_session_block
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def get_allowed_sender_emails(self, *, include_current_user=True, include_creator=True, include_managers=True, include_contact=True, include_chairs=True, include_noreply=False, extra=None, _for_sending=False): """ Return the emails of p...
Return the emails of people who can be used as senders (or rather Reply-to contacts) in emails sent from within an event. :param include_current_user: Whether to include the email of the currently logged-in user :param include_creator: Whether to in...
get_allowed_sender_emails
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def has_feature(self, feature): """Check if a feature is enabled for the event.""" from indico.modules.events.features.util import is_feature_enabled return is_feature_enabled(self, feature)
Check if a feature is enabled for the event.
has_feature
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def log(self, realm, kind, module, summary, user=None, type_='simple', data=None, meta=None): """Create a new log entry for the event. :param realm: A value from :class:`.EventLogRealm` indicating the realm of the action. :param kind: A value from :class:`.LogKind` indicat...
Create a new log entry for the event. :param realm: A value from :class:`.EventLogRealm` indicating the realm of the action. :param kind: A value from :class:`.LogKind` indicating the kind of the action that was performed. :param module: A human-friend...
log
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def move_start_dt(self, start_dt): """Set event start_dt and adjust its timetable entries.""" diff = start_dt - self.start_dt for entry in self.timetable_entries.filter(TimetableEntry.parent_id.is_(None)): new_dt = entry.start_dt + diff entry.move(new_dt) self.sta...
Set event start_dt and adjust its timetable entries.
move_start_dt
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def is_user_registered(self, user): """Check whether the user is registered in the event. This takes both unpaid and complete registrations into account. """ from indico.modules.events.registration.models.forms import RegistrationForm from indico.modules.events.registration.mode...
Check whether the user is registered in the event. This takes both unpaid and complete registrations into account.
is_user_registered
python
indico/indico
indico/modules/events/models/events.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/events.py
MIT
def for_user(cls, user, event=None, is_untrusted=False): """Return EventPerson for a matching User in Event creating if needed.""" person = event.persons.filter_by(user=user).first() if event else None email_person = event.persons.filter(EventPerson.email.in_(user.all_emails)).first() if event e...
Return EventPerson for a matching User in Event creating if needed.
for_user
python
indico/indico
indico/modules/events/models/persons.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/persons.py
MIT
def merge_users(cls, target, source): """Merge the EventPersons of two users. :param target: The target user of the merge :param source: The user that is being merged into `target` """ existing_persons = {ep.event_id: ep for ep in target.event_persons} for event_person i...
Merge the EventPersons of two users. :param target: The target user of the merge :param source: The user that is being merged into `target`
merge_users
python
indico/indico
indico/modules/events/models/persons.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/persons.py
MIT
def link_user_by_email(cls, user): """ Link all email-based persons matching the user's email addresses with the user. :param user: A User object. """ from indico.modules.events.models.events import Event query = (cls.query .join(EventPerson.even...
Link all email-based persons matching the user's email addresses with the user. :param user: A User object.
link_user_by_email
python
indico/indico
indico/modules/events/models/persons.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/persons.py
MIT
def get_unsynced_data(self): """Return data no longer in sync with the user.""" if not self.user: return {} fields = ('first_name', 'last_name', '_title', 'email', 'affiliation', 'affiliation_link', 'address', 'phone') changes = {} for field in fields: per...
Return data no longer in sync with the user.
get_unsynced_data
python
indico/indico
indico/modules/events/models/persons.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/persons.py
MIT
def sync_user(self, *, notify=True): """Update all person data based on the current user data. :param notify: Whether to trigger the ``person_updated`` signal. """ if not self.user: return fields = ('first_name', 'last_name', '_title', 'email', 'affiliation', 'affili...
Update all person data based on the current user data. :param notify: Whether to trigger the ``person_updated`` signal.
sync_user
python
indico/indico
indico/modules/events/models/persons.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/persons.py
MIT
def has_role(self, role, obj): """Whether the person has a role in the ACL list of a given object.""" principals = [x for x in obj.acl_entries if x.has_management_permission(role, explicit=True)] return any(x for x in principals if ((self.user_id is not None...
Whether the person has a role in the ACL list of a given object.
has_role
python
indico/indico
indico/modules/events/models/persons.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/persons.py
MIT
def has_links(self): """Whether the person is an author, speaker, etc., in the event.""" chairpersons = {link.person for link in self.event.person_links} return ( self in chairpersons or # Check regardless of the abstract feature being enabled any(link for lin...
Whether the person is an author, speaker, etc., in the event.
has_links
python
indico/indico
indico/modules/events/models/persons.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/persons.py
MIT
def url(self): """The URL of the referenced entity. ``None`` if no URL template is defined. """ template = self.reference_type.url_template if not template: return None # XXX: Should the value be urlencoded? return template.replace('{value}', self.val...
The URL of the referenced entity. ``None`` if no URL template is defined.
url
python
indico/indico
indico/modules/events/models/references.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/references.py
MIT
def urn(self): """The URN of the referenced entity. ``None`` if no scheme is defined. """ scheme = self.reference_type.scheme if not scheme: return None return f'{scheme}:{self.value}'
The URN of the referenced entity. ``None`` if no scheme is defined.
urn
python
indico/indico
indico/modules/events/models/references.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/references.py
MIT
def load(cls, event, type_, uuid): """Load the data associated with a link. :param event: the `Event` the link belongs to :param type_: the type of the link :param uuid: the UUID of the link :return: the link data or ``None`` if the link does not exist """ try: ...
Load the data associated with a link. :param event: the `Event` the link belongs to :param type_: the type of the link :param uuid: the UUID of the link :return: the link data or ``None`` if the link does not exist
load
python
indico/indico
indico/modules/events/models/static_list_links.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/static_list_links.py
MIT
def create(cls, event, type_, data): """Create a new static list link. If one exists with the same data, that link is used instead of creating a new one. :param event: the `Event` for which to create the link :param type_: the type of the link :param data: the data to a...
Create a new static list link. If one exists with the same data, that link is used instead of creating a new one. :param event: the `Event` for which to create the link :param type_: the type of the link :param data: the data to associate with the link :return: the newl...
create
python
indico/indico
indico/modules/events/models/static_list_links.py
https://github.com/indico/indico/blob/master/indico/modules/events/models/static_list_links.py
MIT
def get_scheduled_notes(event): """Get all notes of scheduled items inside an event.""" def _sort_note_by(note): obj = note.object if hasattr(obj, 'start_dt'): return obj.start_dt, 0 else: return obj.contribution.start_dt, obj.position tt_entries = (event.tim...
Get all notes of scheduled items inside an event.
get_scheduled_notes
python
indico/indico
indico/modules/events/notes/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/notes/util.py
MIT
def can_edit_note(obj, user): """Check if a user can edit the object's note.""" if not user: return False if obj.can_manage(user): return True if isinstance(obj, db.m.Event) and obj.can_manage(user, 'submit'): return True if isinstance(obj, db.m.Contribution) and obj.can_mana...
Check if a user can edit the object's note.
can_edit_note
python
indico/indico
indico/modules/events/notes/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/notes/util.py
MIT
def check_note_revision(note, previous_revision_id, render_mode, source): """Compare revision IDs to check if the note has been modified.""" from indico.modules.events.notes.schemas import EventNoteSchema if previous_revision_id is None: if note.current_revision_id and not note.is_deleted: ...
Compare revision IDs to check if the note has been modified.
check_note_revision
python
indico/indico
indico/modules/events/notes/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/notes/util.py
MIT
def render_note(source, mode): """Render a note from source using the specified render mode.""" from indico.core.db.sqlalchemy.descriptions import RenderMode autolinker_rules = autolinker_settings.get('rules') if mode == RenderMode.html: return HTMLLinker(autolinker_rules).process(source) if...
Render a note from source using the specified render mode.
render_note
python
indico/indico
indico/modules/events/notes/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/notes/util.py
MIT
def get_for_linked_object(cls, linked_object, preload_event=True): """Get the note for the given object. This only returns a note that hasn't been deleted. :param linked_object: An event, session, contribution or subcontribution. :param preload_event: If a...
Get the note for the given object. This only returns a note that hasn't been deleted. :param linked_object: An event, session, contribution or subcontribution. :param preload_event: If all notes for the same event should be pre-loaded...
get_for_linked_object
python
indico/indico
indico/modules/events/notes/models/notes.py
https://github.com/indico/indico/blob/master/indico/modules/events/notes/models/notes.py
MIT
def get_or_create(cls, linked_object): """Get the note for the given object or creates a new one. If there is an existing note for the object, it will be returned even. Otherwise a new note is created. """ note = cls.query.filter_by(object=linked_object).first() if note...
Get the note for the given object or creates a new one. If there is an existing note for the object, it will be returned even. Otherwise a new note is created.
get_or_create
python
indico/indico
indico/modules/events/notes/models/notes.py
https://github.com/indico/indico/blob/master/indico/modules/events/notes/models/notes.py
MIT
def delete(self, user): """Mark the note as deleted and adds a new empty revision.""" self.create_revision(self.current_revision.render_mode, '', user) self.is_deleted = True
Mark the note as deleted and adds a new empty revision.
delete
python
indico/indico
indico/modules/events/notes/models/notes.py
https://github.com/indico/indico/blob/master/indico/modules/events/notes/models/notes.py
MIT
def create_revision(self, render_mode, source, user): """Create a new revision if needed and marks it as undeleted if it was. Any change to the render mode or the source causes a new revision to be created. The user is not taken into account since a user "modifying" a note without chan...
Create a new revision if needed and marks it as undeleted if it was. Any change to the render mode or the source causes a new revision to be created. The user is not taken into account since a user "modifying" a note without changing things is not really a change.
create_revision
python
indico/indico
indico/modules/events/notes/models/notes.py
https://github.com/indico/indico/blob/master/indico/modules/events/notes/models/notes.py
MIT
def get_user_reviewed_contributions(event, user): """Get the list of contributions where user already reviewed paper.""" contribs = _query_contributions_with_user_as_reviewer(event, user).all() return [contrib for contrib in contribs if contrib.paper.last_revision.has_user_reviewed(user)]
Get the list of contributions where user already reviewed paper.
get_user_reviewed_contributions
python
indico/indico
indico/modules/events/papers/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/papers/util.py
MIT
def get_user_contributions_to_review(event, user): """Get the list of contributions where user has paper to review.""" contribs = _query_contributions_with_user_as_reviewer(event, user).all() return [contrib for contrib in contribs if not contrib.paper.last_revision.has_user_reviewed(user)]
Get the list of contributions where user has paper to review.
get_user_contributions_to_review
python
indico/indico
indico/modules/events/papers/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/papers/util.py
MIT
def get_events_with_paper_roles(user, dt=None): """ Get the IDs and PR roles of events where the user has any kind of paper reviewing privileges. :param user: A `User` :param dt: Only include events taking place on/after that date :return: A dict mapping event IDs to a set of roles """ ...
Get the IDs and PR roles of events where the user has any kind of paper reviewing privileges. :param user: A `User` :param dt: Only include events taking place on/after that date :return: A dict mapping event IDs to a set of roles
get_events_with_paper_roles
python
indico/indico
indico/modules/events/papers/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/papers/util.py
MIT
def get_invalid_regforms(self, event): """Return registration forms with incompatible currencies.""" from indico.modules.events.registration.models.forms import RegistrationForm invalid_regforms = [] if self.valid_currencies is not None: invalid_regforms = (RegistrationForm.q...
Return registration forms with incompatible currencies.
get_invalid_regforms
python
indico/indico
indico/modules/events/payment/plugins.py
https://github.com/indico/indico/blob/master/indico/modules/events/payment/plugins.py
MIT
def adjust_payment_form_data(self, data): """Update the payment form data if necessary. This method can be overridden to update e.g. the amount based on choices the user makes in the payment form or to provide additional data to the form. To do so, `data` must be modified. :par...
Update the payment form data if necessary. This method can be overridden to update e.g. the amount based on choices the user makes in the payment form or to provide additional data to the form. To do so, `data` must be modified. :param data: a dict containing event, registration, amoun...
adjust_payment_form_data
python
indico/indico
indico/modules/events/payment/plugins.py
https://github.com/indico/indico/blob/master/indico/modules/events/payment/plugins.py
MIT
def render_payment_form(self, registration): """Return the payment form shown to the user. :param registration: a :class:`Registration` object """ event = registration.registration_form.event settings = self.settings.get_all() event_settings = self.event_settings.get_all...
Return the payment form shown to the user. :param registration: a :class:`Registration` object
render_payment_form
python
indico/indico
indico/modules/events/payment/plugins.py
https://github.com/indico/indico/blob/master/indico/modules/events/payment/plugins.py
MIT
def render_transaction_details(self, transaction): """Render the transaction details in event management. Override this (or inherit from the template) to show more useful data such as transaction IDs :param transaction: the :class:`PaymentTransaction` """ # Try using the templa...
Render the transaction details in event management. Override this (or inherit from the template) to show more useful data such as transaction IDs :param transaction: the :class:`PaymentTransaction`
render_transaction_details
python
indico/indico
indico/modules/events/payment/plugins.py
https://github.com/indico/indico/blob/master/indico/modules/events/payment/plugins.py
MIT
def get_payment_plugins(): """Return a dict containing the available payment plugins.""" return {remove_prefix_re.sub('', p.name): p for p in plugin_engine.get_active_plugins().values() if isinstance(p, PaymentPluginMixin)}
Return a dict containing the available payment plugins.
get_payment_plugins
python
indico/indico
indico/modules/events/payment/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/payment/util.py
MIT
def get_active_payment_plugins(event): """Return a dict containing the active payment plugins of an event.""" return {name: plugin for name, plugin in get_payment_plugins().items() if plugin.event_settings.get(event, 'enabled')}
Return a dict containing the active payment plugins of an event.
get_active_payment_plugins
python
indico/indico
indico/modules/events/payment/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/payment/util.py
MIT
def register_transaction(registration, amount, currency, action, provider=None, data=None): """Create a new transaction for a certain transaction action. :param registration: the `Registration` associated to the transaction :param amount: the (strictly positive) amount of the transaction :param currenc...
Create a new transaction for a certain transaction action. :param registration: the `Registration` associated to the transaction :param amount: the (strictly positive) amount of the transaction :param currency: the currency used for the transaction :param action: the `TransactionAction` of the transact...
register_transaction
python
indico/indico
indico/modules/events/payment/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/payment/util.py
MIT
def toggle_registration_payment(registration, paid): """Toggle registration payment. :param registration: the `Registration` to be modified :param paid: `True` if the registration should be set as paid, `False` otherwise """ currency = registration.currency if paid else registration.transaction.cur...
Toggle registration payment. :param registration: the `Registration` to be modified :param paid: `True` if the registration should be set as paid, `False` otherwise
toggle_registration_payment
python
indico/indico
indico/modules/events/payment/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/payment/util.py
MIT
def create_transaction(): """Return a callable which lets you create transactions.""" def _create_transaction(status, **params): params.setdefault('amount', 10) params.setdefault('currency', 'USD') params.setdefault('provider', '_manual') params.setdefault('data', {}) re...
Return a callable which lets you create transactions.
create_transaction
python
indico/indico
indico/modules/events/payment/testing/fixtures.py
https://github.com/indico/indico/blob/master/indico/modules/events/payment/testing/fixtures.py
MIT
def create_event_person(event, create_untrusted_persons=False, **data): """Create an event person from data passed as kwargs.""" from indico.modules.events.persons.schemas import EventPersonSchema event_person = EventPerson(event=event, is_untrusted=create_untrusted_persons) event_person.populate_from_d...
Create an event person from data passed as kwargs.
create_event_person
python
indico/indico
indico/modules/events/persons/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/persons/util.py
MIT
def get_event_person(event, data, create_untrusted_persons=False, allow_external=False): """Get an EventPerson from dictionary data. If there is already an event person in the same event and for the same user, it will be returned. Matching is done with the e-mail. """ person_type = data.get('type')...
Get an EventPerson from dictionary data. If there is already an event person in the same event and for the same user, it will be returned. Matching is done with the e-mail.
get_event_person
python
indico/indico
indico/modules/events/persons/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/persons/util.py
MIT
def check_person_link_email(event, email): """Check whether an email can be used in a person link. :param event: The event :param email: The email address """ from indico.modules.events.persons.schemas import EventPersonSchema from indico.modules.users.schemas import UserSchema email = emai...
Check whether an email can be used in a person link. :param event: The event :param email: The email address
check_person_link_email
python
indico/indico
indico/modules/events/persons/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/persons/util.py
MIT
def _iter_position(self, canvas, n_horizonal, n_vertical): """Go over every possible position on the page.""" config = self.config tpl_data = self.tpl_data while True: for n_x, n_y in product(range(n_horizonal), range(n_vertical)): yield (config.left_margin + ...
Go over every possible position on the page.
_iter_position
python
indico/indico
indico/modules/events/registration/badges.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/badges.py
MIT
def _get_static_columns(self, ids): """ Retrieve information needed for the header of the static columns (including static and personal items). :return: a list of {'id': ..., 'caption': ...} dicts """ ids = set(ids) result = [] for item_id in [x for x in ...
Retrieve information needed for the header of the static columns (including static and personal items). :return: a list of {'id': ..., 'caption': ...} dicts
_get_static_columns
python
indico/indico
indico/modules/events/registration/lists.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/lists.py
MIT
def _get_sorted_regform_items(self, item_ids): """Return the form items ordered by their position in the registration form.""" if not item_ids: return [] return (RegistrationFormItem.query .filter(~RegistrationFormItem.is_deleted, RegistrationFormItem.id.in_(item_ids)...
Return the form items ordered by their position in the registration form.
_get_sorted_regform_items
python
indico/indico
indico/modules/events/registration/lists.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/lists.py
MIT
def log_registration_check_in(registration, **kwargs): """Log a registration check-in action to the event log.""" if registration.checked_in: log_text = f'"{registration.full_name}" has been checked in' else: log_text = '"{}" check-in has been reset' registration.log(EventLogRealm.partic...
Log a registration check-in action to the event log.
log_registration_check_in
python
indico/indico
indico/modules/events/registration/logging.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/logging.py
MIT
def log_registration_updated(registration, previous_state, silent=False, **kwargs): """Log the registration status change to the event log.""" if not previous_state or silent: return previous_state_title = orig_string(previous_state.title) data = {'Previous state': previous_state_title} if (...
Log the registration status change to the event log.
log_registration_updated
python
indico/indico
indico/modules/events/registration/logging.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/logging.py
MIT
def notify_invitation(invitation, email_subject, email_body, sender_address): """Send a notification about a new registration invitation.""" email_body = replace_placeholders('registration-invitation-email', email_body, invitation=invitation) email_subject = replace_placeholders('registration-invitation-ema...
Send a notification about a new registration invitation.
notify_invitation
python
indico/indico
indico/modules/events/registration/notifications.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/notifications.py
MIT
def __init__(self, title, subtitle, type, **kwargs): """Base class for registration form statistics. :param title: str -- the title for the stats box :param subtitle: str -- the subtitle for the stats box :param type: str -- the type used in Jinja to display the stats """ ...
Base class for registration form statistics. :param title: str -- the title for the stats box :param subtitle: str -- the subtitle for the stats box :param type: str -- the type used in Jinja to display the stats
__init__
python
indico/indico
indico/modules/events/registration/stats.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/stats.py
MIT
def __new__(cls, type='default', data=None, colspan=1, classes=None, qtip=None): """ The table below indicates the valid types and expected data. +--------------------+-----------------------------------------+ | type | data | +==...
The table below indicates the valid types and expected data. +--------------------+-----------------------------------------+ | type | data | +====================+=========================================+ | `str` |...
__new__
python
indico/indico
indico/modules/events/registration/stats.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/stats.py
MIT
def _build_data(self): """Build data from registration data and field choices. :returns: (dict, bool) -- the data and a boolean to indicate whether the data contains billing information or not. """ choices = defaultdict(dict) data = defaultdict(list) al...
Build data from registration data and field choices. :returns: (dict, bool) -- the data and a boolean to indicate whether the data contains billing information or not.
_build_data
python
indico/indico
indico/modules/events/registration/stats.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/stats.py
MIT
def get_table(self): """Return a table containing the stats for each item. :return: dict -- A table with a list of head cells (key: `'head'`) and a list of rows (key: `'rows'`) where each row is a list of cells. """ table = defaultdict(list) tab...
Return a table containing the stats for each item. :return: dict -- A table with a list of head cells (key: `'head'`) and a list of rows (key: `'rows'`) where each row is a list of cells.
get_table
python
indico/indico
indico/modules/events/registration/stats.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/stats.py
MIT
def _get_billing_cells(self, data_items): """Return cells with billing information from data items. :params data_items: [DataItem] -- Data items containing billing info :returns: [Cell] -- Cells containing billing information. """ if not self._show_billing_info: retu...
Return cells with billing information from data items. :params data_items: [DataItem] -- Data items containing billing info :returns: [Cell] -- Cells containing billing information.
_get_billing_cells
python
indico/indico
indico/modules/events/registration/stats.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/stats.py
MIT
def _get_billing_details_cells(self, detail): """Return cells with detailed billing information. :params item_details: DataItem -- Data items containing billing info :returns: [Cell] -- Cells containing billing information. """ if not self._show_billing_info: return ...
Return cells with detailed billing information. :params item_details: DataItem -- Data items containing billing info :returns: [Cell] -- Cells containing billing information.
_get_billing_details_cells
python
indico/indico
indico/modules/events/registration/stats.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/stats.py
MIT
def get_title_uuid(regform, title): """Convert a string title to its UUID value. If the title does not exist in the title PD field, it will be ignored and returned as ``None``. """ if not title: return None title_field = next((x for x in regform.active_fields ...
Convert a string title to its UUID value. If the title does not exist in the title PD field, it will be ignored and returned as ``None``.
get_title_uuid
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def get_country_field(regform): """Get the country personal-data field of a regform.""" return next((x for x in regform.active_fields if (x.type == RegistrationFormItemType.field_pd and x.personal_data_type == PersonalDataType.country)), None)
Get the country personal-data field of a regform.
get_country_field
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def get_form_registration_data(regform, registration, *, management=False): """ Return a mapping from 'html_field_name' to the registration data. This also includes default values for any newly added fields since the React frontend requires all initial values to be present. """ data_by_field = r...
Return a mapping from 'html_field_name' to the registration data. This also includes default values for any newly added fields since the React frontend requires all initial values to be present.
get_form_registration_data
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def check_registration_email(regform, email, registration=None, management=False): """Check whether an email address is suitable for registration. :param regform: The registration form :param email: The email address :param registration: The existing registration (in case of mo...
Check whether an email address is suitable for registration. :param regform: The registration form :param email: The email address :param registration: The existing registration (in case of modification) :param management: If it's a manager adding a new registration
check_registration_email
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def make_registration_schema( regform, *, management=False, override_required=False, registration=None, captcha_required=False, ): """Dynamically create a Marshmallow schema based on the registration form fields. :param regform: The registration form :param management: True if this ...
Dynamically create a Marshmallow schema based on the registration form fields. :param regform: The registration form :param management: True if this registration is with manager privileges :param override_required: True if the registration manager requested to override required fields :param registrati...
make_registration_schema
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def create_personal_data_fields(regform): """Create the special section/fields for personal data.""" section = next((s for s in regform.sections if s.type == RegistrationFormItemType.section_pd), None) if section is None: section = RegistrationFormPersonalDataSection(registration_form=regform, title...
Create the special section/fields for personal data.
create_personal_data_fields
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def generate_spreadsheet_from_registrations(registrations, regform_items, static_items): """Generate a spreadsheet data from a given registration list. :param registrations: The list of registrations to include in the file :param regform_items: The registration form items to be used as columns :param s...
Generate a spreadsheet data from a given registration list. :param registrations: The list of registrations to include in the file :param regform_items: The registration form items to be used as columns :param static_items: Registration form information as extra columns
generate_spreadsheet_from_registrations
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def get_published_registrations(event, is_participant): """Get a list of published registrations for an event. :param event: the `Event` to get registrations for :param is_participant: whether the user accessing the registrations is a participant of the event :return: list of `Registration` objects ...
Get a list of published registrations for an event. :param event: the `Event` to get registrations for :param is_participant: whether the user accessing the registrations is a participant of the event :return: list of `Registration` objects
get_published_registrations
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def count_hidden_registrations(event, is_participant): """Get the number of hidden registrations for an event. :param event: the `Event` to get registrations for :param is_participant: whether the user accessing the registrations is a participant of the event :return: number of registrations """ ...
Get the number of hidden registrations for an event. :param event: the `Event` to get registrations for :param is_participant: whether the user accessing the registrations is a participant of the event :return: number of registrations
count_hidden_registrations
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def get_events_registered(user, dt=None): """Get the IDs of events where the user is registered. :param user: A `User` :param dt: Only include events taking place on/after that date :return: A set of event ids """ query = (user.registrations .options(load_only('event_id')) ...
Get the IDs of events where the user is registered. :param user: A `User` :param dt: Only include events taking place on/after that date :return: A set of event ids
get_events_registered
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def get_ticket_qr_code_data(person): """Get the data which will be saved in a ticket QR code. QR code format: { 'i': [qr_code_version, indico_url, b64(checkin_secret), b64(person_id)], # extra keys may be added by plugins (e.g. site access) } This format tries to be as compact as ...
Get the data which will be saved in a ticket QR code. QR code format: { 'i': [qr_code_version, indico_url, b64(checkin_secret), b64(person_id)], # extra keys may be added by plugins (e.g. site access) } This format tries to be as compact as possible so that the resulting QR codes ...
get_ticket_qr_code_data
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def generate_ticket_qr_code(person): """Generate an image with a QR code encoding a check-in ticket. :param registration: corresponding `Registration` object :return: A `BytesIO` containing the image data """ qr = QRCode( version=None, error_correction=constants.ERROR_CORRECT_M, ...
Generate an image with a QR code encoding a check-in ticket. :param registration: corresponding `Registration` object :return: A `BytesIO` containing the image data
generate_ticket_qr_code
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def get_event_regforms(event, user, with_registrations=False, only_in_acl=False): """Get registration forms with information about user registrations. :param event: the `Event` to get registration forms for :param user: A `User` :param with_registrations: Whether to return the user's ...
Get registration forms with information about user registrations. :param event: the `Event` to get registration forms for :param user: A `User` :param with_registrations: Whether to return the user's registration instead of just whether they hav...
get_event_regforms
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def get_event_regforms_registrations(event, user, include_scheduled=True, only_in_acl=False): """Get regforms and the associated registrations for an event+user. :param event: the `Event` to get registration forms for :param user: A `User` :param include_scheduled: Whether to include scheduled ...
Get regforms and the associated registrations for an event+user. :param event: the `Event` to get registration forms for :param user: A `User` :param include_scheduled: Whether to include scheduled but not open registration forms :param only_in_acl: Whether to include only...
get_event_regforms_registrations
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def update_regform_item_positions(regform): """Update positions when deleting/disabling an item in order to prevent gaps.""" section_positions = itertools.count(1) disabled_section_positions = itertools.count(1000) for section in sorted(regform.sections, key=attrgetter('position')): section_acti...
Update positions when deleting/disabling an item in order to prevent gaps.
update_regform_item_positions
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def import_registrations_from_csv(regform, fileobj, skip_moderation=True, notify_users=False, delimiter=','): """Import event registrants from a CSV file into a form.""" columns = ['first_name', 'last_name', 'affiliation', 'position', 'phone', 'email'] user_records = import_user_records_from_csv(fileobj, co...
Import event registrants from a CSV file into a form.
import_registrations_from_csv
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def import_invitations_from_csv(regform, fileobj, email_sender, email_subject, email_body, *, skip_moderation=True, skip_access_check=True, skip_existing=False, delimiter=','): """Import invitations from a CSV file. :return: A list of invitations and the number of skipped record...
Import invitations from a CSV file. :return: A list of invitations and the number of skipped records which is zero if skip_existing=False
import_invitations_from_csv
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def get_registered_event_persons(event): """Get all registered EventPersons of an event.""" query = (event.persons .join(Registration, and_(Registration.event_id == EventPerson.event_id, Registration.is_active, or_(Registra...
Get all registered EventPersons of an event.
get_registered_event_persons
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def serialize_registration_form(regform): """Serialize registration form to JSON-like object.""" return { 'id': regform.id, 'name': regform.title, 'identifier': f'RegistrationForm:{regform.id}', '_type': 'RegistrationForm' }
Serialize registration form to JSON-like object.
serialize_registration_form
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def diff_registration_data(old_data, new_data): """Compare two sets of registration data. :return: A dictionary where the key is the html name of the field and the value is the old and new friendly data and the field price """ diff = {} for html_field_name in old_data.keys() | new_data...
Compare two sets of registration data. :return: A dictionary where the key is the html name of the field and the value is the old and new friendly data and the field price
diff_registration_data
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def process_registration_picture(source, *, thumbnail=False): """Resize the picture to a maximum size and save it as JPEG.""" max_size = REGISTRATION_PICTURE_THUMBNAIL_SIZE if thumbnail else REGISTRATION_PICTURE_SIZE try: picture = Image.open(source) except (OSError, Image.DecompressionBombError...
Resize the picture to a maximum size and save it as JPEG.
process_registration_picture
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def load_registration_schema(regform, schema_cls, *, registration=None, partial_fields=frozenset()): """Process data using the registration schema. This takes conditional fields into account so required fields which are disabled due to a condition do not cause a validation error, but required fields th...
Process data using the registration schema. This takes conditional fields into account so required fields which are disabled due to a condition do not cause a validation error, but required fields that are active are actually enforced as required.
load_registration_schema
python
indico/indico
indico/modules/events/registration/util.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/util.py
MIT
def _get_optional_fields(self): """Get fields for which we already have a value and thus are not required.""" if self.management: # In management mode, all fields are optional return True data_by_field = self.registration.data_by_field return [form_item.html_fiel...
Get fields for which we already have a value and thus are not required.
_get_optional_fields
python
indico/indico
indico/modules/events/registration/controllers/__init__.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/controllers/__init__.py
MIT
def ui_default_value(self): """A default value that is passed to the registration form UI. For most fields this is the same as the `default_value`, but in some cases it may not be possible to get a valid default value to be used in the backend code or stored in the database; in that cas...
A default value that is passed to the registration form UI. For most fields this is the same as the `default_value`, but in some cases it may not be possible to get a valid default value to be used in the backend code or stored in the database; in that case the UI can use a more suitable ...
ui_default_value
python
indico/indico
indico/modules/events/registration/fields/base.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/fields/base.py
MIT
def create_mm_field(self, registration=None, override_required=False): """ Create a marshmallow field. When modifying an existing registration, the `registration` parameter is the previous registration. We pass the registration because some field validators need the old data. ...
Create a marshmallow field. When modifying an existing registration, the `registration` parameter is the previous registration. We pass the registration because some field validators need the old data. :param registration: The previous registration if modifying an existing one,...
create_mm_field
python
indico/indico
indico/modules/events/registration/fields/base.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/fields/base.py
MIT
def process_form_data(self, registration, value, old_data=None, billable_items_locked=False): """Convert form data into database-usable dictionary. :param registration: The registration the data is used for :param value: The value from the WTForm :param old_data: The existing `Registrat...
Convert form data into database-usable dictionary. :param registration: The registration the data is used for :param value: The value from the WTForm :param old_data: The existing `RegistrationData` in case a registration is being modified. :param billable_items...
process_form_data
python
indico/indico
indico/modules/events/registration/fields/base.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/fields/base.py
MIT
def process_field_data(cls, data, old_data=None, old_versioned_data=None): """Process the settings of the field. :param data: The field data from the client :param old_data: The old unversioned field data (if available) :param old_versioned_data: The old versioned field data (if ...
Process the settings of the field. :param data: The field data from the client :param old_data: The old unversioned field data (if available) :param old_versioned_data: The old versioned field data (if available) :return: A ``(unversioned_data, version...
process_field_data
python
indico/indico
indico/modules/events/registration/fields/base.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/fields/base.py
MIT
def locator(self): """A locator that adds the UUID if the form is private.""" token = self.uuid if self.private else None return dict(self.locator, form_token=token)
A locator that adds the UUID if the form is private.
locator
python
indico/indico
indico/modules/events/registration/models/forms.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/models/forms.py
MIT
def is_modification_allowed(self, registration): """Check whether a registration may be modified.""" if not registration.is_active: return False # Exceptional modification permissions on the registration always allows modification elif registration.modification_end_dt is not ...
Check whether a registration may be modified.
is_modification_allowed
python
indico/indico
indico/modules/events/registration/models/forms.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/models/forms.py
MIT
def get_registration(self, user=None, uuid=None, email=None): """Retrieve registrations for this registration form by user or uuid.""" if (bool(user) + bool(uuid) + bool(email)) != 1: raise ValueError('Exactly one of `user`, `uuid` and `email` must be specified') if user: ...
Retrieve registrations for this registration form by user or uuid.
get_registration
python
indico/indico
indico/modules/events/registration/models/forms.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/models/forms.py
MIT
def get_ticket_template(self): """Get the current ticket template or, if not set, the default category one.""" from indico.modules.designer.util import get_default_ticket_on_category return self.ticket_template or get_default_ticket_on_category(self.event.category)
Get the current ticket template or, if not set, the default category one.
get_ticket_template
python
indico/indico
indico/modules/events/registration/models/forms.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/models/forms.py
MIT
def get_personal_data_field_id(self, personal_data_type): """Return the field id corresponding to the personal data field with the given name.""" for field in self.active_fields: if (isinstance(field, RegistrationFormPersonalDataField) and field.personal_data_type == pers...
Return the field id corresponding to the personal data field with the given name.
get_personal_data_field_id
python
indico/indico
indico/modules/events/registration/models/forms.py
https://github.com/indico/indico/blob/master/indico/modules/events/registration/models/forms.py
MIT