added flag on_top to model Collection, refactored CollectionList view
This commit is contained in:
parent
e2767af57d
commit
919c625bbc
18
apps/collection/migrations/0004_collection_on_top.py
Normal file
18
apps/collection/migrations/0004_collection_on_top.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.2.4 on 2019-08-23 13:22
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('collection', '0003_auto_20190823_0935'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='collection',
|
||||||
|
name='on_top',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='Position on top'),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -43,6 +43,8 @@ class Collection(ProjectBaseMixin, CollectionNameMixin,
|
||||||
"""Collection model."""
|
"""Collection model."""
|
||||||
is_publish = models.BooleanField(
|
is_publish = models.BooleanField(
|
||||||
default=False, verbose_name=_('Publish status'))
|
default=False, verbose_name=_('Publish status'))
|
||||||
|
on_top = models.BooleanField(
|
||||||
|
default=False, verbose_name=_('Position on top'))
|
||||||
filters = JSONField(
|
filters = JSONField(
|
||||||
_('filters'), null=True, blank=True,
|
_('filters'), null=True, blank=True,
|
||||||
default=None, help_text='{"key":"value"}')
|
default=None, help_text='{"key":"value"}')
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ class CollectionSerializer(serializers.ModelSerializer):
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
'block_size',
|
'block_size',
|
||||||
'image'
|
'image',
|
||||||
|
'on_top'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ class CollectionListView(CollectionViewMixin, generics.ListAPIView):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
"""Override get_queryset method"""
|
"""Override get_queryset method"""
|
||||||
return models.Collection.objects.published()\
|
return models.Collection.objects.published()\
|
||||||
.by_country_code(code=self.request.country_code)
|
.by_country_code(code=self.request.country_code)\
|
||||||
|
.order_by('-on_top', '-created')
|
||||||
|
|
||||||
|
|
||||||
class CollectionRetrieveView(CollectionViewMixin, generics.RetrieveAPIView):
|
class CollectionRetrieveView(CollectionViewMixin, generics.RetrieveAPIView):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user