Signalen / backend

Backend for Signalen, an application that helps cities manage and prioritize nuisance reports.
https://signalen.org
Mozilla Public License 2.0
5 stars 5 forks source link

Design configurable actions on signals #1

Closed bartjkdp closed 4 years ago

bartjkdp commented 4 years ago

As an administrator I want to be able to configure the actions on a signal so that I can easily tailor the workflow without requiring a developer

Current implementation

Currently actions on signals are hardcoded into the backend code. This makes Signalen difficult to tailor for other municipalities. Also a developer is required to make changes to the actions (e.g. changes in the recipient list or categories)

In the code there are two types of actions:

These actions can be limited specific conditions:

This functionality is used for example to send a group of people a notification on

Proposal

We would like to design a new extendible system for actions that can be configured from the Django admin and can easily be extended with new action types.

We propose a new model in Django:

Action

The choices of Type will be resolved dynamically in runtime. In this way a developer can easily create a new action type. Defining a new action type could look something like this.

Example of args for email

Args

{
    "recipients": [
        "Example <user@example.com>"
     ]
}

Conditions can be used to limit the action to a specific category, status or timeframe:

Conditions

{
    "main_category": {
        "is": "overlast-in-de-openbare-ruimte"
     },
    "sub_category": {
        "in": ["parkeeroverlast", "fietswrak"]
    },
    "status": {
        "in": ["GEMELD", "HEROPEND", "GESPLITST"]
    },
    "time": {
        "in": {
            "minute": "*",
            "hour": "20-4",
            "day": "*",
            "month": "*",
            "day_of_week": "1-5"
        }
    }
}

Conditions are loosely inspired on IBM's Logical JSON operators. Time roughly follows the crontab definition.

Args can contain specific configuration for that action, e.g. the list of recipients of the e-mail.

Open questions