add home_page
This commit is contained in:
parent
29d05929ff
commit
831cb4bc81
|
|
@ -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
|
RUN localedef -i ru_RU -c -f UTF-8 -A /usr/share/locale/locale.alias ru_RU.UTF-8
|
||||||
ENV LANG ru_RU.utf8
|
ENV LANG ru_RU.utf8
|
||||||
|
|
|
||||||
37
apps/main/management/commands/add_home_page_carousel.py
Normal file
37
apps/main/management/commands/add_home_page_carousel.py
Normal 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.'))
|
||||||
|
|
@ -1000,7 +1000,7 @@ class ProductNotes(MigrateMixin):
|
||||||
db_table = 'product_notes'
|
db_table = 'product_notes'
|
||||||
|
|
||||||
|
|
||||||
class HomePages(models.Model):
|
class HomePages(MigrateMixin):
|
||||||
using = 'legacy'
|
using = 'legacy'
|
||||||
|
|
||||||
site = models.ForeignKey(Sites, models.DO_NOTHING, blank=True, null=True)
|
site = models.ForeignKey(Sites, models.DO_NOTHING, blank=True, null=True)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
./manage.py transfer -a
|
./manage.py transfer -a
|
||||||
./manage.py transfer -d
|
./manage.py transfer -d
|
||||||
./manage.py transfer -e
|
./manage.py transfer -e
|
||||||
|
./manage.py transfer -n
|
||||||
|
./manage.py rm_empty_images # команда для удаления картинок с относительным урлом из news.description
|
||||||
./manage.py upd_transportation
|
./manage.py upd_transportation
|
||||||
./manage.py transfer --fill_city_gallery
|
./manage.py transfer --fill_city_gallery
|
||||||
./manage.py transfer -l
|
./manage.py transfer -l
|
||||||
|
|
|
||||||
|
|
@ -524,3 +524,6 @@ INTERNATIONAL_COUNTRY_CODES = ['www', 'main', 'next']
|
||||||
THUMBNAIL_ENGINE = 'utils.thumbnail_engine.GMEngine'
|
THUMBNAIL_ENGINE = 'utils.thumbnail_engine.GMEngine'
|
||||||
|
|
||||||
COOKIE_DOMAIN = None
|
COOKIE_DOMAIN = None
|
||||||
|
|
||||||
|
ELASTICSEARCH_DSL = {}
|
||||||
|
ELASTICSEARCH_INDEX_NAMES = {}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ DATABASES = {
|
||||||
'HOST': os.environ.get('DB_HOSTNAME'),
|
'HOST': os.environ.get('DB_HOSTNAME'),
|
||||||
'PORT': os.environ.get('DB_PORT'),
|
'PORT': os.environ.get('DB_PORT'),
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'options': '-c search_path=gm'
|
'options': '-c search_path=gm,public'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'legacy': {
|
'legacy': {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user