-
Notifications
You must be signed in to change notification settings - Fork 31
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 #2309 from WikiWatershed/jcw/fix-gis-data-serializ…
…ation-2 Fix gis_data serialization
- Loading branch information
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/mmw/apps/modeling/migrations/0023_fix_gis_data_serialization.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 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
import ast | ||
import json | ||
|
||
from django.db import migrations | ||
|
||
|
||
def fix_gis_data_serialization(apps, schema_editor): | ||
Project = apps.get_model('modeling', 'Project') | ||
for project in Project.objects.filter(gis_data__startswith='{u'): | ||
project.gis_data = json.dumps(ast.literal_eval(project.gis_data)) | ||
project.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('modeling', '0022_project_wkaoi'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(fix_gis_data_serialization, | ||
migrations.RunPython.noop) | ||
] |
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