|
|
@@ -12,6 +12,7 @@ django.setup()
|
|
|
from django.conf import settings
|
|
|
from smartfarming.models.device import MongoDeviceType
|
|
|
from smartfarming.models.user import UserPurview
|
|
|
+from smartfarming.models.pests_bank import MongoPestBank
|
|
|
|
|
|
|
|
|
|
|
|
@@ -23,14 +24,24 @@ with open(os.path.join(local_path, "scripts/test/sa_device_type.json") , 'r', en
|
|
|
id=row.get("id"),
|
|
|
defaults=row
|
|
|
)
|
|
|
- print(device_type, is_created)
|
|
|
+ print(device_type.id, 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(
|
|
|
+ sa_user_purview, is_created = UserPurview.objects.get_or_create(
|
|
|
id=row.get("id"),
|
|
|
defaults=row
|
|
|
)
|
|
|
- print(sa_user_purview, is_created)
|
|
|
+ print(sa_user_purview.id, is_created)
|
|
|
+
|
|
|
+
|
|
|
+with open(os.path.join(local_path, "scripts/test/sa_pest_bank.json") , 'r', encoding='utf-8') as f:
|
|
|
+ sa_pest_bank = json.load(f)
|
|
|
+ for row in sa_pest_bank.get("rows"):
|
|
|
+ sa_pest_bank, is_created = UserPurview.objects.get_or_create(
|
|
|
+ id=row.get("id"),
|
|
|
+ defaults=row
|
|
|
+ )
|
|
|
+ print(sa_pest_bank.id, is_created)
|