Skip to content

Commit

Permalink
Merge pull request #33465 from dimagi/gh/domains/countries-bug
Browse files Browse the repository at this point in the history
Update Countries syntax to accurately use API
  • Loading branch information
gherceg authored Sep 13, 2023
2 parents 40ac8ea + efc6094 commit c79ad29
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions corehq/apps/es/domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.size(0))
"""

from django_countries import Countries
from django_countries import countries

from . import filters
from .client import ElasticDocumentAdapter, create_document_adapter
Expand Down Expand Up @@ -78,12 +78,13 @@ def _from_dict(self, domain_dict):

sub = Subscription.visible_objects.filter(subscriber__domain=domain_dict['name'], is_active=True)
domain_dict['deployment'] = domain_dict.get('deployment') or {}
countries = domain_dict['deployment'].get('countries', [])
domain_countries = domain_dict['deployment'].get('countries', [])
domain_dict['deployment']['countries'] = []
if sub:
domain_dict['subscription'] = sub[0].plan_version.plan.edition
for country in countries:
domain_dict['deployment']['countries'].append(Countries[country].upper())
countries_map = dict(countries)
for country in domain_countries:
domain_dict['deployment']['countries'].append(countries_map[country].upper())
return super()._from_dict(domain_dict)


Expand Down

0 comments on commit c79ad29

Please sign in to comment.