Skip to content

Commit

Permalink
update capeditor
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace-Amondi committed Jul 12, 2023
1 parent 2a2adb0 commit a0e3dff
Show file tree
Hide file tree
Showing 22 changed files with 1,383 additions and 72 deletions.
1 change: 1 addition & 0 deletions nmhs_cms/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"pages.search",
"pages.data_request",
"pages.flex_page",
"pages.cap",

"capeditor",
"forecastmanager",
Expand Down
5 changes: 3 additions & 2 deletions nmhs_cms/static/css/cms_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ p {
}

hr {
background-color: #aaaaaa;
height: 1px
background-color: #dcdcdc;
height: 1px;
margin: 0.5rem 0;
}

.section-title {
Expand Down
6 changes: 4 additions & 2 deletions nmhs_cms/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from capeditor import urls as cap_urls
from django.conf import settings
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
Expand All @@ -7,6 +6,7 @@
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.documents import urls as wagtaildocs_urls
from forecastmanager import urls as forecastmanager_urls
from pages.cap.views import AlertList, AlertDetail

# from forecastmanager import urls as forecast_urls
from pages.home.views import list_forecasts,daily_weather
Expand All @@ -22,7 +22,9 @@
# path("", include(forecast_urls)),
path("list_forecast/", list_forecasts, name="list_forecasts"),
path("daily_weather/", daily_weather, name="daily_weather"),
path("cap/", include(cap_urls)),
path('api/cap/feed.xml', AlertList.as_view(), name="cap_alert_feed"),
path("api/cap/<uuid:identifier>.xml", AlertDetail.as_view(), name="cap_alert_detail"),

path("search/", search_views.search, name="search"),

path("", include("geomanager.urls"), name="geomanager"),
Expand Down
Empty file added pages/cap/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions pages/cap/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions pages/cap/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class CapConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'pages.cap'
47 changes: 47 additions & 0 deletions pages/cap/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated by Django 4.1.9 on 2023-07-12 10:37

import capeditor.blocks
import capeditor.models
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import uuid
import wagtail.blocks
import wagtail.documents.blocks
import wagtail.fields


class Migration(migrations.Migration):

initial = True

dependencies = [
('wagtailcore', '0083_workflowcontenttype'),
]

operations = [
migrations.CreateModel(
name='CapAlertPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
('identifier', models.UUIDField(default=uuid.uuid4, editable=False, help_text='Unique ID. Auto generated on creation.', verbose_name='Identifier')),
('sender', models.CharField(default=capeditor.models.get_default_sender, help_text='Identifies the originator of an alert. For example the website address of the institution', max_length=255, verbose_name='Sender')),
('sent', models.DateTimeField(default=django.utils.timezone.now, help_text='Time and date of origination of the alert', verbose_name='Sent')),
('status', models.CharField(choices=[('Draft', 'Draft - A preliminary template or draft, not actionable in its current form'), ('Actual', 'Actual - Actionable by all targeted recipients'), ('Test', 'Test - Technical testing only, all recipients disregard'), ('Exercise', 'Exercise - Actionable only by designated exercise participants; exercise identifier SHOULD appear in note'), ('system', 'System - For messages that support alert network internal functions')], default='Actual', help_text='The code denoting the appropriate handling of the alert', max_length=50, verbose_name='Status')),
('msgType', models.CharField(choices=[('Alert', 'Alert - Initial information requiring attention by targeted recipients'), ('Update', 'Update - Updates and supersedes the earlier message(s) identified in referenced alerts'), ('Cancel', 'Cancel - Cancels the earlier message(s) identified in references'), ('Ack', 'Acknowledge - Acknowledges receipt and acceptance of the message(s) identified in references field'), ('Error', 'Error - Indicates rejection of the message(s) identified in references; explanation SHOULD appear in note field')], default='Alert', help_text='The code denoting the nature of the alert message', max_length=100, verbose_name='Message Type')),
('scope', models.CharField(choices=[('Public', 'Public - For general dissemination to unrestricted audiences'), ('Restricted', 'Restricted - For dissemination only to users with a known operational requirement as in the restriction field'), ('Private', 'Private - For dissemination only to specified addresses as in the addresses field in the alert')], default='Public', help_text='The code denoting the intended distribution of the alert message', max_length=100, verbose_name='Scope')),
('source', models.TextField(blank=True, help_text='The text identifying the source of the alert message', null=True, verbose_name='Source')),
('restriction', models.TextField(blank=True, help_text='The text describing the rule for limiting distribution of the restricted alert message. Used when scope value is Restricted', null=True, verbose_name='Restriction')),
('code', models.CharField(blank=True, help_text='The code denoting the special handling of the alert message', max_length=100, null=True, verbose_name='Code')),
('note', models.TextField(blank=True, help_text="The text describing the purpose or significance of the alert message.The message note is primarily intended for use with <status> 'Exercise' and <msgType> 'Error'", null=True, verbose_name='Note')),
('info', wagtail.fields.StreamField([('alert_info', wagtail.blocks.StructBlock([('language', wagtail.blocks.ChoiceBlock(choices=[('en', 'English')], help_text='The code denoting the language of the alert message', label='Language', required=False)), ('category', wagtail.blocks.ChoiceBlock(choices=[('Geo', 'Geophysical'), ('Met', 'Meteorological'), ('Safety', 'General emergency and public safety'), ('Security', 'Law enforcement, military, homeland and local/private security'), ('Rescue', 'Rescue and recovery'), ('Fire', 'Fire suppression and rescue'), ('Health', 'Medical and public health'), ('Env', 'Pollution and other environmental'), ('Transport', 'Public and private transportation'), ('Infra', 'Utility, telecommunication, other non-transport infrastructure'), ('Cbrne', 'Chemical, Biological, Radiological, Nuclear or High-Yield Explosive threat or attack'), ('Other', 'Other events')], help_text='The code denoting the category of the subject event of the alert message', label='Category')), ('event', wagtail.blocks.CharBlock(help_text='The text denoting the type of the subject event of the alert message', label='Event', max_length=255)), ('urgency', wagtail.blocks.ChoiceBlock(choices=[('Immediate', 'Immediate - Responsive action SHOULD be taken immediately'), ('Expected', 'Expected - Responsive action SHOULD be taken soon (within next hour)'), ('Future', 'Future - Responsive action SHOULD be taken in the near future'), ('Past', 'Past - Responsive action is no longer required'), ('Unknown', 'Unknown - Urgency not known')], help_text='The code denoting the urgency of the subject event of the alert message', label='Urgency')), ('severity', wagtail.blocks.ChoiceBlock(choices=[('Extreme', 'Extreme - Extraordinary threat to life or property'), ('Severe', 'Severe - Significant threat to life or property'), ('Moderate', 'Moderate - Possible threat to life or property'), ('Minor', 'Minor - Minimal to no known threat to life or property'), ('Unknown', 'Unknown - Severity unknown')], help_text='The code denoting the severity of the subject event of the alert message', label='Severity')), ('certainty', wagtail.blocks.ChoiceBlock(choices=[('Observed', 'Observed - Determined to have occurred or to be ongoing'), ('Likely', 'Likely - Likely (percentage > ~50%)'), ('Possible', 'Possible - Possible but not likely (percentage <= ~50%)'), ('Unlikely', 'Unlikely - Not expected to occur (percentage ~ 0)'), ('Unknown', 'Unknown - Certainty unknown')], help_text='The code denoting the certainty of the subject event of the alert message', label='Certainty')), ('headline', wagtail.blocks.CharBlock(help_text='The text headline of the alert message. Make it direct and actionable as possible while remaining short', label='Headline', max_length=160, required=False)), ('description', wagtail.blocks.TextBlock(help_text='The text describing the subject event of the alert message. An extended description of the hazard or event that occasioned this message', label='Description', required=True)), ('instruction', wagtail.blocks.TextBlock(help_text='The text describing the recommended action to be taken by recipients of the alert message', label='Instruction', required=False)), ('effective', wagtail.blocks.DateTimeBlock(help_text='The effective time of the information of the alert message. If not set, the sent date will be used', label='Effective', required=False)), ('onset', wagtail.blocks.DateTimeBlock(help_text='The expected time of the beginning of the subject event of the alert message', label='Onset', required=False)), ('expires', wagtail.blocks.DateTimeBlock(help_text='The expiry time of the information of the alert message. If not set, each recipient is free to set its own policy as to when the message is no longer in effect.', label='Expires', required=True)), ('responseType', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('response_type', wagtail.blocks.ChoiceBlock(choices=[('Shelter', 'Shelter - Take shelter in place or per instruction'), ('Evacuate', 'Evacuate - Relocate as instructed in the instruction'), ('Prepare', 'Prepare - Relocate as instructed in the instruction'), ('Execute', 'Execute - Execute a pre-planned activity identified in instruction'), ('Avoid', 'Avoid - Avoid the subject event as per the instruction'), ('Monitor', 'Monitor - Attend to information sources as described in instruction'), ('Assess', 'Assess - Evaluate the information in this message - DONT USE FOR PUBLIC ALERTS'), ('AllClear', 'All Clear - The subject event no longer poses a threat or concern and any follow on action is described in instruction'), ('None', 'No action recommended')], help_text='The code denoting the type of action recommended for the target audience', label='Response type'))], label='Response Type'), default=[], label='Response Types')), ('senderName', wagtail.blocks.CharBlock(help_text='The human-readable name of the agency or authority issuing this alert.', label='Sender name', max_length=255, required=False)), ('contact', wagtail.blocks.CharBlock(help_text='The text describing the contact for follow-up and confirmation of the alert message', label='Contact', max_length=255, required=False)), ('audience', wagtail.blocks.CharBlock(help_text='The text describing the intended audience of the alert message', label='Audience', max_length=255, required=False)), ('area', wagtail.blocks.StreamBlock([('boundary_block', wagtail.blocks.StructBlock([('areaDesc', wagtail.blocks.TextBlock(help_text='The text describing the affected area of the alert message', label='Affected areas / Regions')), ('admin_level', wagtail.blocks.ChoiceBlock(choices=[(1, 'Level 1'), (2, 'Level 2'), (3, 'Level 3')], label='Administrative Level')), ('boundary', capeditor.blocks.BoundaryFieldBlock(help_text='The paired values of points defining a polygon that delineates the affected area of the alert message', label='Boundary')), ('altitude', wagtail.blocks.CharBlock(help_text='The specific or minimum altitude of the affected area of the alert message', label='Altitude', max_length=100, required=False)), ('ceiling', wagtail.blocks.CharBlock(help_text='The maximum altitude of the affected area of the alert message.MUST NOT be used except in combination with the altitude element. ', label='Ceiling', max_length=100, required=False))], label='Admin Boundary')), ('polygon_block', wagtail.blocks.StructBlock([('areaDesc', wagtail.blocks.TextBlock(help_text='The text describing the affected area of the alert message', label='Affected areas / Regions')), ('polygon', capeditor.blocks.PolygonFieldBlock(help_text='The paired values of points defining a polygon that delineates the affected area of the alert message', label='Polygon')), ('altitude', wagtail.blocks.CharBlock(help_text='The specific or minimum altitude of the affected area of the alert message', label='Altitude', max_length=100, required=False)), ('ceiling', wagtail.blocks.CharBlock(help_text='The maximum altitude of the affected area of the alert message.MUST NOT be used except in combination with the altitude element. ', label='Ceiling', max_length=100, required=False))], label='Draw Polygon')), ('circle_block', wagtail.blocks.StructBlock([('areaDesc', wagtail.blocks.TextBlock(help_text='The text describing the affected area of the alert message', label='Affected areas / Regions')), ('circle', capeditor.blocks.CircleFieldBlock(help_text='Drag the marker to change position', label='Circle')), ('altitude', wagtail.blocks.CharBlock(help_text='The specific or minimum altitude of the affected area of the alert message', label='Altitude', max_length=100, required=False)), ('ceiling', wagtail.blocks.CharBlock(help_text='The maximum altitude of the affected area of the alert message.MUST NOT be used except in combination with the altitude element. ', label='Ceiling', max_length=100, required=False))], label='Circle')), ('geocode_block', wagtail.blocks.StructBlock([('areaDesc', wagtail.blocks.TextBlock(help_text='The text describing the affected area of the alert message', label='Affected areas / Regions')), ('valueName', wagtail.blocks.TextBlock(label='Name')), ('value', wagtail.blocks.TextBlock(label='Value')), ('altitude', wagtail.blocks.CharBlock(help_text='The specific or minimum altitude of the affected area of the alert message', label='Altitude', max_length=100, required=False)), ('ceiling', wagtail.blocks.CharBlock(help_text='The maximum altitude of the affected area of the alert message.MUST NOT be used except in combination with the altitude element. ', label='Ceiling', max_length=100, required=False))], label='Geocode'))], help_text='Admin Boundary, Polygon, Circle or Geocode', label='Alert Area')), ('resource', wagtail.blocks.StreamBlock([('file_resource', wagtail.blocks.StructBlock([('resourceDesc', wagtail.blocks.TextBlock(help_text='The text describing the type and content of the resource file', label='Resource Description')), ('file', wagtail.documents.blocks.DocumentChooserBlock())])), ('external_resource', wagtail.blocks.StructBlock([('resourceDesc', wagtail.blocks.TextBlock(help_text='The text describing the type and content of the resource file', label='Resource Description')), ('external_url', wagtail.blocks.URLBlock(help_text='Link to external resource. This can be for example a link to related websites. ', verbose_name='External Resource Link'))]))], help_text='Additional file with supplemental information related to this alert information', label='Resources', required=False)), ('parameter', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('valueName', wagtail.blocks.TextBlock(label='Name')), ('value', wagtail.blocks.TextBlock(label='Value'))], label='Parameter'), default=[], label='Parameters')), ('eventCode', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('valueName', wagtail.blocks.TextBlock(help_text='Name for the event code', label='Name')), ('value', wagtail.blocks.TextBlock(help_text='Value of the event code', label='Value'))], label='Event Code'), default=[], label='Event codes'))], label='Alert Information'))], blank=True, null=True, use_json_field=True, verbose_name='Alert Information')),
('addresses', wagtail.fields.StreamField([('recipient', wagtail.blocks.StructBlock([('name', wagtail.blocks.TextBlock(help_text='Name of the recipient', label='Name')), ('address', wagtail.blocks.TextBlock(help_text='Address Information of the recipient', label='Address'))], label='Recipient'))], blank=True, help_text='The group listing of intended recipients of the alert message, if scope is Private', null=True, use_json_field=True, verbose_name='Addresses')),
('references', wagtail.fields.StreamField([('reference', wagtail.blocks.StructBlock([('ref_alert', wagtail.blocks.PageChooserBlock(help_text='Earlier alert referenced by this alert', label='Reference Alert'))], label='Reference Alert'))], blank=True, null=True, use_json_field=True, verbose_name='Reference Alerts')),
('incidents', wagtail.fields.StreamField([('incident', wagtail.blocks.StructBlock([('incident', wagtail.blocks.TextBlock(help_text='Referent incident to this alert message', label='Incident'))], label='Incident'))], blank=True, null=True, use_json_field=True, verbose_name='Incidents')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]
Empty file.
21 changes: 21 additions & 0 deletions pages/cap/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.db import models
from django.utils.functional import cached_property
from wagtail.models import Page
from django.urls import reverse

from capeditor.models import AbstractCapAlertPage

# Create your models here.
class CapAlertPage(AbstractCapAlertPage):
template = "capeditor/alert_detail.html"

parent_page_type = ["home.HomePage"]
subpage_types = []

content_panels = Page.content_panels + [
*AbstractCapAlertPage.content_panels
]

@cached_property
def xml_link(self):
return reverse("cap_alert_detail", args=(self.identifier,))
Loading

0 comments on commit a0e3dff

Please sign in to comment.