Tz field for establishments

(cherry picked from commit a537f04)
This commit is contained in:
Kuroshini 2019-12-02 18:36:44 +03:00
parent 2c04d08316
commit 3b05a552aa
4 changed files with 9 additions and 1 deletions

View File

@ -541,6 +541,11 @@ class Establishment(GalleryModelMixin, ProjectBaseMixin, URLImageMixin,
time_at_est_tz = now_at_est_tz.time()
return schedule_for_today.ending_time > time_at_est_tz > schedule_for_today.opening_time
@property
def timezone_as_str(self):
""" Returns tz in str format"""
return self.tz.localize(datetime.now()).strftime('%z')
@property
def tags_indexing(self):
return [{'id': tag.metadata.id,

View File

@ -286,7 +286,7 @@ class EstablishmentBaseSerializer(ProjectModelSerializer):
preview_image = serializers.URLField(source='preview_image_url',
allow_null=True,
read_only=True)
tz = serializers.CharField(read_only=True, source='timezone_as_str')
new_image = ImageBaseSerializer(source='crop_main_image', allow_null=True, read_only=True)
class Meta:
@ -311,6 +311,7 @@ class EstablishmentBaseSerializer(ProjectModelSerializer):
'image',
'preview_image',
'new_image',
'tz',
]

View File

@ -124,6 +124,7 @@ class EstablishmentDocument(Document):
},
)
favorites_for_users = fields.ListField(field=fields.IntegerField())
tz = fields.KeywordField(attr='timezone_as_str')
class Django:

View File

@ -251,6 +251,7 @@ class EstablishmentDocumentSerializer(InFavoritesMixin, DocumentSerializer):
'works_noon',
'works_evening',
'works_at_weekday',
'tz',
# 'works_now',
# 'collections',
# 'establishment_type',