Award migrate add tqdm

This commit is contained in:
Виктор Гладких 2019-11-14 10:53:19 +03:00
parent 92ee7537a3
commit 78064481db
2 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,7 @@ from django.db import connections
from establishment.management.commands.add_position import namedtuplefetchall
from main.models import Award, AwardType
from establishment.models import Employee
from tqdm import tqdm
class Command(BaseCommand):
@ -25,7 +26,7 @@ class Command(BaseCommand):
def handle(self, *args, **kwargs):
objects =[]
for a in self.award_sql():
for a in tqdm(self.award_sql(), desc='Add award to profile'):
profile = Employee.objects.filter(old_id=a.profile_id).first()
type = AwardType.objects.filter(old_id=a.award_type).first()
state = Award.PUBLISHED if a.state == 'published' else Award.WAITING

View File

@ -3,7 +3,7 @@ from django.db import connections
from establishment.management.commands.add_position import namedtuplefetchall
from main.models import AwardType
from location.models import Country
from tqdm import tqdm
class Command(BaseCommand):
help = '''Add award types from old db to new db.
@ -24,7 +24,7 @@ class Command(BaseCommand):
def handle(self, *args, **kwargs):
objects =[]
for a in self.award_types_sql():
for a in tqdm(self.award_types_sql(), desc='Add award types: '):
country = Country.objects.filter(code=a.country_code).first()
if country:
type = AwardType(name=a.name, old_id=a.id)