disabled inline in est, and change currency creator
This commit is contained in:
parent
398a982c82
commit
1856589427
|
|
@ -57,9 +57,10 @@ class ProductInline(admin.TabularInline):
|
||||||
class EstablishmentAdmin(BaseModelAdminMixin, admin.ModelAdmin):
|
class EstablishmentAdmin(BaseModelAdminMixin, admin.ModelAdmin):
|
||||||
"""Establishment admin."""
|
"""Establishment admin."""
|
||||||
list_display = ['id', '__str__', 'image_tag', ]
|
list_display = ['id', '__str__', 'image_tag', ]
|
||||||
inlines = [
|
|
||||||
AwardInline, ContactPhoneInline, ContactEmailInline,
|
# inlines = [
|
||||||
ReviewInline, CommentInline, ProductInline]
|
# AwardInline, ContactPhoneInline, ContactEmailInline,
|
||||||
|
# ReviewInline, CommentInline, ProductInline]
|
||||||
raw_id_fields = ('address',)
|
raw_id_fields = ('address',)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@ class Command(BaseCommand):
|
||||||
def handle(self, *args, **kwargs):
|
def handle(self, *args, **kwargs):
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
queryset = Establishment.objects.all()
|
queryset = list(Establishment.objects.filter(address__city__country__isnull=False))
|
||||||
url = 'https://restcountries.eu/rest/v2/name/{country}'
|
url = 'https://restcountries.eu/rest/v2/name/{country}'
|
||||||
for est in queryset:
|
|
||||||
if not est.currency and est.address and est.address.city and est.address.city.country:
|
|
||||||
|
|
||||||
|
for est in queryset:
|
||||||
|
if not est.currency:
|
||||||
try:
|
try:
|
||||||
country = est.address.city.country.name_translated
|
country = est.address.city.country.name_translated
|
||||||
resp = requests.get(url=url.format(country=country))
|
resp = requests.get(url=url.format(country=country))
|
||||||
|
|
@ -38,7 +38,7 @@ class Command(BaseCommand):
|
||||||
currency.sign = currency_dict.get("symbol"),
|
currency.sign = currency_dict.get("symbol"),
|
||||||
currency.save()
|
currency.save()
|
||||||
est.currency = currency
|
est.currency = currency
|
||||||
est.save()
|
|
||||||
count += 1
|
count += 1
|
||||||
|
Establishment.objects.bulk_update(queryset, ['currency'])
|
||||||
|
|
||||||
self.stdout.write(self.style.WARNING(f'Created/updated {count} objects.'))
|
self.stdout.write(self.style.WARNING(f'Created/updated {count} objects.'))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user