Log¶
Todo
Docstrings (module, models, utilities)
Models¶
- class indico.modules.logs.models.entries.CategoryLogEntry(**kwargs)¶
Log entries for categories.
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_id¶
The ID of the category
- data¶
Type-specific data
- event¶
The Category this log entry is associated with
- id¶
The ID of the log entry
- kind¶
The general kind of operation that was performed
- link_fk_name = 'category_id'¶
- logged_dt¶
The date/time when the reminder was created
- meta¶
Non-displayable data
- module¶
The module the operation was related to (does not need to match something in indico.modules and should be human-friendly but not translated).
- query: IndicoBaseQuery¶
A SQLAlchemy query for a model. Equivalent to
db.session.query(Model)
. Can be customized per-model by overridingquery_class
.Warning
The query interface is considered legacy in SQLAlchemy. Prefer using
session.execute(select())
instead.
- realm¶
The general area of the event the entry comes from
- summary¶
A short one-line description of the logged action. Should not be translated!
- type¶
The type of the log entry. This needs to match the name of a log renderer.
- user¶
The user associated with the log entry.
- user_backref_name = 'category_log_entries'¶
- user_id¶
The ID of the user associated with the entry.
- class indico.modules.logs.models.entries.CategoryLogRealm(value)¶
An enumeration.
- category = 1¶
- events = 2¶
- class indico.modules.logs.models.entries.EventLogEntry(**kwargs)¶
Log entries for events.
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.
- data¶
Type-specific data
- event¶
The Event this log entry is associated with
- event_id¶
The ID of the event
- id¶
The ID of the log entry
- kind¶
The general kind of operation that was performed
- link_fk_name = 'event_id'¶
- logged_dt¶
The date/time when the reminder was created
- meta¶
Non-displayable data
- module¶
The module the operation was related to (does not need to match something in indico.modules and should be human-friendly but not translated).
- query: IndicoBaseQuery¶
A SQLAlchemy query for a model. Equivalent to
db.session.query(Model)
. Can be customized per-model by overridingquery_class
.Warning
The query interface is considered legacy in SQLAlchemy. Prefer using
session.execute(select())
instead.
- realm¶
The general area of the event the entry comes from
- summary¶
A short one-line description of the logged action. Should not be translated!
- type¶
The type of the log entry. This needs to match the name of a log renderer.
- user¶
The user associated with the log entry.
- user_backref_name = 'event_log_entries'¶
- user_id¶
The ID of the user associated with the entry.
- class indico.modules.logs.models.entries.EventLogRealm(value)¶
An enumeration.
- emails = 5¶
- event = 1¶
- management = 2¶
- participants = 3¶
- reviewing = 4¶
- class indico.modules.logs.models.entries.LogEntryBase(**kwargs)¶
Base model for log entries.
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.
- data = Column(None, JSON(astext_type=Text()), table=None, nullable=False)¶
Type-specific data
- id = Column(None, Integer(), table=None, primary_key=True, nullable=False)¶
The ID of the log entry
- kind = Column(None, PyIntEnum(), table=None, nullable=False)¶
The general kind of operation that was performed
- link_fk_name = None¶
- property logged_date¶
- logged_dt = Column(None, UTCDateTime(), table=None, nullable=False, default=ColumnDefault(<function now_utc>))¶
The date/time when the reminder was created
- meta = Column(None, JSONB(astext_type=Text()), table=None, nullable=False)¶
Non-displayable data
- module = Column(None, String(), table=None, nullable=False)¶
The module the operation was related to (does not need to match something in indico.modules and should be human-friendly but not translated).
- query: IndicoBaseQuery¶
A SQLAlchemy query for a model. Equivalent to
db.session.query(Model)
. Can be customized per-model by overridingquery_class
.Warning
The query interface is considered legacy in SQLAlchemy. Prefer using
session.execute(select())
instead.
- render()¶
Render the log entry to be displayed.
If the renderer is not available anymore, e.g. because of a disabled plugin,
None
is returned.
- property renderer¶
- summary = Column(None, String(), table=None, nullable=False)¶
A short one-line description of the logged action. Should not be translated!
- type = Column(None, String(), table=None, nullable=False)¶
The type of the log entry. This needs to match the name of a log renderer.
- user = <RelationshipProperty at 0x7f9b7335e340; no key>¶
- user_backref_name = None¶
- user_id = Column(None, Integer(), ForeignKey('users.users.id'), table=None)¶
Utilities¶
- indico.modules.logs.util.get_log_renderers()¶
- indico.modules.logs.util.make_diff_log(changes, fields)¶
Create a value for log data containing change information.
- Parameters:
changes – a dict mapping attributes to
(old, new)
tuplesfields – a dict mapping attributes to field metadata. for simple cases this may be a string with the human-friendly title, for more advanced fields it should be a dict containing
title
, atype
string and aconvert
callback which will be invoked with a tuple containing the old and new value
- indico.modules.logs.util.render_changes(a, b, type_)¶
Render the comparison of a and b as HTML.
- Parameters:
a – old value
b – new value
type – the type determining how the values should be compared
- indico.modules.logs.util.serialize_log_entry(entry)¶
- class indico.modules.logs.renderers.EmailRenderer¶
- name = 'email'¶
unique name of the log renderer (matches EventLogEntry.type)
- template_name = 'logs/entry_email.html'¶
template used to render the log entry
- class indico.modules.logs.renderers.EventLogRendererBase¶
Base class for event log renderers.
- classmethod get_data(entry)¶
Return the entry data in a format suitable for the template.
This method may be overridden if the entry’s data needs to be preprocessed before being passed to the template.
It MUST NOT modify entry.data directly.
- name = None¶
unique name of the log renderer (matches EventLogEntry.type)
- plugin = None¶
plugin containing this renderer - assigned automatically
- classmethod render_entry(entry)¶
Render the log entry row.
- Parameters:
entry – A
EventLogEntry
- template_kwargs = {}¶
extra kwargs passed to render_template
- template_name = None¶
template used to render the log entry
- class indico.modules.logs.renderers.SimpleRenderer¶
- classmethod get_data(entry)¶
Return the entry data in a format suitable for the template.
This method may be overridden if the entry’s data needs to be preprocessed before being passed to the template.
It MUST NOT modify entry.data directly.
- name = 'simple'¶
unique name of the log renderer (matches EventLogEntry.type)
- template_kwargs = {'compare': <function render_changes>}¶
extra kwargs passed to render_template
- template_name = 'logs/entry_simple.html'¶
template used to render the log entry