chane FK to URLField in Collection model, added properties to field collections in Establishment model
This commit is contained in:
parent
413c93bead
commit
2089ca067a
22
apps/collection/migrations/0011_auto_20190920_1059.py
Normal file
22
apps/collection/migrations/0011_auto_20190920_1059.py
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Generated by Django 2.2.4 on 2019-09-20 10:59
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('collection', '0010_collection_description'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='collection',
|
||||||
|
name='image',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='collection',
|
||||||
|
name='image_url',
|
||||||
|
field=models.URLField(blank=True, default=None, null=True, verbose_name='Image URL path'),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -4,7 +4,7 @@ from utils.models import TJSONField
|
||||||
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 utils.models import ProjectBaseMixin, ImageMixin
|
from utils.models import ProjectBaseMixin, URLImageMixin
|
||||||
from utils.models import TranslatedFieldsMixin
|
from utils.models import TranslatedFieldsMixin
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -41,7 +41,8 @@ class CollectionQuerySet(models.QuerySet):
|
||||||
return self.filter(is_publish=True)
|
return self.filter(is_publish=True)
|
||||||
|
|
||||||
|
|
||||||
class Collection(ProjectBaseMixin, CollectionNameMixin, CollectionDateMixin, TranslatedFieldsMixin):
|
class Collection(ProjectBaseMixin, CollectionNameMixin, CollectionDateMixin,
|
||||||
|
TranslatedFieldsMixin, URLImageMixin):
|
||||||
"""Collection model."""
|
"""Collection model."""
|
||||||
ORDINARY = 0 # Ordinary collection
|
ORDINARY = 0 # Ordinary collection
|
||||||
POP = 1 # POP collection
|
POP = 1 # POP collection
|
||||||
|
|
@ -54,9 +55,6 @@ class Collection(ProjectBaseMixin, CollectionNameMixin, CollectionDateMixin, Tra
|
||||||
collection_type = models.PositiveSmallIntegerField(choices=COLLECTION_TYPES,
|
collection_type = models.PositiveSmallIntegerField(choices=COLLECTION_TYPES,
|
||||||
default=ORDINARY,
|
default=ORDINARY,
|
||||||
verbose_name=_('Collection type'))
|
verbose_name=_('Collection type'))
|
||||||
image = models.ForeignKey(
|
|
||||||
'gallery.Image', null=True, blank=True, default=None,
|
|
||||||
verbose_name=_('Collection image'), on_delete=models.CASCADE)
|
|
||||||
is_publish = models.BooleanField(
|
is_publish = models.BooleanField(
|
||||||
default=False, verbose_name=_('Publish status'))
|
default=False, verbose_name=_('Publish status'))
|
||||||
on_top = models.BooleanField(
|
on_top = models.BooleanField(
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from collection import models
|
from collection import models
|
||||||
from gallery import models as gallery_models
|
|
||||||
from location import models as location_models
|
from location import models as location_models
|
||||||
|
|
||||||
|
|
||||||
class CollectionSerializer(serializers.ModelSerializer):
|
class CollectionSerializer(serializers.ModelSerializer):
|
||||||
"""Collection serializer"""
|
"""Collection serializer"""
|
||||||
# RESPONSE
|
# RESPONSE
|
||||||
image_url = serializers.ImageField(source='image.image')
|
|
||||||
description_translated = serializers.CharField(read_only=True, allow_null=True)
|
description_translated = serializers.CharField(read_only=True, allow_null=True)
|
||||||
|
|
||||||
# COMMON
|
# COMMON
|
||||||
|
|
@ -22,9 +20,6 @@ class CollectionSerializer(serializers.ModelSerializer):
|
||||||
country = serializers.PrimaryKeyRelatedField(
|
country = serializers.PrimaryKeyRelatedField(
|
||||||
queryset=location_models.Country.objects.all(),
|
queryset=location_models.Country.objects.all(),
|
||||||
write_only=True)
|
write_only=True)
|
||||||
image = serializers.PrimaryKeyRelatedField(
|
|
||||||
queryset=gallery_models.Image.objects.all(),
|
|
||||||
write_only=True)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Collection
|
model = models.Collection
|
||||||
|
|
@ -34,7 +29,6 @@ class CollectionSerializer(serializers.ModelSerializer):
|
||||||
'description_translated',
|
'description_translated',
|
||||||
'start',
|
'start',
|
||||||
'end',
|
'end',
|
||||||
'image',
|
|
||||||
'image_url',
|
'image_url',
|
||||||
'is_publish',
|
'is_publish',
|
||||||
'on_top',
|
'on_top',
|
||||||
|
|
|
||||||
18
apps/establishment/migrations/0027_auto_20190920_1120.py
Normal file
18
apps/establishment/migrations/0027_auto_20190920_1120.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.2.4 on 2019-09-20 11:20
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('establishment', '0026_establishment_preview_image_url'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='establishment',
|
||||||
|
name='collections',
|
||||||
|
field=models.ManyToManyField(blank=True, default=None, null=True, related_name='establishments', to='collection.Collection', verbose_name='Collections'),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -272,8 +272,9 @@ class Establishment(ProjectBaseMixin, URLImageMixin, TranslatedFieldsMixin):
|
||||||
transportation = models.TextField(blank=True, null=True, default=None,
|
transportation = models.TextField(blank=True, null=True, default=None,
|
||||||
verbose_name=_('Transportation'))
|
verbose_name=_('Transportation'))
|
||||||
collections = models.ManyToManyField(to='collection.Collection',
|
collections = models.ManyToManyField(to='collection.Collection',
|
||||||
verbose_name=_('Collections'),
|
related_name='establishments',
|
||||||
related_name='establishments')
|
blank=True, null=True, default=None,
|
||||||
|
verbose_name=_('Collections'))
|
||||||
preview_image_url = models.URLField(verbose_name=_('Preview image URL path'),
|
preview_image_url = models.URLField(verbose_name=_('Preview image URL path'),
|
||||||
blank=True, null=True, default=None)
|
blank=True, null=True, default=None)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user