Fix award add
This commit is contained in:
parent
8ef31fa560
commit
2a9c7bf28d
|
|
@ -27,13 +27,16 @@ class Command(BaseCommand):
|
||||||
def handle(self, *args, **kwargs):
|
def handle(self, *args, **kwargs):
|
||||||
objects =[]
|
objects =[]
|
||||||
for a in tqdm(self.award_sql(), desc='Add award to profile'):
|
for a in tqdm(self.award_sql(), desc='Add award to profile'):
|
||||||
profile = Employee.objects.filter(old_id=a.profile_id).first()
|
profiles = Employee.objects.filter(old_id=a.profile_id)
|
||||||
type = AwardType.objects.filter(old_id=a.award_type).first()
|
type = AwardType.objects.filter(old_id=a.award_type)
|
||||||
state = Award.PUBLISHED if a.state == 'published' else Award.WAITING
|
state = Award.PUBLISHED if a.state == 'published' else Award.WAITING
|
||||||
if profile and type:
|
if profiles.exists() and type.exists():
|
||||||
award = Award(award_type=type, vintage_year=a.vintage_year,
|
for profile in profiles:
|
||||||
|
print(f'PROFILE {profile}')
|
||||||
|
award = Award(award_type=type.first(), vintage_year=a.vintage_year,
|
||||||
title={"en-GB": a.title}, state=state,
|
title={"en-GB": a.title}, state=state,
|
||||||
content_object=profile, old_id=a.id)
|
content_object=profile, old_id=a.id)
|
||||||
|
|
||||||
objects.append(award)
|
objects.append(award)
|
||||||
awards = Award.objects.bulk_create(objects)
|
awards = Award.objects.bulk_create(objects)
|
||||||
self.stdout.write(self.style.WARNING(f'Created awards objects.'))
|
self.stdout.write(self.style.WARNING(f'Created awards objects.'))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user