Wagtail based CAP composer
Project description
CAP Composer
A Wagtail based Common Alerting Protocol (CAP) Warning Composer. This is a web-based tool for creating and managing CAP alerts. It is designed to be used by meteorological and hydrological services, disaster management agencies, and other organizations that need to create and disseminate CAP alerts.
The Common Alerting Protocol (CAP) provides an open, non-proprietary digital message format for all types of alerts and notifications. It does not address any particular application or telecommunications method. The CAP format is compatible with emerging techniques, such as Web services, as well as existing formats including the Specific Area Message Encoding (SAME) used for the United States' National Oceanic and Atmospheric Administration (NOAA) Weather Radio and the Emergency Alert System (EAS)
The CAP xml response follows the structure of the schema provided at http://docs.oasis-open.org/emergency/cap/v1.2/CAP-v1.2-os.html
Contents
🌟 Features
- Modern user-friendly composer that follows CAP 1.2 standard. Built on top of the awesome Wagtail CMS
- Preview a CAP alert as you edit. Save drafts for sharing with colleagues and collaborating
- Inbuilt CAP validation. The page will not save if you have not input the required data according to CAP standard
- User-friendly alert area map tool that allows multiple ways of constructing alert geographic areas, while keeping the
interface simple
- Draw a polygon
- Draw a circle
- Selecting predefined areas that you create beforehand for common alert areas
- Use Geocode key values
- Inbuilt publishing workflow using Wagtail's powerful page model, with automated emails to composers and approvers
- Collaborate with team members using inbuilt comments (similar to how you could do in Word) with automated notifications. Request for changes and approvals
- Publish realtime notifications/messages to third party integrations using MQTT messaging protocol
- Predefine a list of hazards types monitored by your institution, with intuitive icons from OCHA humanitarian icons
- Extendable to add your custom logic and functionality. The package provides an
abstract
django model that can be inherited for customizations. It is all python code.
Quick start
1. Install in virtualenvironment using pip
pip install capeditor
2. Configure settings
In your settings.py
or settings/base.py
, within the installed apps, include the rest_framework, rest_framework_xml
and capeditor
as below:
INSTALLED_APPS = [
# ...
'rest_framework',
'rest_framework_xml',
'capeditor'
]
Set up restframeworkxml renderers
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
'rest_framework_xml.renderers.XMLRenderer', # add XMLRenderer
),
'DEFAULT_PARSER_CLASSES': (
'rest_framework_xml.parsers.XMLParser',
),
}
3. Run model migrations
python manage.py migrate
Usage
Creating a CAP Alert
With CAP composer successfully installed, both the Alert Listing page and Alert Detail page will be available on wagtail admin interface.
- AlertList
|_ Alert 1
|_ Alert 2
Create an Alert Listing Page
by adding it as a child page and specifying the title of the page. This page will host a
list of all alerts created.
Create one or more Alert Page
by adding it as a child to the
Alert Listing Page
Sections in the Alert Page and corresponding XML
The overall Document Object Model of an alert is as below:
Alert Identification
It contains the following entities required for a valid CAP message:
- Sender ID(sender),
- Sent Dat/Time (sent),
- Message Status (status),
- Message Type (msgType),
- Scope(scope),
- Restriction (restriction),
- Addresses (addresses),
- Note (note),
- Reference IDs (references) and
- Incident ids (incidents).
The alert identifier is generated automatically and is not editable.
NOTE: Some fields are visible based on selection of different parameters.
Alert Info
Corresponds to the <info>
element in the CAP message. The entity specifies the alert's details. At least
one block is required for an alert. If you support multiple languages, it is recommended that you use one
block for each language for the same entity.:
A CAP message expects at least one <info>
element to be present. Multiple <info>
blocks should all have the
same <category>
and <event>
element values.
Each Information
block contains the following elements:
- Language (Language)
- Event Category/Categories (category)
- Event Type (event)
- Response Type/Types (responseType)
- Urgency (urgency)
- Severity (severity)
- Certainty (certainty)
- Audience (audience)
- Event Code/Codes (eventCode)
- Effective Date/Time (effective)
- Onset Date/Time (onset)
- Expiration Date/Time (expires)
- Sender Name (senderName)
- Headline(headline)
- Event description (description)
- Instructions (instruction)
- Information URL (web),
- Contact Info (contact) and
- Parameter/Parameters(parameter)
C. Alert Area
Information Entity that defines the geographic area to be notified. Multiple areas can be defined in the alert. Each area contains the following elements:
- Area Description (areaDesc),
- Area Polygon/Polygons (polygon),
- Area Circle/Circles (circle),
- Area Geocode/Geocodes (geocode),
- Altitude (altitude),
- Ceiling (ceiling)
The Alert area input has multiple selector options:
- Polygon (drawing a polygon)
- Circle (drawing a circle which specifies the latitude, longitude and radius)
-
Predefined Area (selecting a predefined area that you create beforehand for common alert areas)
-
Geocode (specifying area geocode name and value). Using this option presumes knowledge of the coding system
Alert Resource
Entity that defines supplemental information related to an object Multiple instances of this section are allowed. It contains:
- Description (resourceDesc), MIME Type (mimeType), File Size (size), URI (uri), Dereferenced URI (derefUri) and Digest (digest)**
The Alert resource input has 2 selector options:
- File resource (takes in a file and description)
- External resource
Integrations
To integrate the alerts to another wagtail page and include in templates, for example in the home page refer to sandbox folder for sample standalone.
MQTT Integration
You can publish a mqtt message immediately after a CAP alert has been published. This allows connected clients to receive the CAP message using the MQTT protocol.
You will need to setup a MQTT broker. We have included the docker configuration to setup a local broker instance using Eclipse Mosquitto
You need to add a CAP_BROKER_URI
setting to your settings.py
which should be the URI to a MQTT broker with
permissions to publish messages.
Then using Wagtail page_published signal or Wagtail after_publish_page hook, you can attach a function to publish the MQTT message.
Below is a sample snippet to achieve this in your models.py
# models.py
from wagtail.signals import page_published
from capeditor.models import AbstractCapAlertPage
from capeditor.pubsub.publish import publish_cap_mqtt_message
class CapAlertPage(AbstractCapAlertPage):
....
def on_publish_cap_alert(sender, **kwargs):
instance = kwargs['instance']
topic = "cap/alerts/all"
publish_cap_mqtt_message(instance, topic)
page_published.connect(on_publish_cap_alert, sender=CapAlertPage)
Using the sample above, once a CAP Alert Page has published, a corresponding mqtt message
will also be published
immediately.
You will need to decide how to structure your MQTT alert topics.
You can have a complete look at the code under sandbox/home/models.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file capeditor-0.6.4.tar.gz
.
File metadata
- Download URL: capeditor-0.6.4.tar.gz
- Upload date:
- Size: 1.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be7e51f74c8e05793316f8a9cde8dfb74e666a72604a19d0a88af0ebe02d692f |
|
MD5 | 0975fd557709c286a2ef2f692b444ba4 |
|
BLAKE2b-256 | d6ea9886e9cbd062497075172c02ea0d334131818c3942cddea4a70503d2875b |
Provenance
The following attestation bundles were made for capeditor-0.6.4.tar.gz
:
Publisher:
publish.yml
on wmo-raf/cap-composer
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
capeditor-0.6.4.tar.gz
- Subject digest:
be7e51f74c8e05793316f8a9cde8dfb74e666a72604a19d0a88af0ebe02d692f
- Sigstore transparency entry: 147552458
- Sigstore integration time:
- Predicate type:
File details
Details for the file capeditor-0.6.4-py3-none-any.whl
.
File metadata
- Download URL: capeditor-0.6.4-py3-none-any.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5073f8317b0d0a7324f137a26e0e8cce8ea267c9dc770a85ae6197eb69d4a1b3 |
|
MD5 | 576c158c0530c0f45a9cd715e1448e4e |
|
BLAKE2b-256 | 1498e64a7962d4370fbacaff171da42f5f7497ffbbab7a8244d238406a9e30aa |
Provenance
The following attestation bundles were made for capeditor-0.6.4-py3-none-any.whl
:
Publisher:
publish.yml
on wmo-raf/cap-composer
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
capeditor-0.6.4-py3-none-any.whl
- Subject digest:
5073f8317b0d0a7324f137a26e0e8cce8ea267c9dc770a85ae6197eb69d4a1b3
- Sigstore transparency entry: 147552459
- Sigstore integration time:
- Predicate type: