merge from develop
This commit is contained in:
parent
90e53d738d
commit
6a9f11e989
14
apps/account/migrations/0014_merge_20191023_0959.py
Normal file
14
apps/account/migrations/0014_merge_20191023_0959.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Generated by Django 2.2.4 on 2019-10-23 09:59
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('account', '0009_auto_20191002_0648'),
|
||||
('account', '0013_auto_20191016_0810'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
]
|
||||
14
apps/news/migrations/0023_merge_20191023_1000.py
Normal file
14
apps/news/migrations/0023_merge_20191023_1000.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Generated by Django 2.2.4 on 2019-10-23 10:00
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('news', '0021_merge_20191002_1300'),
|
||||
('news', '0022_auto_20191021_1306'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
]
|
||||
18
apps/news/migrations/0024_newsgallery_is_main.py
Normal file
18
apps/news/migrations/0024_newsgallery_is_main.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.4 on 2019-10-23 10:01
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('news', '0023_merge_20191023_1000'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='newsgallery',
|
||||
name='is_main',
|
||||
field=models.BooleanField(default=False, verbose_name='Is the main image'),
|
||||
),
|
||||
]
|
||||
|
|
@ -146,10 +146,6 @@ class News(BaseAttributes, TranslatedFieldsMixin):
|
|||
verbose_name=_('State'))
|
||||
is_highlighted = models.BooleanField(default=False,
|
||||
verbose_name=_('Is highlighted'))
|
||||
image_url = models.URLField(blank=True, null=True, default=None,
|
||||
verbose_name=_('Image URL path'))
|
||||
preview_image_url = models.URLField(blank=True, null=True, default=None,
|
||||
verbose_name=_('Preview image URL path'))
|
||||
template = models.PositiveIntegerField(choices=TEMPLATE_CHOICES, default=NEWSPAPER)
|
||||
address = models.ForeignKey('location.Address', blank=True, null=True,
|
||||
default=None, verbose_name=_('address'),
|
||||
|
|
@ -197,10 +193,18 @@ class News(BaseAttributes, TranslatedFieldsMixin):
|
|||
def same_theme(self):
|
||||
return self.__class__.objects.same_theme(self)[:3]
|
||||
|
||||
@property
|
||||
def main_image(self):
|
||||
return self.news_gallery.main_images().first().image
|
||||
|
||||
|
||||
class NewsGalleryQuerySet(models.QuerySet):
|
||||
"""QuerySet for model News"""
|
||||
|
||||
def main_images(self):
|
||||
"""Return objects with flag is_main is True"""
|
||||
return self.filter(is_main=True)
|
||||
|
||||
|
||||
class NewsGallery(models.Model):
|
||||
|
||||
|
|
@ -212,6 +216,10 @@ class NewsGallery(models.Model):
|
|||
related_name='news_gallery',
|
||||
on_delete=models.SET_NULL,
|
||||
verbose_name=_('gallery'))
|
||||
is_main = models.BooleanField(default=False,
|
||||
verbose_name=_('Is the main image'))
|
||||
|
||||
objects = NewsGalleryQuerySet.as_manager()
|
||||
|
||||
class Meta:
|
||||
"""NewsGallery meta class."""
|
||||
|
|
|
|||
|
|
@ -134,7 +134,6 @@ class NewsBaseSerializer(ProjectModelSerializer):
|
|||
|
||||
# related fields
|
||||
news_type = NewsTypeSerializer(read_only=True)
|
||||
gallery = NewsImageSerializer(read_only=True, many=True)
|
||||
tags = TagBaseSerializer(read_only=True, many=True)
|
||||
|
||||
class Meta:
|
||||
|
|
@ -149,7 +148,34 @@ class NewsBaseSerializer(ProjectModelSerializer):
|
|||
'news_type',
|
||||
'tags',
|
||||
'slug',
|
||||
'gallery',
|
||||
)
|
||||
|
||||
|
||||
class NewsListSerializer(NewsBaseSerializer):
|
||||
"""List serializer for News model."""
|
||||
|
||||
# read only fields
|
||||
title_translated = TranslatedField()
|
||||
subtitle_translated = TranslatedField()
|
||||
|
||||
# related fields
|
||||
news_type = NewsTypeSerializer(read_only=True)
|
||||
tags = TagBaseSerializer(read_only=True, many=True)
|
||||
image = NewsImageSerializer(source='main_image', allow_null=True)
|
||||
|
||||
class Meta:
|
||||
"""Meta class."""
|
||||
|
||||
model = models.News
|
||||
fields = (
|
||||
'id',
|
||||
'title_translated',
|
||||
'subtitle_translated',
|
||||
'is_highlighted',
|
||||
'news_type',
|
||||
'tags',
|
||||
'slug',
|
||||
'image',
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -161,6 +187,7 @@ class NewsDetailSerializer(NewsBaseSerializer):
|
|||
author = UserBaseSerializer(source='created_by', read_only=True)
|
||||
state_display = serializers.CharField(source='get_state_display',
|
||||
read_only=True)
|
||||
gallery = NewsImageSerializer(read_only=True, many=True)
|
||||
|
||||
class Meta(NewsBaseSerializer.Meta):
|
||||
"""Meta class."""
|
||||
|
|
@ -175,6 +202,7 @@ class NewsDetailSerializer(NewsBaseSerializer):
|
|||
'state_display',
|
||||
'author',
|
||||
'country',
|
||||
'gallery',
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -242,6 +270,7 @@ class NewsBackOfficeGallerySerializer(serializers.ModelSerializer):
|
|||
model = models.NewsGallery
|
||||
fields = [
|
||||
'id',
|
||||
'is_main',
|
||||
]
|
||||
|
||||
def get_request_kwargs(self):
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class NewsMixinView:
|
|||
|
||||
class NewsListView(NewsMixinView, generics.ListAPIView):
|
||||
"""News list view."""
|
||||
|
||||
serializer_class = serializers.NewsListSerializer
|
||||
filter_class = filters.NewsListFilterSet
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
# Generated by Django 2.2.4 on 2019-10-04 14:01
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('rating', '0002_auto_20191004_1217'),
|
||||
('rating', '0002_auto_20191004_0928'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
]
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
# Generated by Django 2.2.4 on 2019-10-02 07:29
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('timetable', '0002_auto_20190919_1124'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='timetable',
|
||||
options={'ordering': ['weekday'], 'verbose_name': 'Timetable', 'verbose_name_plural': 'Timetables'},
|
||||
),
|
||||
]
|
||||
|
|
@ -369,7 +369,6 @@ SORL_THUMBNAIL_ALIASES = {
|
|||
'avatar_comments_web': {'geometry_string': '116x116', 'crop': 'center'}, # через контент эдитор в мобильном браузерe
|
||||
}
|
||||
|
||||
GEOIP_PATH = os.path.join(PROJECT_ROOT, 'geoip_db')
|
||||
|
||||
# JWT
|
||||
SIMPLE_JWT = {
|
||||
|
|
@ -455,3 +454,17 @@ LIMITING_QUERY_OBJECTS = QUERY_OUTPUT_OBJECTS * 3
|
|||
# GEO
|
||||
# A Spatial Reference System Identifier
|
||||
GEO_DEFAULT_SRID = 4326
|
||||
GEOIP_PATH = os.path.join(PROJECT_ROOT, 'geoip_db')
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
||||
STATIC_ROOT = os.path.join(PUBLIC_ROOT, 'static')
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
STATICFILES_DIRS = (
|
||||
os.path.join(PROJECT_ROOT, 'static'),
|
||||
)
|
||||
|
||||
|
||||
# MEDIA
|
||||
MEDIA_LOCATION = 'media'
|
||||
|
|
@ -31,6 +31,10 @@ MEDIA_URL = f'{SCHEMA_URI}://{DOMAIN_URI}/{MEDIA_LOCATION}/'
|
|||
MEDIA_ROOT = os.path.join(PUBLIC_ROOT, MEDIA_LOCATION)
|
||||
|
||||
|
||||
# SORL thumbnails
|
||||
THUMBNAIL_DEBUG = True
|
||||
|
||||
|
||||
# LOGGING
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
|
|
@ -84,7 +88,3 @@ ELASTICSEARCH_INDEX_NAMES = {
|
|||
TESTING = sys.argv[1:2] == ['test']
|
||||
if TESTING:
|
||||
ELASTICSEARCH_INDEX_NAMES = {}
|
||||
|
||||
|
||||
# SORL thumbnails
|
||||
THUMBNAIL_DEBUG = True
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user