From 3eaed9905909ce2ae523f656dade393543dfe271 Mon Sep 17 00:00:00 2001 From: Erick Otenyo Date: Wed, 17 Jul 2024 10:26:26 +0300 Subject: [PATCH 1/2] Update humans.txt --- nmhs_cms/templates/humans.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nmhs_cms/templates/humans.txt b/nmhs_cms/templates/humans.txt index 730217a2..f575c31e 100644 --- a/nmhs_cms/templates/humans.txt +++ b/nmhs_cms/templates/humans.txt @@ -1,5 +1,10 @@ /* DEVELOPMENT TEAM */ +ClimWeb is developed by a team of developers, climate scientists, and climate experts, +together with the National Meteorological and Hydrological Services (NMHSs) in Africa. + +The core team is composed of the following members: + Developer: Erick Otenyo Github: github.com/erick-otenyo Linkedin: linkedin.com/in/erick-otenyo @@ -14,6 +19,9 @@ Climate Scientist: Abubakr Salih Babiker Linkedin: linkedin.com/in/abubakr-salih-babiker-665445185 + Climate Expert: Stella Ndagire + Linkedin: linkedin.com/in/stellandagire + Co-developed with National Meteorological and Hydrological Services (NMHSs) in Africa /* ACKNOWLEDGEMENT */ From 700f2b802109f25db44516870baaf70a1277e87e Mon Sep 17 00:00:00 2001 From: Erick Otenyo Date: Thu, 18 Jul 2024 10:57:39 +0300 Subject: [PATCH 2/2] Update homepage city forecast widget --- .../location_forecast_multiple_slider.html | 108 ++++--- .../location_forecast_single_slider.html | 268 +++++++++++++++--- pages/weather/utils.py | 12 +- pages/weather/views.py | 6 +- requirements.txt | 2 +- 5 files changed, 314 insertions(+), 82 deletions(-) diff --git a/pages/weather/templates/weather/widgets/location_forecast_multiple_slider.html b/pages/weather/templates/weather/widgets/location_forecast_multiple_slider.html index 00771916..751ff9a9 100644 --- a/pages/weather/templates/weather/widgets/location_forecast_multiple_slider.html +++ b/pages/weather/templates/weather/widgets/location_forecast_multiple_slider.html @@ -150,11 +150,10 @@ flex-direction: column; align-items: center; height: 100%; - min-height: 300px; + min-height: 250px; background-color: #ffffff20; border-radius: 8px; overflow: hidden; - padding-bottom: 20px; } .forecast-item .forecast-time { @@ -171,7 +170,8 @@ flex-direction: column; align-items: center; justify-content: center; - height: 100%; + width: 100%; + position: relative; } .forecast-item .forecast-condition .condition-img { @@ -179,6 +179,23 @@ height: 70px; } + .forecast-item .forecast-condition .condition-label { + font-size: 14px; + font-weight: 500; + text-align: center; + padding-bottom: 10px; + } + + .forecast-item .forecast-params { + flex: 1; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + width: 100%; + padding: 0 10px 20px; + } + .forecast-item .forecast-param { display: flex; flex-direction: column; @@ -275,6 +292,18 @@ {{ city.name }} {% endif %} +
+ + + {% translate "Detail" %} + + + + + +
+ +
    {% for f_date, forecasts in city_forecasts_by_date.items %} @@ -332,43 +363,50 @@
    {{ forecast.datetime|date:"H:i" }}
    -
    -
    - {{ forecast.condition.label }} +
    +
    +
    + {{ forecast.condition.label }} +
    + {% if show_condition_label %} +
    + {{ forecast.condition.label }} +
    + {% endif %}
    -
    - {% for param in weather_parameters %} -
    -
    - {% if param.parameter_info and param.parameter_info.icon %} -
    - {% svg_icon param.parameter_info.icon %} -
    - {% else %} - + {% for param in weather_parameters %} +
    +
    + {% if param.parameter_info and param.parameter_info.icon %} +
    + {% svg_icon param.parameter_info.icon %} +
    + {% else %} + {{ param.name }} - {% endif %} -
    - {% if forecast.data_values_dict|get_dict_item:param.parameter %} - {% with forecast.data_values_dict|get_dict_item:param.parameter as data_value %} + {% endif %} +
    + {% if forecast.data_values_dict|get_dict_item:param.parameter %} + {% with forecast.data_values_dict|get_dict_item:param.parameter as data_value %} +
    + {% if data_value.value_with_units %} + {{ data_value.value_with_units }} + {% else %} + - + {% endif %} +
    + {% endwith %} + {% else %}
    - {% if data_value.value_with_units %} - {{ data_value.value_with_units }} - {% else %} - - - {% endif %} + -
    - {% endwith %} - {% else %} -
    - - -
    - {% endif %} -
    - {% endfor %} + {% endif %} +
    + {% endfor %} +
{% endfor %} diff --git a/pages/weather/templates/weather/widgets/location_forecast_single_slider.html b/pages/weather/templates/weather/widgets/location_forecast_single_slider.html index 0b1f4423..30c05b15 100644 --- a/pages/weather/templates/weather/widgets/location_forecast_single_slider.html +++ b/pages/weather/templates/weather/widgets/location_forecast_single_slider.html @@ -72,26 +72,112 @@ font-size: 24px; color: #fff; margin-right: 20px; - margin-left: 50px; text-shadow: 0px 1px 10px #333; - } + } .forecast-widget .city-name .icon { margin-right: 10px; } + .forecast-content { + background-color: #ffffff10; + backdrop-filter: blur(10px); + padding: 20px; + border: 1px solid #ffffff50; + border-radius: 8px; + width: 100%; + } + + .forecast-widget .today-forecast { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + width: 100%; + border-radius: 8px; + } + + .forecast-widget .today-forecast .today { + font-size: 18px; + font-weight: bold; + backdrop-filter: blur(10px); + padding: 4px 10px; + margin-bottom: 10px; + } + + .forecast-widget .today-forecast .forecast-params { + display: flex; + width: 100%; + justify-content: center; + } + + .forecast-widget .today-forecast .forecast-params .forecast-condition { + display: flex; + flex-direction: column; + align-items: center; + height: 100px; + } + + .forecast-widget .today-forecast .forecast-params .forecast-condition .condition-img { + height: 100px; + width: 130px; + object-fit: cover; + } + + .forecast-widget .today-forecast .forecast-params .forecast-condition .condition-label { + font-size: 13px; + font-weight: bold; + text-align: center; + margin-bottom: 20px; + } + + + .today-forecast .data-params { + display: flex; + flex-direction: column; + } + + .today-forecast .forecast-param { + display: flex; + align-items: center; + width: 100%; + padding: 5px 10px; + font-size: 14px; + } + + .today-forecast .forecast-param.has-icon { + flex-direction: row; + align-items: center; + } + + .today-forecast.forecast-param-label { + text-align: center; + font-weight: 500; + } + + .today-forecast .forecast-parameter-icon { + margin-right: 10px; + } + + .today-forecast .forecast-parameter-icon svg { + height: 14px; + width: 14px; + fill: #fff; + } + + .forecast-widget .forecast-item { display: flex; flex-direction: column; align-items: center; height: 100%; - min-height: 300px; + min-height: 250px; background-color: #ffffff20; backdrop-filter: blur(10px); border-radius: 8px; overflow: hidden; - padding-bottom: 20px; + text-align: center; } .forecast-item .forecast-time { @@ -103,12 +189,23 @@ font-size: 14px; } + + .forecast-item .forecast-params { + flex: 1; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + width: 100%; + padding: 0 10px 20px; + } + .forecast-item .forecast-condition { display: flex; flex-direction: column; align-items: center; justify-content: center; - height: 100%; + width: 100%; } .forecast-item .forecast-condition .condition-img { @@ -116,6 +213,13 @@ height: 70px; } + .forecast-item .forecast-condition .condition-label { + font-size: 14px; + font-weight: 500; + text-align: center; + margin-bottom: 10px; + } + .forecast-item .forecast-param { display: flex; flex-direction: column; @@ -126,6 +230,7 @@ font-size: 14px; } + .forecast-item .forecast-param.has-icon { flex-direction: row; align-items: center; @@ -211,33 +316,29 @@ -
-
-
- {% for date, forecasts in city_forecasts_by_date.items %} -
-
-
-
- {% if date|date_is_today %} - {% translate "Today" %} - {% else %} - {{ date|date:"D" }} - {% endif %} -
-
- {{ date|date:"d F" }} +
+ {% for date, forecasts in city_forecasts_by_date.items %} + {% if date|date_is_today %} + {% with forecasts.0 as forecast %} +
+
+ {% translate "Today" %} +
+
+
+
+ {{ forecast.condition.label }}
-
- {% with forecasts.0 as forecast %} -
-
- {{ forecast.condition.label }} + {% if show_condition_label %} +
+ {{ forecast.condition.label }}
-
+ {% endif %} +
+
{% for param in weather_parameters %}
@@ -268,19 +369,106 @@ {% endif %}
{% endfor %} - {% endwith %} +
- {% endfor %} -
+ {% endwith %} + {% endif %} + {% endfor %} + + -
- - + +
+
+
+ {% for date, forecasts in city_forecasts_by_date.items %} + {% if not date|date_is_today %} +
+
+
+
+ {% if date|date_is_today %} + {% translate "Today" %} + {% else %} + {{ date|date:"D" }} + {% endif %} +
+
+ {{ date|date:"d F" }} +
+
+
+ {% with forecasts.0 as forecast %} +
+
+ {{ forecast.condition.label }} +
+ {% if show_condition_label %} +
+ {{ forecast.condition.label }} +
+ {% endif %} +
+ {% for param in weather_parameters %} +
+
+ {% if param.parameter_info and param.parameter_info.icon %} +
+ {% svg_icon param.parameter_info.icon %} +
+ {% else %} + + {{ param.name }}: + + {% endif %} +
+ {% if forecast.data_values_dict|get_dict_item:param.parameter %} + {% with forecast.data_values_dict|get_dict_item:param.parameter as data_value %} +
+ {% if data_value.value_with_units %} + {{ data_value.value_with_units }} + {% else %} + - + {% endif %} +
+ {% endwith %} + {% else %} +
+ - +
+ {% endif %} +
+ {% endfor %} + {% endwith %} +
+
+
+ {% endif %} + {% endfor %} +
+
+
+ + +
diff --git a/pages/weather/utils.py b/pages/weather/utils.py index d05a7ba1..f117fa50 100644 --- a/pages/weather/utils.py +++ b/pages/weather/utils.py @@ -4,7 +4,7 @@ from wagtail.models import Site -def get_city_forecast_detail_data(city, multi_period=False, request=None): +def get_city_forecast_detail_data(city, multi_period=False, request=None, for_home_widget=False): localtime = timezone.localtime() city_forecasts = CityForecast.objects.filter(city=city, parent__forecast_date__gte=localtime.date()) @@ -19,12 +19,16 @@ def get_city_forecast_detail_data(city, multi_period=False, request=None): if forecast_date not in city_forecasts_by_date: city_forecasts_by_date[forecast_date] = [] city_forecasts_by_date[forecast_date].append(forecast) - if request: - weather_parameters = ForecastSetting.for_request(request).data_parameters.all() + forecast_setting = ForecastSetting.for_request(request) else: site = Site.objects.get(is_default_site=True) - weather_parameters = ForecastSetting.for_site(site).data_parameters.all() + forecast_setting = ForecastSetting.for_site(site) + + if for_home_widget: + weather_parameters = forecast_setting.data_parameters.filter(show_on_home_widget=True)[:4] + else: + weather_parameters = forecast_setting.data_parameters.all() return { "city_forecasts_by_date": city_forecasts_by_date, diff --git a/pages/weather/views.py b/pages/weather/views.py index 032d0b65..64adc8a3 100644 --- a/pages/weather/views.py +++ b/pages/weather/views.py @@ -75,11 +75,13 @@ def get_home_forecast_widget(request): multi_period = forecast_periods_count > 1 - data = get_city_forecast_detail_data(city, multi_period=multi_period, request=request) + data = get_city_forecast_detail_data(city, multi_period=multi_period, request=request, + for_home_widget=True) context.update({ "city": city, - **data + "show_condition_label": forecast_setting.show_conditions_label_on_widget, + **data, }) if multi_period: diff --git a/requirements.txt b/requirements.txt index 739d0dde..a3784b5e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -72,7 +72,7 @@ filelock==3.12.0 filetype==1.2.0 Fiona==1.9.4.post1 fonttools==4.39.4 -forecastmanager==0.5.1 +forecastmanager==0.5.3 frozenlist==1.3.3 future==0.18.3 geomanager==0.4.8