Note¶
Todo
Docstrings (module, models, utilities)
Models¶
-
class
indico.modules.events.notes.models.notes.
EventNote
(**kwargs)¶ Bases:
indico.core.db.sqlalchemy.links.LinkMixin
,sqlalchemy.orm.decl_api.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.
-
allowed_link_types
= frozenset({<LinkType.event: 2>, <LinkType.contribution: 3>, <LinkType.subcontribution: 4>, <LinkType.session: 5>})¶
-
category
= None¶
-
category_id
= None¶
-
contribution
¶
-
contribution_id
¶
-
create_revision
(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 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)¶ Mark the note as deleted and adds a new empty revision.
-
event
¶
-
event_id
¶
-
events_backref_name
= 'all_notes'¶
-
classmethod
get_for_linked_object
(linked_object, preload_event=True)¶ Get 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)¶ 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.
-
html
¶ The rendered HTML of the note
-
classmethod
html_matches
(search_string, exact=False)¶ Check whether the html content matches a search string.
To be used in a SQLAlchemy filter call.
Parameters: - search_string – A string to search for
- exact – Whether to search for the exact string
-
id
¶ The ID of the note
-
is_deleted
¶ If the note has been deleted
-
link_backref_name
= 'note'¶
-
link_type
¶
-
linked_event
¶
-
linked_event_id
¶
-
locator
¶ Define 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 passingobj.locator.other
to the code expecting an object with a locator.
-
revisions
¶ The list of all revisions for the note
-
session
¶
-
session_block
= None¶
-
session_block_id
= None¶
-
session_id
¶
-
subcontribution
¶
-
subcontribution_id
¶
-
unique_links
= True¶
-
-
class
indico.modules.events.notes.models.notes.
EventNoteRevision
(**kwargs)¶ Bases:
sqlalchemy.orm.decl_api.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
¶
-
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)¶ Check if a user can edit the object’s note.
-
indico.modules.events.notes.util.
get_scheduled_notes
(event)¶ Get all notes of scheduled items inside an event.