Skip to content

Commit

Permalink
fix: Sdg goal; trend y axis min max; period sorting (#404)
Browse files Browse the repository at this point in the history
* add sdg goal; trend y axmis min max; period sorting

* fix: reformat
  • Loading branch information
msarar authored Dec 19, 2024
1 parent 1ac993b commit 35bac20
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 2 deletions.
6 changes: 6 additions & 0 deletions server/cpho/jinja2/indicators/_indicator_form.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
{{ form_field(form.table_title_overall) }}
{{ form_field(form.table_title_overall_fr) }}

{{ form_field(form.sdg_goal, rich=true) }}
{{ form_field(form.sdg_goal_fr, rich=true) }}

{{ form_field(form.impact_text, rich=true) }}
{{ form_field(form.impact_text_fr, rich=true) }}

Expand Down Expand Up @@ -179,6 +182,9 @@
{{ form_field(form.y_axis_trend) }}
{{ form_field(form.y_axis_trend_fr) }}

{{ form_field(form.y_axis_trend_min) }}
{{ form_field(form.y_axis_trend_max) }}

{{ form_field(form.trend_footnotes, rich=true) }}
{{ form_field(form.trend_footnotes_fr, rich=true) }}
</div>
Expand Down
5 changes: 3 additions & 2 deletions server/cpho/jinja2/indicators/view_indicator.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,16 @@
<table class="table table-hover">
<thead>
<tr class="text-center">
<th>{{ tm("period") }}</th>
<th>{{ tm("year_of_dashboard_update") }}</th>
<th>{{ tm("data_count") }}</th>
<th>{{ tm("hso_submission") }}</th>
<th>{{ tm("program_submission") }}</th>
<th>{{ tm("actions") }}</th>
</tr>
</thead>
<tbody>
{% for period,data_count in data_counts_by_period.items() %}
{% for period in sorted_all_shown_periods %}
{% set data_count = data_counts_by_period[period] %}
{% if data_count or period.is_current %}
{% set submission_statuses = submission_statuses_by_period[period] %}
{% set metadata_submission = false %}
Expand Down
6 changes: 6 additions & 0 deletions server/cpho/jinja2/review_indicator_metadata.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
{{ field_tr(tm("table_title_overall") , ind.table_title_overall) }}
{{ field_tr(tm("table_title_overall_french") , ind.table_title_overall_fr) }}

{{ field_tr(tm("sdg_goal") , ind.sdg_goal) }}
{{ field_tr(tm("sdg_goal_fr") , ind.sdg_goal_fr) }}

{{ field_tr(tm("general_footnotes") , ind.general_footnotes) }}
{{ field_tr(tm("general_footnotes_french") , ind.general_footnotes_fr) }}

Expand Down Expand Up @@ -185,6 +188,9 @@
{{ field_tr(tm("y_axis_trend") , ind.y_axis_trend) }}
{{ field_tr(tm("y_axis_trend_french") , ind.y_axis_trend_fr) }}

{{ field_tr(tm("y_axis_trend_min") , ind.y_axis_trend_min) }}
{{ field_tr(tm("y_axis_trend_max") , ind.y_axis_trend_max) }}

{{ field_tr(tm("trend_footnotes") , ind.trend_footnotes) }}
{{ field_tr(tm("trend_footnotes_french") , ind.trend_footnotes_fr) }}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Generated by Django 5.0.9 on 2024-12-17 18:22

import server.fields
from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("cpho", "0043_alter_indicator_name_fr_and_more"),
]

operations = [
migrations.AddField(
model_name="indicator",
name="sdg_goal",
field=server.fields.RichTextField(null=True),
),
migrations.AddField(
model_name="indicator",
name="sdg_goal_fr",
field=server.fields.RichTextField(null=True),
),
migrations.AddField(
model_name="indicator",
name="y_axis_trend_max",
field=server.fields.FloatField(null=True),
),
migrations.AddField(
model_name="indicator",
name="y_axis_trend_min",
field=server.fields.FloatField(null=True),
),
migrations.AddField(
model_name="indicatorhistory",
name="sdg_goal",
field=server.fields.RichTextField(null=True),
),
migrations.AddField(
model_name="indicatorhistory",
name="sdg_goal_fr",
field=server.fields.RichTextField(null=True),
),
migrations.AddField(
model_name="indicatorhistory",
name="y_axis_trend_max",
field=server.fields.FloatField(null=True),
),
migrations.AddField(
model_name="indicatorhistory",
name="y_axis_trend_min",
field=server.fields.FloatField(null=True),
),
]
8 changes: 8 additions & 0 deletions server/cpho/models/indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ class Indicator(models.Model, SubmissionHelpersMixin):
table_title_overall = fields.TextField(null=True, blank=True)
table_title_overall_fr = fields.TextField(null=True, blank=True)

sdg_goal = fields.RichTextField(config_name="notes", null=True, blank=True)
sdg_goal_fr = fields.RichTextField(
config_name="notes", null=True, blank=True
)

