-
-
- {% if alert_info.event_icon %}
- {% svg_icon name=alert_info.event_icon %}
- {% endif %}
-
-
-
-
- {{ alert_info.status }}: {{ alert_info.event|truncatechars:60 }}
-
-
- {{ alert_info.severity.label }}
-
-
- {% blocktranslate trimmed with effective_on=alert_info.effective|date:"d M Y h:i a" %}
- Effective on : {{ effective_on }}
- {% endblocktranslate %}
-
-
+
+
+ {% translate "Active Alerts" %}
+
+
+ {% if page.alerts_by_expiry.active_alerts %}
+ {% for alert_info in page.alerts_by_expiry.active_alerts %}
+ {% include "cap/include_alert_list_item.html" with alert_info=alert_info %}
+ {% endfor %}
+ {% else %}
+
+
+ {% svg_icon name="alert" %}
-
-
-
+ {% translate "No active alerts currently" %}
+ {% endif %}
+
-
- {% endfor %}
+ {% if page.alerts_by_expiry.past_alerts %}
+
+
+ {% translate "Past Alerts" %}
+
+ {% for alert_info in page.alerts_by_expiry.past_alerts %}
+ {% include "cap/include_alert_list_item.html" with alert_info=alert_info %}
+ {% endfor %}
+
+ {% endif %}
{% if page.filters.severity %}
diff --git a/pages/cap/templates/cap/include_alert_list_item.html b/pages/cap/templates/cap/include_alert_list_item.html
new file mode 100644
index 00000000..95430ce2
--- /dev/null
+++ b/pages/cap/templates/cap/include_alert_list_item.html
@@ -0,0 +1,48 @@
+{% load static wagtailcore_tags wagtailimages_tags lazyimages_tags wagtailiconchooser_tags i18n %}
+
+
+
+
+
+
+ {% if alert_info.event_icon %}
+ {% svg_icon name=alert_info.event_icon %}
+ {% endif %}
+
+
+
+
+ {{ alert_info.status }}: {{ alert_info.event|truncatechars:60 }}
+
+ {% if alert_info.properties.headline %}
+
+ {{ alert_info.properties.headline|truncatechars:60 }}
+
+ {% endif %}
+
+
+ {% svg_icon name="calendar-alt" %}
+
+
+ {% translate "Issued on:" %}
+
+
+ {% blocktranslate trimmed with issued_on=alert_info.properties.sent|date:"d M Y h:i a" %}
+ {{ issued_on }}
+ {% endblocktranslate %}
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/cap/templatetags/cap_tags.py b/pages/cap/templatetags/cap_tags.py
index e121dbf1..bd5b6053 100644
--- a/pages/cap/templatetags/cap_tags.py
+++ b/pages/cap/templatetags/cap_tags.py
@@ -10,7 +10,7 @@
@register.inclusion_tag(filename="cap/active_alert.html")
def get_latest_active_cap_alert():
- alerts = CapAlertPage.objects.all().live().order_by('-sent')
+ alerts = CapAlertPage.objects.all().live().filter(status="Actual")
active_alert_infos = []
for alert in alerts:
diff --git a/pages/cap/views.py b/pages/cap/views.py
index 629e45e1..751569bf 100644
--- a/pages/cap/views.py
+++ b/pages/cap/views.py
@@ -65,18 +65,11 @@ def description(self):
return None
def items(self):
- alerts = CapAlertPage.objects.all().live()
-
- active_alert_infos = []
-
- for alert in alerts:
- for info in alert.info:
- active_alert_infos.append(alert.id)
-
- return CapAlertPage.objects.filter(id__in=active_alert_infos).live()
+ alerts = CapAlertPage.objects.all().live().filter(status="Actual")
+ return alerts
def item_title(self, item):
- return item.info[0].value.get('headline')
+ return item.title
def item_link(self, item):
return reverse("cap_alert_detail", args=[item.identifier])
@@ -91,16 +84,13 @@ def item_enclosures(self, item: Model) -> List[Enclosure]:
return super().item_enclosures(item)
def item_guid(self, item):
-
return item.identifier
def item_author_name(self, item):
-
try:
site = Site.objects.get(is_default_site=True)
if site:
cap_setting = CapSetting.for_site(site)
-
return cap_setting.sender
except Exception:
@@ -125,13 +115,13 @@ class AlertDetail(generics.RetrieveAPIView):
serializer_class.Meta.model = CapAlertPage
renderer_classes = (CapXMLRenderer,)
- queryset = CapAlertPage.objects.live()
+ queryset = CapAlertPage.objects.live().filter(status="Actual")
lookup_field = "identifier"
def cap_geojson(request):
- alerts = CapAlertPage.objects.all().live()
+ alerts = CapAlertPage.objects.all().live().filter(status="Actual")
active_alert_infos = []
for alert in alerts:
diff --git a/pages/cap/wagtail_hooks.py b/pages/cap/wagtail_hooks.py
index ed83b006..286fdc49 100644
--- a/pages/cap/wagtail_hooks.py
+++ b/pages/cap/wagtail_hooks.py
@@ -96,7 +96,7 @@ def add_geomanager_datasets(request):
if cap_geomanager_settings.show_on_mapviewer and cap_geomanager_settings.geomanager_subcategory:
# check if we have any live alerts
- has_live_alerts = CapAlertPage.objects.live().exists()
+ has_live_alerts = CapAlertPage.objects.live().filter(status="Actual").exists()
# create dataset
dataset = create_cap_geomanager_dataset(cap_geomanager_settings, has_live_alerts, request)
diff --git a/pages/home/models.py b/pages/home/models.py
index ec11407b..7b1f488e 100644
--- a/pages/home/models.py
+++ b/pages/home/models.py
@@ -262,13 +262,13 @@ def get_forecast_by_daterange(self):
@cached_property
def cap_alerts(self):
- alerts = CapAlertPage.objects.all().live().order_by('-sent')
+ alerts = CapAlertPage.objects.all().live().filter(status="Actual")
active_alert_infos = []
geojson = {"type": "FeatureCollection", "features": []}
for alert in alerts:
for info in alert.info:
- if info.value.get('expires').date() >= datetime.today().date():
+ if info.value.get('expires') > timezone.localtime():
start_time = info.value.get("effective") or alert.sent
if timezone.now() > start_time:
diff --git a/requirements.txt b/requirements.txt
index d600fc75..05402ae4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -9,7 +9,7 @@ attrs==23.1.0
beautifulsoup4==4.9.3
billiard==3.6.4.0
cachetools==5.3.0
-capeditor==0.4.8
+capeditor==0.4.9
Cartopy==0.22.0
celery==5.2.7
certifi==2023.07.22