]> git.parisson.com Git - teleforma.git/commitdiff
Add script to import markers : https://trackers.pilotsystems.net/prebarreau/0463
authorYoan Le Clanche <yoanl@pilotsystems.net>
Wed, 15 Jun 2022 15:31:25 +0000 (17:31 +0200)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Wed, 15 Jun 2022 15:31:25 +0000 (17:31 +0200)
teleforma/management/commands/teleforma-import-markers.py [new file with mode: 0644]

diff --git a/teleforma/management/commands/teleforma-import-markers.py b/teleforma/management/commands/teleforma-import-markers.py
new file mode 100644 (file)
index 0000000..6529c60
--- /dev/null
@@ -0,0 +1,28 @@
+from django.core.management.base import BaseCommand
+
+
+
+from teleforma.models.core import MediaItemMarker
+import json
+
+class Command(BaseCommand):
+    help = "Send orders to avis-verifies ftp"
+
+    
+    def handle(self, *args, **options):
+        data = []
+
+        with open('/srv/src/teleforma/teleforma/export-mediamarkers.json', 'r') as file:
+            data = file.read()
+        
+        data = json.loads(data)
+        for row in data:
+            if not row['public_id']:
+                raise "no public id"
+            try:
+                marker = MediaItemMarker.objects.get(public_id=row['public_id'], item_id=row['item_id'])
+            except MediaItemMarker.DoesNotExist:
+                continue
+            marker.time = row['time']
+            marker.save()
+            
\ No newline at end of file