fix currency
This commit is contained in:
parent
c50cd7c693
commit
924b4e68e9
|
|
@ -3,6 +3,7 @@ import requests
|
||||||
from establishment.models import Establishment
|
from establishment.models import Establishment
|
||||||
from main.models import Currency
|
from main.models import Currency
|
||||||
from location.models import Country
|
from location.models import Country
|
||||||
|
from django.template.defaultfilters import slugify
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
|
@ -23,15 +24,15 @@ class Command(BaseCommand):
|
||||||
if isinstance(country_list, list):
|
if isinstance(country_list, list):
|
||||||
currency_dict = country_list[0].get("currencies")[0]
|
currency_dict = country_list[0].get("currencies")[0]
|
||||||
if currency_dict:
|
if currency_dict:
|
||||||
name = currency_dict.get("name")
|
name = currency_dict['name']
|
||||||
if name:
|
if name:
|
||||||
currency, created = Currency.objects.get_or_create(
|
slug = slugify(name)
|
||||||
slug=currency_dict.get("name").lower(),
|
currency, _ = Currency.objects.get_or_create(
|
||||||
|
slug=slug,
|
||||||
)
|
)
|
||||||
if created:
|
currency.name = {"en-GB": name},
|
||||||
currency.name = {"en-GB": name},
|
currency.sign = currency_dict["symbol"],
|
||||||
currency.sign = currency_dict.get("symbol"),
|
currency.save()
|
||||||
currency.save()
|
|
||||||
establishments = Establishment.objects.filter(address__city__country=country)
|
establishments = Establishment.objects.filter(address__city__country=country)
|
||||||
establishments.update(currency=currency)
|
establishments.update(currency=currency)
|
||||||
count += 1
|
count += 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user