summaryrefslogtreecommitdiff
path: root/chimere/management/commands/v3_to_v2_routes.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-06-14 11:52:52 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-06-14 11:52:52 +0200
commitd968a48b9d0457bb3e592c4c58d21ce0186c062c (patch)
tree3c745a2ef1d77e270bd8bf8d437da042b8e5cb7f /chimere/management/commands/v3_to_v2_routes.py
parent2431d24b67c8f738ce22b23232114dc9ab697b64 (diff)
downloadChimère-d968a48b9d0457bb3e592c4c58d21ce0186c062c.tar.bz2
Chimère-d968a48b9d0457bb3e592c4c58d21ce0186c062c.zip
v2 to v3 dump: add associated categories
Diffstat (limited to 'chimere/management/commands/v3_to_v2_routes.py')
-rw-r--r--chimere/management/commands/v3_to_v2_routes.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/chimere/management/commands/v3_to_v2_routes.py b/chimere/management/commands/v3_to_v2_routes.py
index d373e25..92e26d5 100644
--- a/chimere/management/commands/v3_to_v2_routes.py
+++ b/chimere/management/commands/v3_to_v2_routes.py
@@ -1,25 +1,20 @@
-from io import StringIO
import json
-from django.core.management import call_command
from django.core.management.base import BaseCommand
+from chimere.management.commands.v3_to_v2_markers import get_data
+
class Command(BaseCommand):
help = "Route dump for v2"
def handle(self, *args, **options):
- out = StringIO()
- call_command('dumpdata', 'chimere.Route', indent=4, stdout=out)
- vals = out.getvalue()
- routes = json.loads(vals)
new_routes = []
- for route in routes:
- data = route.copy()
- data['fields'].pop('weight')
- data['fields'].pop('normalised_weight')
- data['fields'].pop('color')
- new_routes.append(data)
+ new_routes += get_data('Route',
+ filters=('weight', 'normalised_weight',
+ 'color'))
+ new_routes += get_data('Route_categories')
+
res = json.dumps(new_routes)
self.stdout.write(res)