add home_page

This commit is contained in:
Dmitriy Kuzmenko 2019-12-06 18:17:16 +03:00
parent 29d05929ff
commit 831cb4bc81
6 changed files with 45 additions and 3 deletions

View File

@ -1,3 +1,3 @@
FROM mdillon/postgis:latest
FROM mdillon/postgis:10
RUN localedef -i ru_RU -c -f UTF-8 -A /usr/share/locale/locale.alias ru_RU.UTF-8
ENV LANG ru_RU.utf8

View File

@ -0,0 +1,37 @@
from django.core.management.base import BaseCommand
from tqdm import tqdm
from establishment.models import Establishment
from main.models import Carousel
from transfer.models import HomePages
from location.models import Country
from django.db.models import F
class Command(BaseCommand):
help = '''Add establishment form HomePage to Carousel!'''
@staticmethod
def get_country(country_code):
return Country.objects.filter(code__iexact=country_code).first()
def handle(self, *args, **kwargs):
objects = []
deleted = 0
hp_list = HomePages.objects.annotate(
country=F('site__country_code_2'),
).all()
for hm in tqdm(hp_list, desc='Add home_page.establishments to carousel'):
est = Establishment.objects.filter(old_id=hm.selection_of_week).first()
if est:
if est.carousels.exists():
est.carousels.all().delete()
deleted += 1
carousel = Carousel(
content_object=est,
country=self.get_country(hm.country)
)
objects.append(carousel)
Carousel.objects.bulk_create(objects)
self.stdout.write(
self.style.WARNING(f'Created {len(objects)}/Deleted {deleted} carousel objects.'))

View File

@ -1000,7 +1000,7 @@ class ProductNotes(MigrateMixin):
db_table = 'product_notes'
class HomePages(models.Model):
class HomePages(MigrateMixin):
using = 'legacy'
site = models.ForeignKey(Sites, models.DO_NOTHING, blank=True, null=True)

View File

@ -2,6 +2,8 @@
./manage.py transfer -a
./manage.py transfer -d
./manage.py transfer -e
./manage.py transfer -n
./manage.py rm_empty_images # команда для удаления картинок с относительным урлом из news.description
./manage.py upd_transportation
./manage.py transfer --fill_city_gallery
./manage.py transfer -l

View File

@ -524,3 +524,6 @@ INTERNATIONAL_COUNTRY_CODES = ['www', 'main', 'next']
THUMBNAIL_ENGINE = 'utils.thumbnail_engine.GMEngine'
COOKIE_DOMAIN = None
ELASTICSEARCH_DSL = {}
ELASTICSEARCH_INDEX_NAMES = {}

View File

@ -42,7 +42,7 @@ DATABASES = {
'HOST': os.environ.get('DB_HOSTNAME'),
'PORT': os.environ.get('DB_PORT'),
'OPTIONS': {
'options': '-c search_path=gm'
'options': '-c search_path=gm,public'
},
},
'legacy': {