Skip to content

Commit

Permalink
fix production display
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace-Amondi committed Jul 13, 2023
1 parent a0e3dff commit 5d35669
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pages/cap/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class CapAlertPage(AbstractCapAlertPage):
template = "capeditor/alert_detail.html"

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

content_panels = Page.content_panels + [
Expand Down
15 changes: 8 additions & 7 deletions pages/cap/templates/capeditor/alert_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,7 @@ <h2 class="title">



{% for item in page.info %}
{% for area in item.value.area %}
<span class="tag is-dark" style="margin:1em 0"> <i class="fa fa-location-pin pr-1"> </i>
{{area.value.areaDesc}}
</span>
{% endfor %}
{% endfor %}

<div class="cap-map-wrapper">
<div id="cap-map" style="height:500px;background-color:#e9e8e8; width:100%"></div>
<div class="map-legend">
Expand Down Expand Up @@ -96,6 +90,13 @@ <h2 class="title">
</div>
</div>
</div>
{% for item in page.info %}
{% for area in item.value.area %}
<span class="tag is-dark" style="margin:1em 0"> <i class="fa fa-location-pin pr-1"> </i>
{{area.value.areaDesc}}
</span>
{% endfor %}
{% endfor %}


</div>
Expand Down
52 changes: 50 additions & 2 deletions pages/cap/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
from wagtail.contrib.modeladmin.options import modeladmin_register

from .models import CapAlertPage
from capeditor.models import CapSetting
from wagtail.contrib.modeladmin.options import (
ModelAdmin,
modeladmin_register,
ModelAdminGroup
)
from adminboundarymanager.wagtail_hooks import AdminBoundaryManagerAdminGroup
from django.urls import path, include, reverse
from wagtail.admin.menu import MenuItem
from django.utils.translation import gettext_lazy as _

modeladmin_register(AdminBoundaryManagerAdminGroup)

class CAPAdmin(ModelAdmin):
model = CapAlertPage
menu_label = 'Alerts'
menu_icon = 'list-ul'
menu_order = 200
add_to_settings_menu = False
exclude_from_explorer = False



class CAPMenuGroup(ModelAdminGroup):
menu_label = 'CAP Alerts'
menu_icon = 'warning' # change as required
menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd)
items = (CAPAdmin,)

def get_submenu_items(self):
menu_items = []
item_order = 1

for modeladmin in self.modeladmin_instances:
menu_items.append(modeladmin.get_menu_item(order=item_order))
item_order += 1

try:
settings_url = reverse(
"wagtailsettings:edit",
args=[CapSetting._meta.app_label, CapSetting._meta.model_name, ],
)
gm_settings_menu = MenuItem(label=_("Settings"), url=settings_url, icon_name="cog")
menu_items.append(gm_settings_menu)
except Exception:
pass

return menu_items


modeladmin_register(AdminBoundaryManagerAdminGroup)
modeladmin_register(CAPMenuGroup)
10 changes: 9 additions & 1 deletion pages/home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def get_forecast_by_daterange(request):

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

active_alert_info = None
Expand Down Expand Up @@ -226,3 +226,11 @@ def get_cities(self):
return {
'cities': cities
}

def get_children(self):
children = super().get_children() # Get live and public child pages

# Exclude CAP Alert pages by their specific criteria (e.g., page type or attribute)
children = children.not_type(CapAlertPage)

return children
10 changes: 5 additions & 5 deletions pages/home/static/js/forecast_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ $(document).ready(function () {
forecast_map.fitBounds(bbox, { padding: 20 });
}

console.log(geojson)

if(geojson){
forecast_map.addSource("alert-areas", {
type: "geojson",
Expand All @@ -117,7 +115,6 @@ $(document).ready(function () {
type: "fill",
source: "alert-areas",
paint: {
"fill-color": "#088",
"fill-color": [
"case",
["==", ["get", "severity"], "Extreme"],
Expand All @@ -133,6 +130,7 @@ $(document).ready(function () {
"black",
],
"fill-opacity": 0.7,
"fill-outline-color": "#000",
},
});

Expand Down Expand Up @@ -195,6 +193,9 @@ $(document).ready(function () {
forecast_map.getCanvas().style.cursor = "";
});

var initDate = document.getElementById("daily_forecast");
setForecastData(initDate.value)


})

Expand Down Expand Up @@ -234,8 +235,7 @@ $(document).ready(function () {

}

var initDate = document.getElementById("daily_forecast");
setForecastData(initDate.value)




Expand Down
2 changes: 2 additions & 0 deletions pages/home/templates/home_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
const temp_units = "{{settings.forecastmanager.ForecastSetting.get_temp_units_display}}"
const forecast_api = "{% url 'forecast-list'%}"
const static_path = '{% static "forecastmanager/img/" %}'
const geojson = JSON.parse("{{self.get_alerts.geojson|escapejs}}")


</script>

Expand Down
8 changes: 1 addition & 7 deletions pages/home/templates/section/forecast_include.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% load static nmhs_cms_tags %}


{% if self.enable_weather_forecasts == True %}


Expand Down Expand Up @@ -183,11 +184,4 @@ <h2 class="title" style="font-size:14px; margin-bottom:1em">CAP Alerts</h2>
</section>
{% endif %}

{% block extra_js %}

<script>
const geojson = JSON.parse("{{self.get_alerts.geojson|escapejs}}")

</script>

{% endblock extra_js %}

0 comments on commit 5d35669

Please sign in to comment.