Search establishment by working time
This commit is contained in:
parent
6d7341377b
commit
ed03f0f40f
|
|
@ -368,6 +368,16 @@ class Establishment(ProjectBaseMixin, URLImageMixin, TranslatedFieldsMixin):
|
||||||
def best_price_carte(self):
|
def best_price_carte(self):
|
||||||
return 200
|
return 200
|
||||||
|
|
||||||
|
@property
|
||||||
|
def works_noon(self):
|
||||||
|
""" Used for indexing working by day """
|
||||||
|
return [ret.weekday for ret in self.schedule.all() if ret.works_at_noon]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def works_afternoon(self):
|
||||||
|
""" Used for indexing working by day """
|
||||||
|
return [ret.weekday for ret in self.schedule.all() if ret.works_at_afternoon]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tags_indexing(self):
|
def tags_indexing(self):
|
||||||
return [{'id': tag.metadata.id,
|
return [{'id': tag.metadata.id,
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,12 @@ class EstablishmentDocument(Document):
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
multi=True)
|
multi=True)
|
||||||
|
works_afternoon = fields.ListField(fields.IntegerField(
|
||||||
|
attr='works_afternoon'
|
||||||
|
))
|
||||||
|
works_noon = fields.ListField(fields.IntegerField(
|
||||||
|
attr='works_noon'
|
||||||
|
))
|
||||||
tags = fields.ObjectField(
|
tags = fields.ObjectField(
|
||||||
properties={
|
properties={
|
||||||
'id': fields.IntegerField(attr='id'),
|
'id': fields.IntegerField(attr='id'),
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,12 @@ class EstablishmentDocumentViewSet(BaseDocumentViewSet):
|
||||||
'establishment_subtypes': {
|
'establishment_subtypes': {
|
||||||
'field': 'establishment_subtypes.id'
|
'field': 'establishment_subtypes.id'
|
||||||
},
|
},
|
||||||
|
'works_noon': {
|
||||||
|
'field': 'works_noon'
|
||||||
|
},
|
||||||
|
'works_afternoon': {
|
||||||
|
'field': 'works_afternoon'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
geo_spatial_filter_fields = {
|
geo_spatial_filter_fields = {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from datetime import time
|
||||||
|
|
||||||
from utils.models import ProjectBaseMixin
|
from utils.models import ProjectBaseMixin
|
||||||
|
|
||||||
|
|
@ -14,6 +15,8 @@ class Timetable(ProjectBaseMixin):
|
||||||
SATURDAY = 5
|
SATURDAY = 5
|
||||||
SUNDAY = 6
|
SUNDAY = 6
|
||||||
|
|
||||||
|
NOON = time(17, 0)
|
||||||
|
|
||||||
WEEKDAYS_CHOICES = (
|
WEEKDAYS_CHOICES = (
|
||||||
(MONDAY, _('Monday')),
|
(MONDAY, _('Monday')),
|
||||||
(TUESDAY, _('Tuesday')),
|
(TUESDAY, _('Tuesday')),
|
||||||
|
|
@ -32,6 +35,14 @@ class Timetable(ProjectBaseMixin):
|
||||||
opening_at = models.TimeField(verbose_name=_('Opening time'), null=True)
|
opening_at = models.TimeField(verbose_name=_('Opening time'), null=True)
|
||||||
closed_at = models.TimeField(verbose_name=_('Closed time'), null=True)
|
closed_at = models.TimeField(verbose_name=_('Closed time'), null=True)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def works_at_noon(self):
|
||||||
|
return bool(self.closed_at and self.closed_at <= self.NOON)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def works_at_afternoon(self):
|
||||||
|
return bool(self.closed_at and self.closed_at > self.NOON)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"""Meta class."""
|
"""Meta class."""
|
||||||
verbose_name = _('Timetable')
|
verbose_name = _('Timetable')
|
||||||
|
|
|
||||||
|
|
@ -88,4 +88,5 @@ class TimetableSerializer(serializers.ModelSerializer):
|
||||||
fields = (
|
fields = (
|
||||||
'id',
|
'id',
|
||||||
'weekday_display',
|
'weekday_display',
|
||||||
|
'works_at_noon',
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user