Skip to content

Commit

Permalink
Merge pull request #73 from wmo-raf/dev
Browse files Browse the repository at this point in the history
Updates and Bug Fixes
  • Loading branch information
erick-otenyo authored Feb 22, 2024
2 parents 7a98eab + 2f5d4c5 commit cea54b3
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 93 deletions.
16 changes: 2 additions & 14 deletions base/templates/blocks/products_by_service_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,11 @@
</div>

</div>
<div class="columns is-multiline service-group-items">
<div class="columns is-multiline is-mobile service-group-items">
{% for sub_page in products %}
{% if sub_page.show_in_menus and sub_page.live %}
<div class="column is-half">
<div class="column product-nav-item is-one-third-tablet is-half-mobile">
<a class="navbar-item" href="{{ sub_page.url }}">
<div class="menu-item-figure">
{% if sub_page.specific.nav_menu_icon %}
{% svg_icon sub_page.specific.nav_menu_icon %}
{% elif sub_page.specific.banner_image %}
{% image sub_page.specific.banner_image original as subpage_image %}
<img src="{{ subpage_image.url }}" alt="">
{% elif sub_page.specific.introduction_image %}
{% image sub_page.specific.introduction_image original as subpage_image %}
<img src="{{ subpage_image.url }}" alt="">
{% endif %}

