-
Notifications
You must be signed in to change notification settings - Fork 0
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 #2019 from laws-africa/metadata
Move metadata field to coredocument model
- Loading branch information
Showing
7 changed files
with
755 additions
and
685 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
1,352 changes: 676 additions & 676 deletions
1,352
peachjam/fixtures/documents/sample_documents.json
Large diffs are not rendered by default.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
peachjam/migrations/0156_rename_metadata_json_legislation_old_metadata_json_and_more.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,28 @@ | ||
# Generated by Django 4.2.15 on 2024-09-11 09:19 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("peachjam", "0155_entityprofile_title"), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name="legislation", | ||
old_name="metadata_json", | ||
new_name="old_metadata_json", | ||
), | ||
migrations.AddField( | ||
model_name="coredocument", | ||
name="metadata_json", | ||
field=models.JSONField(blank=True, null=True, verbose_name="metadata JSON"), | ||
), | ||
migrations.AddField( | ||
model_name="legislation", | ||
name="principal", | ||
field=models.BooleanField(default=False, verbose_name="principal"), | ||
), | ||
] |
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.15 on 2024-09-11 09:20 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def backfill_metadata_json(apps, schema_editor): | ||
Legislation = apps.get_model("peachjam", "Legislation") | ||
|
||
for leg in Legislation.objects.iterator(100): | ||
leg.metadata_json = leg.old_metadata_json | ||
leg.principal = leg.old_metadata_json["principal"] | ||
leg.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
( | ||
"peachjam", | ||
"0156_rename_metadata_json_legislation_old_metadata_json_and_more", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(backfill_metadata_json, migrations.RunPython.noop) | ||
] |
18 changes: 18 additions & 0 deletions
18
peachjam/migrations/0158_alter_legislation_old_metadata_json.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.15 on 2024-09-11 10:14 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("peachjam", "0157_backfill_metadata_json"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="legislation", | ||
name="old_metadata_json", | ||
field=models.JSONField(blank=True, null=True, verbose_name="metadata JSON"), | ||
), | ||
] |
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