fixed carousel
This commit is contained in:
parent
15ef2295ca
commit
8ac5a1970f
|
|
@ -1,6 +1,7 @@
|
||||||
"""Establishment models."""
|
"""Establishment models."""
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
|
import elasticsearch_dsl
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.contenttypes import fields as generic
|
from django.contrib.contenttypes import fields as generic
|
||||||
from django.contrib.gis.db.models.functions import Distance
|
from django.contrib.gis.db.models.functions import Distance
|
||||||
|
|
@ -11,12 +12,11 @@ from django.db import models
|
||||||
from django.db.models import When, Case, F, ExpressionWrapper, Subquery, Q
|
from django.db.models import When, Case, F, ExpressionWrapper, Subquery, Q
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from elasticsearch_dsl import Q
|
|
||||||
from phonenumber_field.modelfields import PhoneNumberField
|
from phonenumber_field.modelfields import PhoneNumberField
|
||||||
|
|
||||||
from collection.models import Collection
|
from collection.models import Collection
|
||||||
from main.models import Award, MetaDataContent
|
|
||||||
from location.models import Address
|
from location.models import Address
|
||||||
|
from main.models import Award, MetaDataContent
|
||||||
from review.models import Review
|
from review.models import Review
|
||||||
from utils.models import (ProjectBaseMixin, TJSONField, URLImageMixin,
|
from utils.models import (ProjectBaseMixin, TJSONField, URLImageMixin,
|
||||||
TranslatedFieldsMixin, BaseAttributes)
|
TranslatedFieldsMixin, BaseAttributes)
|
||||||
|
|
@ -103,8 +103,8 @@ class EstablishmentQuerySet(models.QuerySet):
|
||||||
"""Search text via ElasticSearch."""
|
"""Search text via ElasticSearch."""
|
||||||
from search_indexes.documents import EstablishmentDocument
|
from search_indexes.documents import EstablishmentDocument
|
||||||
search = EstablishmentDocument.search().filter(
|
search = EstablishmentDocument.search().filter(
|
||||||
Q('match', name=value) |
|
elasticsearch_dsl.Q('match', name=value) |
|
||||||
Q('match', **{f'description.{locale}': value})
|
elasticsearch_dsl.Q('match', **{f'description.{locale}': value})
|
||||||
).execute()
|
).execute()
|
||||||
ids = [result.meta.id for result in search]
|
ids = [result.meta.id for result in search]
|
||||||
return self.filter(id__in=ids)
|
return self.filter(id__in=ids)
|
||||||
|
|
@ -375,8 +375,8 @@ class Establishment(ProjectBaseMixin, URLImageMixin, TranslatedFieldsMixin):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def the_most_recent_award(self):
|
def the_most_recent_award(self):
|
||||||
return Award.objects.filter(Q(establishment=self) | Q(employees__establishments=self)).latest(
|
return Award.objects.filter(Q(establishment=self) | Q(employees__establishments=self)) \
|
||||||
field_name='vintage_year')
|
.latest(field_name='vintage_year')
|
||||||
|
|
||||||
|
|
||||||
class Position(BaseAttributes, TranslatedFieldsMixin):
|
class Position(BaseAttributes, TranslatedFieldsMixin):
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,8 @@ class NewsBaseSerializer(ProjectModelSerializer):
|
||||||
'tags',
|
'tags',
|
||||||
'slug',
|
'slug',
|
||||||
'gallery',
|
'gallery',
|
||||||
|
'image_url',
|
||||||
|
'preview_image_url',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user