Note

Todo

Docstrings (module, models, utilities)

Models

class indico.modules.events.notes.models.notes.EventNote(**kwargs)

Bases: indico.core.db.sqlalchemy.links.LinkMixin, flask_sqlalchemy.Model

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

category = None
category_id = None
contribution
contribution_id
create_revision(render_mode, source, user)

Creates 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.

current_revision

The currently active revision of the note

current_revision_id

The ID of the current revision

delete(user)

Marks the note as deleted and adds a new empty revision

event_id
event_new
events_backref_name = u'all_notes'
classmethod get_for_linked_object(linked_object, preload_event=True)

Gets the note for the given object.

This only returns a note that hasn’t been deleted.

Parameters:
  • linked_object – An event, session, contribution or subcontribution.
  • preload_event – If all notes for the same event should be pre-loaded and cached in the app context.
classmethod get_or_create(linked_object)

Gets 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.

html

The rendered HTML of the note

id

The ID of the note

is_deleted

If the note has been deleted

linked_event
linked_event_id
locator

Defines a smart locator property.

This behaves pretty much like a normal read-only property and the decorated function should return a dict containing the necessary data to build a URL for the object.

This decorator should usually be applied to a method named locator as this name is required for get_locator to find it automatically when just passing the object.

If you need more than one locator, you can define it like this:

@locator_property
def locator(self):
    return {...}

@locator.other
def locator(self):
    return {...}

The other locator can then be accessed by passing obj.locator.other to the code expecting an object with a locator.

revisions

The list of all revisions for the note

session
session_id
subcontribution
subcontribution_id
class indico.modules.events.notes.models.notes.EventNoteRevision(**kwargs)

Bases: flask_sqlalchemy.Model

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

created_dt

The date/time when the revision was created

html

The rendered HTML of the note

id

The ID of the revision

note_id

The ID of the associated note

render_mode

How the note is rendered

source

The raw source of the note as provided by the user

user

The user who created the revision

user_id

The user who created the revision

Utilities

indico.modules.events.notes.util.build_note_api_data(note)
indico.modules.events.notes.util.build_note_legacy_api_data(note)
indico.modules.events.notes.util.can_edit_note(obj, user)

Checks if a user can edit the object’s note

indico.modules.events.notes.util.get_scheduled_notes(event)

Gets all notes of scheduled items inside an event