-
Notifications
You must be signed in to change notification settings - Fork 143
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 #9704 from archesproject/9648_prevent_prov_edit_er…
…rors Fixes errors when creating provisional edits
- Loading branch information
Showing
6 changed files
with
282 additions
and
167 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
29 changes: 29 additions & 0 deletions
29
arches/app/models/migrations/9648_add_empty_key_value_pairs_to_tiles.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 @@ | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("models", "9477_fix_for_spatial_view_dbf_function_edtf_displaying_null"), | ||
] | ||
|
||
def forwards_func(apps, schema_editor): | ||
TileModel = apps.get_model("models", "TileModel") | ||
Node = apps.get_model("models", "Node") | ||
|
||
for tile in TileModel.objects.filter(data={}, provisionaledits__isnull=False): | ||
for node in Node.objects.filter(nodegroup_id=tile.nodegroup_id): | ||
if not str(node.pk) in tile.data: | ||
tile.data[str(node.pk)] = None | ||
tile.save() | ||
|
||
def reverse_func(apps, schema_editor): | ||
TileModel = apps.get_model("models", "TileModel") | ||
|
||
for tile in TileModel.objects.filter(provisionaledits__isnull=False): | ||
if bool(tile.provisionaledits and not any(tile.data.values())): | ||
tile.data = {} | ||
tile.save() | ||
|
||
operations = [ | ||
migrations.RunPython(forwards_func, reverse_func), | ||
] |
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
Oops, something went wrong.