wherehouse: change command
This commit is contained in:
@@ -2,6 +2,7 @@ import json
|
||||
from django.core.management import BaseCommand
|
||||
|
||||
from core.apps.wherehouse.models import WhereHouse
|
||||
from core.apps.accounts.models import User
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@@ -15,8 +16,12 @@ class Command(BaseCommand):
|
||||
data = json.load(f)
|
||||
|
||||
for item in data['data']['warehouses']:
|
||||
WhereHouse.objects.get_or_create(
|
||||
wherehouse, create = WhereHouse.objects.update_or_create(
|
||||
name=item['name']
|
||||
)
|
||||
|
||||
full_names = []
|
||||
for user in item['users']:
|
||||
full_names.append(user['full_name'])
|
||||
users = User.objects.filter(full_name__in=full_names)
|
||||
wherehouse.users.set(users)
|
||||
self.stdout.write("Warehouses added")
|
||||
Reference in New Issue
Block a user