impact_text = fields.RichTextField(
config_name="notes", null=True, blank=True
)
Expand Down Expand Up @@ -275,6 +280,9 @@ class Indicator(models.Model, SubmissionHelpersMixin):
y_axis_trend = fields.TextField(null=True, blank=True)
y_axis_trend_fr = fields.TextField(null=True, blank=True)

y_axis_trend_min = fields.FloatField(null=True, blank=True)
y_axis_trend_max = fields.FloatField(null=True, blank=True)

trend_footnotes = fields.RichTextField(
config_name="notes", null=True, blank=True
)
Expand Down
20 changes: 20 additions & 0 deletions server/cpho/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1411,4 +1411,24 @@
"en": "Show French Fields",
"fr": "Afficher les champs en français",
},
"sdg_goal": {
"en": "SDG Goal",
"fr": "Objectif de développement durable",
},
"sdg_goal_french": {
"en": "SDG Goal (French)",
"fr": "Objectif de développement durable (français)",
},
"year_of_dashboard_update": {
"en": "Year of Dashboard Update",
"fr": "Année de mise à jour du tableau de bord",
},
"y_axis_trend_min": {
"en": "Y axis trend min",
"fr": "Axe y tendance min",
},
"y_axis_trend_max": {
"en": "Y axis trend max",
"fr": "Axe y tendance max",
},
}
21 changes: 21 additions & 0 deletions server/cpho/views/indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def ckEditorField(required=False, french=False, label=None):
"table_title_benchmark",
"x_axis_benchmark",
"benchmarking_dynamic_text",
"sdg_goal",
"y_axis_trend_min",
"y_axis_trend_max",
]
name = charField(required=True, label=tm("name"))
name_fr = charField(french=True, label=tm("name_french"))
Expand Down Expand Up @@ -198,6 +201,9 @@ def ckEditorField(required=False, french=False, label=None):
french=True, label=tm("table_title_overall_french")
)

sdg_goal = ckEditorField(label=tm("sdg_goal"))
sdg_goal_fr = ckEditorField(french=True, label=tm("sdg_goal_french"))

general_footnotes = ckEditorField(label=tm("general_footnotes"))
general_footnotes_fr = ckEditorField(
french=True, label=tm("general_footnotes_french")
Expand Down Expand Up @@ -317,6 +323,15 @@ def ckEditorField(required=False, french=False, label=None):
y_axis_trend = charField(label=tm("y_axis_trend"))
y_axis_trend_fr = charField(french=True, label=tm("y_axis_trend_french"))

y_axis_trend_min = forms.FloatField(
required=False,
widget=forms.NumberInput(attrs={"class": "form-control"}),
)
y_axis_trend_max = forms.FloatField(
required=False,
widget=forms.NumberInput(attrs={"class": "form-control"}),
)

trend_footnotes = ckEditorField(label=tm("trend_footnotes"))
trend_footnotes_fr = ckEditorField(
french=True, label=tm("trend_footnotes_french")
Expand Down Expand Up @@ -445,6 +460,11 @@ def get_context_data(self, **kwargs):
p: len([datum for datum in all_data if datum.period_id == p.id])
for p in all_shown_periods
}

sorted_all_shown_periods = sorted(
all_shown_periods, key=lambda p: ((-p.year), (p.quarter or -1))
)

submission_statuses_by_period = {
p: get_submission_statuses(indicator, p) for p in all_shown_periods
}
Expand All @@ -463,6 +483,7 @@ def get_context_data(self, **kwargs):
indicator
),
"alternate_periods": alternate_periods,
"sorted_all_shown_periods": sorted_all_shown_periods,
}


Expand Down
4 changes: 4 additions & 0 deletions server/cpho/views/infobase_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
ModelColumn(IndicatorHistory, "title_overall_fr"),
ModelColumn(IndicatorHistory, "table_title_overall"),
ModelColumn(IndicatorHistory, "table_title_overall_fr"),
ModelColumn(IndicatorHistory, "sdg_goal"),
ModelColumn(IndicatorHistory, "sdg_goal_fr"),
ModelColumn(IndicatorHistory, "impact_text"),
ModelColumn(IndicatorHistory, "impact_text_fr"),
ModelColumn(IndicatorHistory, "general_footnotes"),
Expand Down Expand Up @@ -88,6 +90,8 @@
ModelColumn(IndicatorHistory, "x_axis_trend_fr"),
ModelColumn(IndicatorHistory, "y_axis_trend"),
ModelColumn(IndicatorHistory, "y_axis_trend_fr"),
ModelColumn(IndicatorHistory, "y_axis_trend_min"),
ModelColumn(IndicatorHistory, "y_axis_trend_max"),
ModelColumn(IndicatorHistory, "trend_footnotes"),
ModelColumn(IndicatorHistory, "trend_footnotes_fr"),
ModelColumn(IndicatorHistory, "title_benchmark"),
Expand Down

0 comments on commit 35bac20

Please sign in to comment.