-
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.
Merge pull request #706 from basedosdados/staging
Staging
- Loading branch information
Showing
28 changed files
with
1,888 additions
and
213 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django import forms | ||
|
||
class ReorderObservationLevelsForm(forms.Form): | ||
ordered_entities = forms.CharField( | ||
required=False, | ||
widget=forms.Textarea(attrs={"rows": 10, "cols": 40}), | ||
help_text="Enter entity names one per line in desired order", | ||
) |
29 changes: 29 additions & 0 deletions
29
backend/apps/api/v1/migrations/0037_area_entity_area_level_area_parent.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,29 @@ | ||
# Generated by Django 4.2.16 on 2024-11-03 01:29 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('v1', '0036_datetimerange_units'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='area', | ||
name='entity', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='areas', to='v1.entity'), | ||
), | ||
migrations.AddField( | ||
model_name='area', | ||
name='level', | ||
field=models.IntegerField(blank=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='area', | ||
name='parent', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='children', to='v1.area'), | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
backend/apps/api/v1/migrations/0038_rename_level_area_administrative_level.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,18 @@ | ||
# Generated by Django 4.2.16 on 2024-11-03 01:37 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('v1', '0037_area_entity_area_level_area_parent'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='area', | ||
old_name='level', | ||
new_name='administrative_level', | ||
), | ||
] |
41 changes: 41 additions & 0 deletions
41
backend/apps/api/v1/migrations/0039_dataset_organizations.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,41 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 4.2.10 on 2024-05-10 15:30 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def migrate_organization_to_organizations(apps, schema_editor): | ||
Dataset = apps.get_model('v1', 'Dataset') | ||
for dataset in Dataset.objects.all(): | ||
if dataset.organization: | ||
dataset.organizations.add(dataset.organization) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('v1', '0038_rename_level_area_administrative_level'), | ||
] | ||
|
||
operations = [ | ||
# Add new ManyToMany field | ||
migrations.AddField( | ||
model_name='dataset', | ||
name='organizations', | ||
field=models.ManyToManyField( | ||
related_name='datasets', | ||
to='v1.organization', | ||
verbose_name='Organizations', | ||
help_text='Organizations associated with this dataset', | ||
), | ||
), | ||
# Run data migration | ||
migrations.RunPython( | ||
migrate_organization_to_organizations, | ||
reverse_code=migrations.RunPython.noop | ||
), | ||
# Remove old ForeignKey field | ||
migrations.RemoveField( | ||
model_name='dataset', | ||
name='organization', | ||
), | ||
] |
78 changes: 78 additions & 0 deletions
78
backend/apps/api/v1/migrations/0040_table_publishers_data_cleaners.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,78 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 4.2.10 on 2024-05-10 16:00 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
def migrate_publishers_and_cleaners(apps, schema_editor): | ||
"""Migrate existing ForeignKey relationships to ManyToMany""" | ||
Table = apps.get_model('v1', 'Table') | ||
for table in Table.objects.all(): | ||
# Store old ForeignKey values | ||
old_publisher = getattr(table, 'published_by_old', None) | ||
old_cleaner = getattr(table, 'data_cleaned_by_old', None) | ||
|
||
# Add to new M2M fields if they existed | ||
if old_publisher: | ||
table.published_by.add(old_publisher) | ||
if old_cleaner: | ||
table.data_cleaned_by.add(old_cleaner) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('v1', '0039_dataset_organizations'), | ||
] | ||
|
||
operations = [ | ||
# Rename old fields temporarily | ||
migrations.RenameField( | ||
model_name='table', | ||
old_name='published_by', | ||
new_name='published_by_old', | ||
), | ||
migrations.RenameField( | ||
model_name='table', | ||
old_name='data_cleaned_by', | ||
new_name='data_cleaned_by_old', | ||
), | ||
# Add new M2M fields | ||
migrations.AddField( | ||
model_name='table', | ||
name='published_by', | ||
field=models.ManyToManyField( | ||
blank=True, | ||
related_name='tables_published', | ||
to=settings.AUTH_USER_MODEL, | ||
verbose_name='Published by', | ||
help_text='People who published the table', | ||
), | ||
), | ||
migrations.AddField( | ||
model_name='table', | ||
name='data_cleaned_by', | ||
field=models.ManyToManyField( | ||
blank=True, | ||
related_name='tables_cleaned', | ||
to=settings.AUTH_USER_MODEL, | ||
verbose_name='Data cleaned by', | ||
help_text='People who cleaned the data', | ||
), | ||
), | ||
# Run data migration | ||
migrations.RunPython( | ||
migrate_publishers_and_cleaners, | ||
reverse_code=migrations.RunPython.noop | ||
), | ||
# Remove old fields | ||
migrations.RemoveField( | ||
model_name='table', | ||
name='published_by_old', | ||
), | ||
migrations.RemoveField( | ||
model_name='table', | ||
name='data_cleaned_by_old', | ||
), | ||
] |
Oops, something went wrong.