Merge branch 'develop' into feature/product
This commit is contained in:
commit
154df2b720
44
apps/collection/migrations/0015_auto_20191023_0715.py
Normal file
44
apps/collection/migrations/0015_auto_20191023_0715.py
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
# Generated by Django 2.2.4 on 2019-10-23 07:15
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
import utils.models
|
||||||
|
|
||||||
|
|
||||||
|
def fill_title_json_from_title(apps, schema_editor):
|
||||||
|
# We can't import the Person model directly as it may be a newer
|
||||||
|
# version than this migration expects. We use the historical version.
|
||||||
|
Collection = apps.get_model('collection', 'Collection')
|
||||||
|
for collection in Collection.objects.all():
|
||||||
|
collection.name_json = {'en-GB': collection.name}
|
||||||
|
collection.save()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('collection', '0014_auto_20191022_1242'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='collection',
|
||||||
|
name='name_json',
|
||||||
|
field=utils.models.TJSONField(blank=True, default=None, help_text='{"en-GB":"some text"}', null=True, verbose_name='name'),
|
||||||
|
),
|
||||||
|
migrations.RunPython(fill_title_json_from_title, migrations.RunPython.noop),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='collection',
|
||||||
|
name='name',
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='collection',
|
||||||
|
old_name='name_json',
|
||||||
|
new_name='name',
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='collection',
|
||||||
|
name='name',
|
||||||
|
field=utils.models.TJSONField(help_text='{"en-GB":"some text"}', verbose_name='name'),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -43,9 +43,11 @@ class CollectionQuerySet(RelatedObjectsCountMixin):
|
||||||
return self.filter(is_publish=True)
|
return self.filter(is_publish=True)
|
||||||
|
|
||||||
|
|
||||||
class Collection(ProjectBaseMixin, CollectionNameMixin, CollectionDateMixin,
|
class Collection(ProjectBaseMixin, CollectionDateMixin,
|
||||||
TranslatedFieldsMixin, URLImageMixin):
|
TranslatedFieldsMixin, URLImageMixin):
|
||||||
"""Collection model."""
|
"""Collection model."""
|
||||||
|
STR_FIELD_NAME = 'name'
|
||||||
|
|
||||||
ORDINARY = 0 # Ordinary collection
|
ORDINARY = 0 # Ordinary collection
|
||||||
POP = 1 # POP collection
|
POP = 1 # POP collection
|
||||||
|
|
||||||
|
|
@ -54,6 +56,8 @@ class Collection(ProjectBaseMixin, CollectionNameMixin, CollectionDateMixin,
|
||||||
(POP, _('Pop')),
|
(POP, _('Pop')),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
name = TJSONField(verbose_name=_('name'),
|
||||||
|
help_text='{"en-GB":"some text"}')
|
||||||
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'))
|
||||||
|
|
@ -79,10 +83,6 @@ class Collection(ProjectBaseMixin, CollectionNameMixin, CollectionDateMixin,
|
||||||
verbose_name = _('collection')
|
verbose_name = _('collection')
|
||||||
verbose_name_plural = _('collections')
|
verbose_name_plural = _('collections')
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
"""String method."""
|
|
||||||
return f'{self.name}'
|
|
||||||
|
|
||||||
|
|
||||||
class GuideQuerySet(models.QuerySet):
|
class GuideQuerySet(models.QuerySet):
|
||||||
"""QuerySet for Guide."""
|
"""QuerySet for Guide."""
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,19 @@ from rest_framework import serializers
|
||||||
|
|
||||||
from collection import models
|
from collection import models
|
||||||
from location import models as location_models
|
from location import models as location_models
|
||||||
|
from utils.serializers import TranslatedField
|
||||||
|
|
||||||
|
|
||||||
class CollectionBaseSerializer(serializers.ModelSerializer):
|
class CollectionBaseSerializer(serializers.ModelSerializer):
|
||||||
"""Collection base serializer"""
|
"""Collection base serializer"""
|
||||||
# RESPONSE
|
name_translated = TranslatedField()
|
||||||
description_translated = serializers.CharField(read_only=True, allow_null=True)
|
description_translated = TranslatedField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Collection
|
model = models.Collection
|
||||||
fields = [
|
fields = [
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name_translated',
|
||||||
'description_translated',
|
'description_translated',
|
||||||
'image_url',
|
'image_url',
|
||||||
'slug',
|
'slug',
|
||||||
|
|
@ -35,8 +36,7 @@ class CollectionSerializer(CollectionBaseSerializer):
|
||||||
queryset=location_models.Country.objects.all(),
|
queryset=location_models.Country.objects.all(),
|
||||||
write_only=True)
|
write_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta(CollectionBaseSerializer.Meta):
|
||||||
model = models.Collection
|
|
||||||
fields = CollectionBaseSerializer.Meta.fields + [
|
fields = CollectionBaseSerializer.Meta.fields + [
|
||||||
'start',
|
'start',
|
||||||
'end',
|
'end',
|
||||||
|
|
|
||||||
18
apps/main/migrations/0019_award_image_url.py
Normal file
18
apps/main/migrations/0019_award_image_url.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.2.4 on 2019-10-22 14:56
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('main', '0018_feature_source'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='award',
|
||||||
|
name='image_url',
|
||||||
|
field=models.URLField(blank=True, default=None, null=True, verbose_name='Image URL path'),
|
||||||
|
),
|
||||||
|
]
|
||||||
14
apps/main/migrations/0020_merge_20191023_0750.py
Normal file
14
apps/main/migrations/0020_merge_20191023_0750.py
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Generated by Django 2.2.4 on 2019-10-23 07:50
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('main', '0019_award_image_url'),
|
||||||
|
('main', '0019_auto_20191022_1359'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
]
|
||||||
|
|
@ -15,7 +15,8 @@ from location.models import Country
|
||||||
from main import methods
|
from main import methods
|
||||||
from review.models import Review
|
from review.models import Review
|
||||||
from utils.models import (ProjectBaseMixin, TJSONField,
|
from utils.models import (ProjectBaseMixin, TJSONField,
|
||||||
TranslatedFieldsMixin, ImageMixin, PlatformMixin)
|
TranslatedFieldsMixin, ImageMixin,
|
||||||
|
PlatformMixin, URLImageMixin)
|
||||||
from utils.querysets import ContentTypeQuerySetMixin
|
from utils.querysets import ContentTypeQuerySetMixin
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -226,7 +227,7 @@ class SiteFeature(ProjectBaseMixin):
|
||||||
unique_together = ('site_settings', 'feature')
|
unique_together = ('site_settings', 'feature')
|
||||||
|
|
||||||
|
|
||||||
class Award(TranslatedFieldsMixin, models.Model):
|
class Award(TranslatedFieldsMixin, URLImageMixin, models.Model):
|
||||||
"""Award model."""
|
"""Award model."""
|
||||||
award_type = models.ForeignKey('main.AwardType', on_delete=models.CASCADE)
|
award_type = models.ForeignKey('main.AwardType', on_delete=models.CASCADE)
|
||||||
title = TJSONField(
|
title = TJSONField(
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
"""Main app serializers."""
|
"""Main app serializers."""
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from advertisement.serializers.web import AdvertisementSerializer
|
from advertisement.serializers.web import AdvertisementSerializer
|
||||||
from location.serializers import CountrySerializer
|
from location.serializers import CountrySerializer
|
||||||
from main import models
|
from main import models
|
||||||
from establishment.models import Establishment
|
|
||||||
from utils.serializers import TranslatedField
|
from utils.serializers import TranslatedField
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -102,6 +102,7 @@ class AwardBaseSerializer(serializers.ModelSerializer):
|
||||||
'id',
|
'id',
|
||||||
'title_translated',
|
'title_translated',
|
||||||
'vintage_year',
|
'vintage_year',
|
||||||
|
'image_url',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user