Award migrate add tqdm
This commit is contained in:
parent
92ee7537a3
commit
78064481db
|
|
@ -3,6 +3,7 @@ from django.db import connections
|
||||||
from establishment.management.commands.add_position import namedtuplefetchall
|
from establishment.management.commands.add_position import namedtuplefetchall
|
||||||
from main.models import Award, AwardType
|
from main.models import Award, AwardType
|
||||||
from establishment.models import Employee
|
from establishment.models import Employee
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
|
@ -25,7 +26,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def handle(self, *args, **kwargs):
|
def handle(self, *args, **kwargs):
|
||||||
objects =[]
|
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()
|
profile = Employee.objects.filter(old_id=a.profile_id).first()
|
||||||
type = AwardType.objects.filter(old_id=a.award_type).first()
|
type = AwardType.objects.filter(old_id=a.award_type).first()
|
||||||
state = Award.PUBLISHED if a.state == 'published' else Award.WAITING
|
state = Award.PUBLISHED if a.state == 'published' else Award.WAITING
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ from django.db import connections
|
||||||
from establishment.management.commands.add_position import namedtuplefetchall
|
from establishment.management.commands.add_position import namedtuplefetchall
|
||||||
from main.models import AwardType
|
from main.models import AwardType
|
||||||
from location.models import Country
|
from location.models import Country
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = '''Add award types from old db to new db.
|
help = '''Add award types from old db to new db.
|
||||||
|
|
@ -24,7 +24,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def handle(self, *args, **kwargs):
|
def handle(self, *args, **kwargs):
|
||||||
objects =[]
|
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()
|
country = Country.objects.filter(code=a.country_code).first()
|
||||||
if country:
|
if country:
|
||||||
type = AwardType(name=a.name, old_id=a.id)
|
type = AwardType(name=a.name, old_id=a.id)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user