yf_yzl 2 years ago
parent
commit
699bd6ceec
1 changed files with 12 additions and 1 deletions
  1. 12 1
      scripts/test/add_org_data.py

+ 12 - 1
scripts/test/add_org_data.py

@@ -19,7 +19,18 @@ from smartfarming.models.user import UserPurview
 with open(os.path.join(local_path, "scripts/test/sa_device_type.json") , 'r', encoding='utf-8') as f:
     sa_device_type = json.load(f)
     for row in sa_device_type.get("rows"):
-        MongoDeviceType.objects.get_or_create(
+        device_type, is_created = MongoDeviceType.objects.get_or_create(
             id=row.get("id"),
             defaults=row
         )
+        print(device_type, is_created)
+
+
+with open(os.path.join(local_path, "scripts/test/sa_user_purview.json") , 'r', encoding='utf-8') as f:
+    sa_user_purview = json.load(f)
+    for row in sa_user_purview.get("rows"):
+        desa_user_purviewvice_type, is_created = UserPurview.objects.get_or_create(
+            id=row.get("id"),
+            defaults=row
+        )
+        print(sa_user_purview, is_created)