added fields to model Collection, refactored Collection serializer,
This commit is contained in:
parent
aa37e0a233
commit
e88fea10e7
26
apps/collection/migrations/0003_auto_20190823_0935.py
Normal file
26
apps/collection/migrations/0003_auto_20190823_0935.py
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Generated by Django 2.2.4 on 2019-08-23 09:35
|
||||||
|
|
||||||
|
import django.contrib.postgres.fields.jsonb
|
||||||
|
from django.db import migrations
|
||||||
|
import easy_thumbnails.fields
|
||||||
|
import utils.methods
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('collection', '0002_collection_is_publish'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='collection',
|
||||||
|
name='block_size',
|
||||||
|
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=None, help_text='{"width": "250px", "height":"250px"}', null=True, verbose_name='collection block properties'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='collection',
|
||||||
|
name='image',
|
||||||
|
field=easy_thumbnails.fields.ThumbnailerImageField(blank=True, default=None, null=True, upload_to=utils.methods.image_path, verbose_name='Image'),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
|
from django.contrib.postgres.fields import JSONField
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.contrib.postgres.fields import JSONField
|
|
||||||
from utils.models import ProjectBaseMixin
|
from utils.models import ProjectBaseMixin, ImageMixin
|
||||||
|
|
||||||
|
|
||||||
# Mixins
|
# Mixins
|
||||||
|
|
@ -37,7 +38,8 @@ class CollectionQuerySet(models.QuerySet):
|
||||||
return self.filter(is_publish=True)
|
return self.filter(is_publish=True)
|
||||||
|
|
||||||
|
|
||||||
class Collection(ProjectBaseMixin, CollectionNameMixin, CollectionDateMixin):
|
class Collection(ProjectBaseMixin, CollectionNameMixin,
|
||||||
|
ImageMixin, CollectionDateMixin):
|
||||||
"""Collection model."""
|
"""Collection model."""
|
||||||
is_publish = models.BooleanField(
|
is_publish = models.BooleanField(
|
||||||
default=False, verbose_name=_('Publish status'))
|
default=False, verbose_name=_('Publish status'))
|
||||||
|
|
@ -52,6 +54,9 @@ class Collection(ProjectBaseMixin, CollectionNameMixin, CollectionDateMixin):
|
||||||
default=None, help_text='{"key":"value"}')
|
default=None, help_text='{"key":"value"}')
|
||||||
country = models.ForeignKey(
|
country = models.ForeignKey(
|
||||||
'location.Country', verbose_name=_('country'), on_delete=models.CASCADE)
|
'location.Country', verbose_name=_('country'), on_delete=models.CASCADE)
|
||||||
|
block_size = JSONField(
|
||||||
|
_('collection block properties'), null=True, blank=True,
|
||||||
|
default=None, help_text='{"width": "250px", "height":"250px"}')
|
||||||
|
|
||||||
objects = CollectionQuerySet.as_manager()
|
objects = CollectionQuerySet.as_manager()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,10 @@ class CollectionSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Collection
|
model = models.Collection
|
||||||
fields = [
|
fields = [
|
||||||
|
'id',
|
||||||
'name',
|
'name',
|
||||||
'start',
|
'block_size',
|
||||||
'end',
|
'image'
|
||||||
'filters',
|
|
||||||
'selectors',
|
|
||||||
'targets',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user