Timeline Django API Documentation
This document contains Django API documentation for the timeline
app.
Included are functionalities and classes intended to be used by other
applications.
Backend API
The backend API can be retrieved as follows.
from projectroles.plugins import get_backend_api
app_alerts = get_backend_api('timeline_backend')
Make sure to also enable timeline_backend
in the ENABLED_BACKEND_PLUGINS
Django setting.
- class timeline.api.TimelineAPI[source]
Timeline backend API to be used by Django apps.
- classmethod add_event(project, app_name, user, event_name, description, classified=False, extra_data=None, status_type=None, status_desc=None, status_extra_data=None, plugin_name=None)[source]
Create and save a timeline event.
- Parameters:
project – Project object or None
app_name – Name of app from which event was invoked (must correspond to “name” attribute of app plugin)
user – User invoking the event or None
event_name – Event ID string (must match schema)
description – Description of status change (may include {object label} references)
classified – Whether event is classified (boolean, optional)
extra_data – Additional event data (dict, optional)
status_type – Initial status type (string, optional)
status_desc – Initial status description (string, optional)
status_extra_data – Extra data for initial status (dict, optional)
plugin_name – Name of plugin to which the event is related (optional, plugin with the name of the app is assumed if unset)
- Returns:
TimelineEvent object
- Raise:
ValueError if app_name or status_type is invalid
- classmethod get_event_description(event, plugin_lookup=None, request=None)[source]
Return the description of a timeline event as HTML.
- Parameters:
event – TimelineEvent object
plugin_lookup – App plugin lookup dict (optional)
request – Request object (optional)
- Returns:
String (contains HTML)
- classmethod get_models()[source]
Return timeline event model classes for custom/advanced queries.
- Returns:
TimelineEvent, TimelineEventObjectRef
- classmethod get_object_link(obj, project=None)[source]
Return an inline HTML icon link for a timeline event object history.
- Parameters:
obj – Django database object
project – Related Project object or None
- Returns:
String (contains HTML)
Models
Models for the timeline app
- class timeline.models.TimelineEvent(*args, **kwargs)[source]
Class representing a Project event. Can also be a site-wide event not linked to a specific project.
- exception DoesNotExist
- exception MultipleObjectsReturned
- add_object(obj, label, name, extra_data=None)[source]
Add object reference to an event.
- Parameters:
obj – Django object to which we want to refer
label – Label for the object in the event description (string)
name – Name or title of the object (string)
extra_data – Additional data related to object (dict, optional)
- Returns:
TimelineEventObjectRef object
- app
App from which the event was triggered
- classified
Event is classified (only viewable by user levels specified in rules)
- description
Description of status change (may include {object_name} references)
- event_name
Event ID string
- extra_data
Additional event data as JSON
- plugin
Plugin to which the event is related (optional)
- project
Project to which the event belongs
- set_status(status_type, status_desc=None, extra_data=None)[source]
Set event status.
- Parameters:
status_type – Status type string (see EVENT_STATUS_TYPES)
status_desc – Description string (optional)
extra_data – Extra data for the status (dict, optional)
- Returns:
TimelineEventStatus object
- Raise:
TypeError if status_type is invalid
- sodar_uuid
UUID for the event
- user
User who initiated the event (optional)
- class timeline.models.TimelineEventManager(*args, **kwargs)[source]
Manager for custom table-level TimelineEvent queries
- find(search_terms, keywords=None)[source]
Return events matching the query.
- Parameters:
search_terms – Search terms (list of strings)
keywords – Optional search keywords as key/value pairs (dict)
- Returns:
QuerySet of TimelineEvent objects
- get_object_events(project, object_model, object_uuid, order_by='-pk')[source]
Return events which are linked to an object reference.
- Parameters:
project – Project object or None
object_model – Object model (string)
object_uuid – sodar_uuid of the original object
order_by – Ordering (default = pk descending)
- Returns:
QuerySet
- class timeline.models.TimelineEventObjectRef(*args, **kwargs)[source]
Class representing a reference to an object (existing or removed) related to a timeline event status.
- exception DoesNotExist
- exception MultipleObjectsReturned
- event
Event to which the object belongs
- extra_data
Additional data related to the object as JSON
- label
Label for the object related to the event
- name
Name or title of the object
- object_model
Object model as string
- object_uuid
Object SODAR UUID
- sodar_uuid
UUID for this object reference
- class timeline.models.TimelineEventStatus(*args, **kwargs)[source]
Class representing a timeline event status
- exception DoesNotExist
- exception MultipleObjectsReturned
- description
Description of status change (optional)
- event
Event to which the status change belongs
- extra_data
Additional status data as JSON
- sodar_uuid
UUID for the status
- status_type
Type of the status change
- timestamp
DateTime of the status change