fix product type
This commit is contained in:
parent
c433c18c60
commit
ec96c32453
|
|
@ -27,8 +27,10 @@ class Command(BaseCommand):
|
|||
name = currency_dict['name']
|
||||
if name:
|
||||
slug = slugify(name)
|
||||
code = currency_dict['code']
|
||||
currency, _ = Currency.objects.get_or_create(
|
||||
slug=slug,
|
||||
code=code
|
||||
)
|
||||
currency.name = {"en-GB": name}
|
||||
currency.sign = currency_dict["symbol"]
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ class Command(BaseCommand):
|
|||
# Make Tag
|
||||
new_tag, created = Tag.objects.get_or_create(category=tag_cat, value=old_tag.value)
|
||||
if created:
|
||||
new_tag.label = {'en-GB': new_tag.value}
|
||||
text_value = ' '.join(new_tag.value.split('_'))
|
||||
new_tag.label = {'en-GB': text_value}
|
||||
new_tag.save()
|
||||
for id in old_id_list:
|
||||
if isinstance(id, int):
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class GroupConcat(Aggregate):
|
|||
|
||||
def transfer_news():
|
||||
news_type, _ = NewsType.objects.get_or_create(name='News')
|
||||
tag_cat, _ = TagCategory.objects.get_or_create(index_name='tag', public=True)
|
||||
tag_cat, _ = TagCategory.objects.get_or_create(index_name='tag')
|
||||
news_type.tag_categories.add(tag_cat)
|
||||
news_type.save()
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,10 @@ class Command(BaseCommand):
|
|||
create_counter = 0
|
||||
for product_type in product_types:
|
||||
subtype, created = ProductType.objects.get_or_create(**{
|
||||
'name': {settings.FALLBACK_LOCALE: product_type},
|
||||
'index_name': product_type
|
||||
})
|
||||
if created:
|
||||
subtype.name = {settings.FALLBACK_LOCALE: product_type}
|
||||
subtype.save()
|
||||
created += 1
|
||||
self.stdout.write(self.style.WARNING(f'Created: {create_counter}'))
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
from search_indexes.signals import update_document
|
||||
# from search_indexes.signals import update_document
|
||||
|
|
|
|||
|
|
@ -1,77 +1,77 @@
|
|||
"""Search indexes app signals."""
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from django_elasticsearch_dsl.registries import registry
|
||||
|
||||
|
||||
@receiver(post_save)
|
||||
def update_document(sender, **kwargs):
|
||||
from establishment.models import Establishment
|
||||
app_label = sender._meta.app_label
|
||||
model_name = sender._meta.model_name
|
||||
instance = kwargs['instance']
|
||||
|
||||
if app_label == 'location':
|
||||
if model_name == 'country':
|
||||
establishments = Establishment.objects.filter(
|
||||
address__city__country=instance)
|
||||
for establishment in establishments:
|
||||
registry.update(establishment)
|
||||
if model_name == 'city':
|
||||
establishments = Establishment.objects.filter(
|
||||
address__city=instance)
|
||||
for establishment in establishments:
|
||||
registry.update(establishment)
|
||||
if model_name == 'address':
|
||||
establishments = Establishment.objects.filter(
|
||||
address=instance)
|
||||
for establishment in establishments:
|
||||
registry.update(establishment)
|
||||
|
||||
if app_label == 'establishment':
|
||||
# todo: remove after migration
|
||||
from establishment import models as establishment_models
|
||||
if model_name == 'establishmenttype':
|
||||
if isinstance(instance, establishment_models.EstablishmentType):
|
||||
establishments = Establishment.objects.filter(
|
||||
establishment_type=instance)
|
||||
for establishment in establishments:
|
||||
registry.update(establishment)
|
||||
if model_name == 'establishmentsubtype':
|
||||
if isinstance(instance, establishment_models.EstablishmentSubType):
|
||||
establishments = Establishment.objects.filter(
|
||||
establishment_subtypes=instance)
|
||||
for establishment in establishments:
|
||||
registry.update(establishment)
|
||||
|
||||
if app_label == 'tag':
|
||||
if model_name == 'tag':
|
||||
establishments = Establishment.objects.filter(tags=instance)
|
||||
for establishment in establishments:
|
||||
registry.update(establishment)
|
||||
|
||||
|
||||
@receiver(post_save)
|
||||
def update_news(sender, **kwargs):
|
||||
from news.models import News
|
||||
app_label = sender._meta.app_label
|
||||
model_name = sender._meta.model_name
|
||||
instance = kwargs['instance']
|
||||
|
||||
if app_label == 'location':
|
||||
if model_name == 'country':
|
||||
qs = News.objects.filter(country=instance)
|
||||
for news in qs:
|
||||
registry.update(news)
|
||||
|
||||
if app_label == 'news':
|
||||
if model_name == 'newstype':
|
||||
qs = News.objects.filter(news_type=instance)
|
||||
for news in qs:
|
||||
registry.update(news)
|
||||
|
||||
if app_label == 'tag':
|
||||
if model_name == 'tag':
|
||||
qs = News.objects.filter(tags=instance)
|
||||
for news in qs:
|
||||
registry.update(news)
|
||||
# """Search indexes app signals."""
|
||||
# from django.db.models.signals import post_save
|
||||
# from django.dispatch import receiver
|
||||
# from django_elasticsearch_dsl.registries import registry
|
||||
#
|
||||
#
|
||||
# @receiver(post_save)
|
||||
# def update_document(sender, **kwargs):
|
||||
# from establishment.models import Establishment
|
||||
# app_label = sender._meta.app_label
|
||||
# model_name = sender._meta.model_name
|
||||
# instance = kwargs['instance']
|
||||
#
|
||||
# if app_label == 'location':
|
||||
# if model_name == 'country':
|
||||
# establishments = Establishment.objects.filter(
|
||||
# address__city__country=instance)
|
||||
# for establishment in establishments:
|
||||
# registry.update(establishment)
|
||||
# if model_name == 'city':
|
||||
# establishments = Establishment.objects.filter(
|
||||
# address__city=instance)
|
||||
# for establishment in establishments:
|
||||
# registry.update(establishment)
|
||||
# if model_name == 'address':
|
||||
# establishments = Establishment.objects.filter(
|
||||
# address=instance)
|
||||
# for establishment in establishments:
|
||||
# registry.update(establishment)
|
||||
#
|
||||
# if app_label == 'establishment':
|
||||
# # todo: remove after migration
|
||||
# from establishment import models as establishment_models
|
||||
# if model_name == 'establishmenttype':
|
||||
# if isinstance(instance, establishment_models.EstablishmentType):
|
||||
# establishments = Establishment.objects.filter(
|
||||
# establishment_type=instance)
|
||||
# for establishment in establishments:
|
||||
# registry.update(establishment)
|
||||
# if model_name == 'establishmentsubtype':
|
||||
# if isinstance(instance, establishment_models.EstablishmentSubType):
|
||||
# establishments = Establishment.objects.filter(
|
||||
# establishment_subtypes=instance)
|
||||
# for establishment in establishments:
|
||||
# registry.update(establishment)
|
||||
#
|
||||
# if app_label == 'tag':
|
||||
# if model_name == 'tag':
|
||||
# establishments = Establishment.objects.filter(tags=instance)
|
||||
# for establishment in establishments:
|
||||
# registry.update(establishment)
|
||||
#
|
||||
#
|
||||
# @receiver(post_save)
|
||||
# def update_news(sender, **kwargs):
|
||||
# from news.models import News
|
||||
# app_label = sender._meta.app_label
|
||||
# model_name = sender._meta.model_name
|
||||
# instance = kwargs['instance']
|
||||
#
|
||||
# if app_label == 'location':
|
||||
# if model_name == 'country':
|
||||
# qs = News.objects.filter(country=instance)
|
||||
# for news in qs:
|
||||
# registry.update(news)
|
||||
#
|
||||
# if app_label == 'news':
|
||||
# if model_name == 'newstype':
|
||||
# qs = News.objects.filter(news_type=instance)
|
||||
# for news in qs:
|
||||
# registry.update(news)
|
||||
#
|
||||
# if app_label == 'tag':
|
||||
# if model_name == 'tag':
|
||||
# qs = News.objects.filter(tags=instance)
|
||||
# for news in qs:
|
||||
# registry.update(news)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user