{% extends "webpage/base.html" %} {% block content %}

Ampel Documentation

Basics

This module consists of two parts. A settings model, which allows to turn the display of the Ampel on or off on a per module basis, i.e. Relations (PersonInstitution, PersonPlace, etc.) or Entities (Person, Event, etc.). The second part is a model that stores for each instance of a given Entity or Relation a status indicator (red, yellow or green). When the Ampel is active for a given model, the indicator will be displayed in all listviews, detail views and edit views. There is also a special note field attached to each Ampel instance, allowing for writing and retrieving a note on the given Ampel instance.

Usage

In detail and edit views, the Ampel indicator can be toggled, if a user is logged in. Otherwise, the indicator will be displayed, but can't be changed. The note for a given Ampel instance can be accessed via a button; the button is blue if a note exists, otherwise it is gray.

Implementation

Two django-models are used: AmpelSettings – which links to the content_type of a given model, and a Ampel model. The Ampel model links to TempEntityClass via a one-to-one-field; this field is also used as the models primary key.
Note that all Relations and Entities inherit from TempEntityClass in Apis – which means the primary key of a Entity or Relation instance is ident to the primary key of its TempEntityClass and also with the primary key of the Ampel instance it is linked to. As all Entities and Relations inherit their primary key field from TempEntityClass, all ids are unique, even across different Entities and Relations.
Therefore you can programmatically access a given Ampel instance by looking up the primary key of an Entity or Relation instance in the Ampel model. The Ampel setup is lazy: you don't have to give initial values; a helper function was implemented that checks if an Ampel instance exists for a given Entity or Relation, and if not, it will be created. So when you first try to access an Ampel instance by toggling the indicator, the actual instance will be created automatically. That's the reason why a default display of 'red' was enabled in all views for nstances of Relations or Entities for which the Ampel has not been set yet. You can filter for those in the listview by selecting the 'default' option in the Ampel dropdown.

Dependencies

This module depends on apis_core version 18.3 or higher.

{% endblock %}