</div>
<div class="menu-item-label">
{{ sub_page.title }}
</div>
Expand Down
31 changes: 23 additions & 8 deletions nmhs_cms/static/css/navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -238,34 +238,44 @@ header {

.megamenu .service-group-title {
font-size: 14px;
font-weight: 500;
padding: 10px 0;
font-weight: 600;
padding: 5px 0;
display: flex;
align-items: center;
}

.megamenu .service-group-icon {
height: 28px;
width: 28px;
height: 40px;
width: 40px;
border-radius: 50%;
margin-right: 10px;
background-color: rgba(0, 153, 151, 0.1);
display: flex;
align-items: center;
justify-content: center;
}

.megamenu .service-group-icon svg {
height: 100%;
width: 100%;
height: 24px;
width: 24px;
color: var(--primary-color);
}

.megamenu .service-group-items {
margin-left: 8px;
padding: 4px 0 0;
margin-left: 10px;
margin-bottom: 4px;
padding: 4px 0;
}

.megamenu .sub-items-list {
margin-top: 10px;
border-top: 1px solid #f0f0f0;
}

.megamenu .product-nav-item {
padding: 5px !important;
}


.alert {
font-size: 14px
Expand All @@ -282,6 +292,11 @@ header {


@media screen and (max-width: 768px) {
.megamenu {
padding: 6px;
}


.navbar-brand img {
max-width: 200px;
}
Expand Down
34 changes: 20 additions & 14 deletions pages/cap/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from capeditor.pubsub.publish import publish_cap_mqtt_message
from django.db import models
from django.urls import reverse
from django.utils import timezone
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from geomanager.models import SubCategory, Metadata
Expand Down Expand Up @@ -41,29 +40,33 @@ def get_context(self, request, *args, **kwargs):

@cached_property
def cap_alerts(self):
alerts = CapAlertPage.objects.all().live().order_by('-sent')
alerts = CapAlertPage.objects.all().live().filter(status="Actual").order_by('-sent')
alert_infos = []

for alert in alerts:
for alert_info in alert.infos:
# info = alert_info.get("info")
# if info.value.get('expires').date() >= datetime.today().date():
alert_infos.append(alert_info)

alert_infos = sorted(alert_infos, key=lambda x: x.get("sent", {}), reverse=True)

return alert_infos

@cached_property
def active_alerts(self):
alerts = CapAlertPage.objects.all().live().order_by('-sent')
active_alert_infos = []

for alert in alerts:
for alert_info in alert.infos:
info = alert_info.get("info")
if info.value.get('expires') > timezone.localtime():
active_alert_infos.append(alert_info)
def alerts_by_expiry(self):
all_alerts = self.cap_alerts
active_alerts = []
past_alerts = []

for alert in all_alerts:
if alert.get("expired"):
past_alerts.append(alert)
else:
active_alerts.append(alert)

return active_alert_infos
return {
"active_alerts": active_alerts,
"past_alerts": past_alerts
}

@cached_property
def filters(self):
Expand Down Expand Up @@ -111,6 +114,9 @@ class CapAlertPage(MetadataPageMixin, AbstractCapAlertPage):
*AbstractCapAlertPage.content_panels
]

class Meta:
ordering = ["-sent"]

@cached_property
def xml_link(self):
return reverse("cap_alert_detail", args=(self.identifier,))
Expand Down
60 changes: 58 additions & 2 deletions pages/cap/static/cap/css/cap_list_page.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,74 @@
.alert-item-title {
font-weight: 600;
font-size: 15px;

}

.alert-severity-label {
font-size: 13px;
}

.alert-effective {
.alert-time-info {
font-size: 13px;
display: flex;
align-items: center;
}

.alert-info-headline {
font-size: 13px;
margin-bottom: 4px;
}

.alert-time-info .time-icon {
width: 10px;
margin-right: 4px;
}

.alert-time-info .time-icon svg {
height: 100%;
width: 100%;
}


.alert-time-info .time-em {
font-weight: 600;
margin-right: 4px;
}


.alert-effective {
}

.alert-category-filter {
padding-bottom: 40px;
}

.alerts-group {
margin-bottom: 50px;
}

.alerts-group .group-title {
font-size: 24px;
font-weight: 600;
margin-bottom: 20px;
}

.empty-alerts-state {
display: flex;
align-items: center;
font-size: 14px;
font-weight: 600;
background-color: #f8f9fb;
padding: 20px;
}

.empty-alerts-icon {
height: 24px;
width: 24px;
margin-right: 8px;
}

.empty-alerts-icon svg {
height: 100%;
width: 100%;
fill: green;
}
61 changes: 26 additions & 35 deletions pages/cap/templates/cap/alert_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,51 +23,42 @@ <h2 class="section-title" style="padding-bottom: 0">{{ page.heading }}</h2>
</a>
</div>
{% endif %}

</div>
{% endif %}

<div class="columns is-multiline is-mobile">
<div class="column is-three-fifths-desktop is-full-touch alerts-list">
{% for alert_info in page.cap_alerts %}
<a href="{{ alert_info.url }}" class="alert-link">
<div class="alert-item"
data-severity="{{ alert_info.severity.severity }}"
data-event="{{ alert_info.info.value.event }}"
style="background-color: {{ alert_info.severity.background_color }};border: 1px solid {{ alert_info.severity.border_color }}">
<div class="alert-item-left">
<div class="alert-item-icon">
<div class="alert-icon-wrapper"
style="background-color: {{ alert_info.severity.color }};border-color: {{ alert_info.severity.border_color }};
{% if alert_info.severity.icon_color %}color:{{ alert_info.severity.icon_color }};{% endif %} ">
{% if alert_info.event_icon %}
{% svg_icon name=alert_info.event_icon %}
{% endif %}
</div>
</div>
<div class="alert-item-info">
<div class="alert-item-title">
{{ alert_info.status }}: {{ alert_info.event|truncatechars:60 }}
</div>
<div class="alert-severity-label">
{{ alert_info.severity.label }}
</div>
<div class="alert-effective">
{% blocktranslate trimmed with effective_on=alert_info.effective|date:"d M Y h:i a" %}
Effective on : {{ effective_on }}
{% endblocktranslate %}
</div>
</div>
<div class="alerts-group">
<div class="group-title">
{% translate "Active Alerts" %}
</div>

{% 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 %}
<div class="empty-alerts-state">
<div class="empty-alerts-icon">
{% svg_icon name="alert" %}
</div>
<div>
<span class="icon">
<i class="fa fa-arrow-right"></i>
</span>
{% translate "No active alerts currently" %}
</div>
</div>
{% endif %}
</div>

</a>
{% endfor %}
{% if page.alerts_by_expiry.past_alerts %}
<div class="alerts-group">
<div class="group-title">
{% translate "Past Alerts" %}
</div>
{% for alert_info in page.alerts_by_expiry.past_alerts %}
{% include "cap/include_alert_list_item.html" with alert_info=alert_info %}
{% endfor %}
</div>
{% endif %}
</div>
<div class="column is-offset-1-desktop is-one-fifth-widescreen is-full-touch is-hidden-touch">
{% if page.filters.severity %}
Expand Down
48 changes: 48 additions & 0 deletions pages/cap/templates/cap/include_alert_list_item.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% load static wagtailcore_tags wagtailimages_tags lazyimages_tags wagtailiconchooser_tags i18n %}

<a href="{{ alert_info.url }}" class="alert-link">
<div class="alert-item"
data-severity="{{ alert_info.severity.severity }}"
data-event="{{ alert_info.info.value.event }}"
style="background-color: {{ alert_info.severity.background_color }};border: 1px solid {{ alert_info.severity.border_color }}">
<div class="alert-item-left">
<div class="alert-item-icon">
<div class="alert-icon-wrapper" ¬
style="background-color: {{ alert_info.severity.color }};border-color: {{ alert_info.severity.border_color }};
{% if alert_info.severity.icon_color %}color:{{ alert_info.severity.icon_color }};{% endif %} ">
{% if alert_info.event_icon %}
{% svg_icon name=alert_info.event_icon %}
{% endif %}
</div>
</div>
<div class="alert-item-info">
<div class="alert-item-title">
{{ alert_info.status }}: {{ alert_info.event|truncatechars:60 }}
</div>
{% if alert_info.properties.headline %}
<div class="alert-info-headline">
{{ alert_info.properties.headline|truncatechars:60 }}
</div>
{% endif %}
<div class="alert-time-info">
<span class="time-icon">
{% svg_icon name="calendar-alt" %}
</span>
<span class="time-em">
{% translate "Issued on:" %}
</span>
<span>
{% blocktranslate trimmed with issued_on=alert_info.properties.sent|date:"d M Y h:i a" %}
{{ issued_on }}
{% endblocktranslate %}
</span>
</div>
</div>
</div>
<div>
<span class="icon">
<i class="fa fa-arrow-right"></i>
</span>
</div>
</div>
</a>
2 changes: 1 addition & 1 deletion pages/cap/templatetags/cap_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading

0 comments on commit cea54b3

Please sign in to comment.