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."""
|
||||
is_publish = models.BooleanField(
|
||||
default=False, verbose_name=_('Publish status'))
|
||||
on_top = models.BooleanField(
|
||||
default=False, verbose_name=_('Position on top'))
|
||||
filters = JSONField(
|
||||
_('filters'), null=True, blank=True,
|
||||
default=None, help_text='{"key":"value"}')
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ class CollectionSerializer(serializers.ModelSerializer):
|
|||
'id',
|
||||
'name',
|
||||
'block_size',
|
||||
'image'
|
||||
'image',
|
||||
'on_top'
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ class CollectionListView(CollectionViewMixin, generics.ListAPIView):
|
|||
def get_queryset(self):
|
||||
"""Override get_queryset method"""
|
||||
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):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user