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):
|
||||
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
|
||||
def tags_indexing(self):
|
||||
return [{'id': tag.metadata.id,
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@ class EstablishmentDocument(Document):
|
|||
}),
|
||||
},
|
||||
multi=True)
|
||||
works_afternoon = fields.ListField(fields.IntegerField(
|
||||
attr='works_afternoon'
|
||||
))
|
||||
works_noon = fields.ListField(fields.IntegerField(
|
||||
attr='works_noon'
|
||||
))
|
||||
tags = fields.ObjectField(
|
||||
properties={
|
||||
'id': fields.IntegerField(attr='id'),
|
||||
|
|
|
|||
|
|
@ -121,6 +121,12 @@ class EstablishmentDocumentViewSet(BaseDocumentViewSet):
|
|||
'establishment_subtypes': {
|
||||
'field': 'establishment_subtypes.id'
|
||||
},
|
||||
'works_noon': {
|
||||
'field': 'works_noon'
|
||||
},
|
||||
'works_afternoon': {
|
||||
'field': 'works_afternoon'
|
||||
},
|
||||
}
|
||||
|
||||
geo_spatial_filter_fields = {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from datetime import time
|
||||
|
||||
from utils.models import ProjectBaseMixin
|
||||
|
||||
|
|
@ -14,6 +15,8 @@ class Timetable(ProjectBaseMixin):
|
|||
SATURDAY = 5
|
||||
SUNDAY = 6
|
||||
|
||||
NOON = time(17, 0)
|
||||
|
||||
WEEKDAYS_CHOICES = (
|
||||
(MONDAY, _('Monday')),
|
||||
(TUESDAY, _('Tuesday')),
|
||||
|
|
@ -32,6 +35,14 @@ class Timetable(ProjectBaseMixin):
|
|||
opening_at = models.TimeField(verbose_name=_('Opening 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:
|
||||
"""Meta class."""
|
||||
verbose_name = _('Timetable')
|
||||
|
|
|
|||
|
|
@ -88,4 +88,5 @@ class TimetableSerializer(serializers.ModelSerializer):
|
|||
fields = (
|
||||
'id',
|
||||
'weekday_display',
|
||||
'works_at_noon',
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user