Merge branch 'feature/establishment_fields' into 'develop'
added new fields See merge request gm/gm-backend!259
This commit is contained in:
commit
d5b5149fb0
18
apps/establishment/migrations/0093_auto_20200204_1120.py
Executable file
18
apps/establishment/migrations/0093_auto_20200204_1120.py
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.7 on 2020-02-04 11:20
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('establishment', '0092_merge_20200131_0835'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='establishment',
|
||||
name='status',
|
||||
field=models.PositiveSmallIntegerField(choices=[(0, 'Abandoned'), (1, 'Closed'), (2, 'Published'), (3, 'Unpicked'), (4, 'Waiting'), (5, 'Hidden'), (6, 'Deleted'), (7, 'Out of selection'), (8, 'Unpublished')], default=4, verbose_name='Status'),
|
||||
),
|
||||
]
|
||||
|
|
@ -135,6 +135,10 @@ class EstablishmentQuerySet(models.QuerySet):
|
|||
"""Return qs with related schedule."""
|
||||
return self.prefetch_related('schedule')
|
||||
|
||||
def with_reviews(self):
|
||||
"""Return qs with related reviews."""
|
||||
return self.prefetch_related('reviews')
|
||||
|
||||
def with_currency_related(self):
|
||||
"""Return qs with related """
|
||||
return self.prefetch_related('currency')
|
||||
|
|
@ -554,6 +558,10 @@ class Establishment(GalleryMixin, ProjectBaseMixin, URLImageMixin,
|
|||
PUBLISHED = 2
|
||||
UNPICKED = 3
|
||||
WAITING = 4
|
||||
HIDDEN = 5
|
||||
DELETED = 6
|
||||
OUT_OF_SELECTION = 7
|
||||
UNPUBLISHED = 8
|
||||
|
||||
STATUS_CHOICES = (
|
||||
(ABANDONED, _('Abandoned')),
|
||||
|
|
@ -561,6 +569,10 @@ class Establishment(GalleryMixin, ProjectBaseMixin, URLImageMixin,
|
|||
(PUBLISHED, _('Published')),
|
||||
(UNPICKED, _('Unpicked')),
|
||||
(WAITING, _('Waiting')),
|
||||
(HIDDEN, _('Hidden')),
|
||||
(DELETED, _('Deleted')),
|
||||
(OUT_OF_SELECTION, _('Out of selection')),
|
||||
(UNPUBLISHED, _('Unpublished')),
|
||||
)
|
||||
|
||||
old_id = models.PositiveIntegerField(_('old id'), blank=True, null=True, default=None)
|
||||
|
|
@ -853,6 +865,10 @@ class Establishment(GalleryMixin, ProjectBaseMixin, URLImageMixin,
|
|||
def distillery_type_indexing(self):
|
||||
return self.tags.filter(category__index_name='distillery_type')
|
||||
|
||||
@property
|
||||
def food_producer_indexing(self):
|
||||
return self.tags.filter(category__index_name='producer_type')
|
||||
|
||||
@property
|
||||
def last_comment(self):
|
||||
if hasattr(self, 'comments_prefetched') and len(self.comments_prefetched):
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from location.serializers import (
|
|||
EstablishmentWineRegionBaseSerializer,
|
||||
)
|
||||
from main.serializers import AwardSerializer, CurrencySerializer
|
||||
from review.serializers import ReviewShortSerializer
|
||||
from review.serializers import ReviewShortSerializer, ReviewBaseSerializer
|
||||
from tag.serializers import TagBaseSerializer
|
||||
from timetable.serialziers import ScheduleRUDSerializer
|
||||
from utils import exceptions as utils_exceptions
|
||||
|
|
@ -408,6 +408,8 @@ class EstablishmentListRetrieveSerializer(EstablishmentBaseSerializer):
|
|||
restaurant_cuisine = TagBaseSerializer(read_only=True, many=True, allow_null=True)
|
||||
artisan_category = TagBaseSerializer(read_only=True, many=True, allow_null=True)
|
||||
distillery_type = TagBaseSerializer(read_only=True, many=True, allow_null=True)
|
||||
food_producer = TagBaseSerializer(read_only=True, many=True, allow_null=True)
|
||||
reviews = ReviewBaseSerializer(read_only=True, many=True)
|
||||
|
||||
class Meta(EstablishmentBaseSerializer.Meta):
|
||||
"""Meta class."""
|
||||
|
|
@ -418,6 +420,11 @@ class EstablishmentListRetrieveSerializer(EstablishmentBaseSerializer):
|
|||
'restaurant_cuisine',
|
||||
'artisan_category',
|
||||
'distillery_type',
|
||||
'food_producer',
|
||||
'vintage_year',
|
||||
'reviews',
|
||||
'contact_phones',
|
||||
'public_mark'
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,12 +33,13 @@ class EstablishmentListView(EstablishmentMixinView, generics.ListAPIView):
|
|||
serializer_class = serializers.EstablishmentListRetrieveSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().with_schedule() \
|
||||
return super().get_queryset().with_schedule().with_reviews() \
|
||||
.with_extended_address_related().with_currency_related() \
|
||||
.with_certain_tag_category_related('category', 'restaurant_category') \
|
||||
.with_certain_tag_category_related('cuisine', 'restaurant_cuisine') \
|
||||
.with_certain_tag_category_related('shop_category', 'artisan_category') \
|
||||
.with_certain_tag_category_related('distillery_type', 'distillery_type')
|
||||
.with_certain_tag_category_related('distillery_type', 'distillery_type') \
|
||||
.with_certain_tag_category_related('food_producer', 'producer_type')
|
||||
|
||||
|
||||
class EstablishmentSimilarView(EstablishmentListView):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user