Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
Load countries for each language
Browse files Browse the repository at this point in the history
  • Loading branch information
paltman committed Dec 11, 2015
1 parent feb46ec commit 64e1f6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion td/resources/receivers.py
Expand Up @@ -23,7 +23,7 @@ def handle_entity_save(sender, instance, *args, **kwargs):
if sender in ENTITIES:
if getattr(instance, "source", None) is not None:
for attribute in instance.tracker.changed().keys():
instance.attributes.create(
instance.attributes.get_or_create(
attribute=attribute,
value=getattr(instance, attribute) or "",
source_ct=ContentType.objects.get_for_model(instance.source),
Expand Down
10 changes: 10 additions & 0 deletions td/tasks.py
Expand Up @@ -123,3 +123,13 @@ def integrate_imb_language_data():
resource.published_flag = True
resource.save()
resource.medias.add(media)
for imb in IMBPeopleGroup.objects.order_by("language"):
language = next(iter(Language.objects.filter(iso_639_3=imb.rol)), None)
if not language:
language = next(iter(Language.objects.filter(code=imb.rol)), None)
if language:
country = next(iter(Country.objects.filter(name=imb.country)), None)
if country is not None:
language.country = country
language.source = imb
language.save()

0 comments on commit 64e1f6a

Please sign in to comment.