-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reference period and remarks fields for facts (#102)
* Rename existing remarks field In preparation for adding the remark dimension field * Add new fields for fact and populate them from extra notes * Add support for importing the new fields via uploads * Add tests for new field uploads and XLS uplods * Add the ability to import the two new fields from ESTAT * Add tests for ESTAT imports of the new fields * Include the new fields in the API and exports * Include remarks in the tooltips * Don't migrate extra chart notes automatically Use a management command instead * Include reference period in the tooltip
- Loading branch information
Showing
25 changed files
with
514 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
digital_agenda/apps/core/management/commands/migrate_extra_notes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.core.management import BaseCommand | ||
from rich.console import Console | ||
|
||
from digital_agenda.apps.charts.models import ExtraChartNote | ||
from digital_agenda.apps.core.models import Fact | ||
|
||
console = Console() | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Migrate extra chart notes model" | ||
|
||
def handle(self, *args, **options): | ||
for obj in ExtraChartNote.objects.all(): | ||
reference_period = int(obj.note.strip()[-5:-1]) | ||
assert reference_period > 2000 | ||
|
||
count = Fact.objects.filter( | ||
indicator=obj.indicator, period=obj.period | ||
).update(reference_period=str(reference_period)) | ||
console.print(f"{obj} migrated to {count} Fact objects") |
26 changes: 26 additions & 0 deletions
26
digital_agenda/apps/core/migrations/0016_fact_reference_period_fact_remarks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 4.2.14 on 2024-08-21 10:13 | ||
|
||
import digital_agenda.common.citext | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0015_alter_breakdown_definition_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="fact", | ||
name="reference_period", | ||
field=digital_agenda.common.citext.CICharField( | ||
blank=True, max_length=60, null=True | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="fact", | ||
name="remarks", | ||
field=models.TextField(blank=True, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,6 +132,8 @@ class Meta: | |
"country", | ||
"value", | ||
"flags", | ||
"reference_period", | ||
"remarks", | ||
] | ||
|
||
|
||
|
Oops, something went wrong.