Log

Todo

Docstrings (module, models, utilities)

Models

class indico.modules.logs.models.entries.CategoryLogEntry(**kwargs)

Bases: indico.modules.logs.models.entries.LogEntryBase

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
event

The Category this log entry is associated with

id
kind
logged_dt
meta
module
realm

The general area of the event the entry comes from

summary
type
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

Bases: indico.util.enum.RichIntEnum

An enumeration.

category = 1
events = 2
class indico.modules.logs.models.entries.EventLogEntry(**kwargs)

Bases: indico.modules.logs.models.entries.LogEntryBase

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
event

The Event this log entry is associated with

event_id

The ID of the event

id
kind
logged_dt
meta
module
realm

The general area of the event the entry comes from

summary
type
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

Bases: indico.util.enum.RichIntEnum

An enumeration.

emails = 5
event = 1
management = 2
participants = 3
reviewing = 4
class indico.modules.logs.models.entries.LogEntryBase(**kwargs)

Bases: sqlalchemy.orm.decl_api.Model

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

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

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.

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 0x7f8545ce5e40; no key>
user_backref_name = None
user_id = Column(None, Integer(), ForeignKey('users.users.id'), table=None)
class indico.modules.logs.models.entries.LogKind

Bases: int, indico.util.enum.IndicoEnum

An enumeration.

change = 3
negative = 4
other = 1
positive = 2

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) tuples
  • fields – 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, a type string and a convert 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

Bases: indico.modules.logs.renderers.EventLogRendererBase

name = 'email'
template_name = 'logs/entry_email.html'
class indico.modules.logs.renderers.EventLogRendererBase

Bases: object

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

Bases: indico.modules.logs.renderers.EventLogRendererBase

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'
template_kwargs = {'compare': <function render_changes>}
template_name = 'logs/entry_simple.html'