update news serializer, RUD for backoffice
This commit is contained in:
parent
941feb4233
commit
785d2a2f09
18
apps/news/migrations/0016_news_template.py
Normal file
18
apps/news/migrations/0016_news_template.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.4 on 2019-09-27 13:54
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('news', '0015_auto_20190927_0853'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='news',
|
||||
name='template',
|
||||
field=models.PositiveIntegerField(choices=[(0, 'newspaper'), (1, 'main.pdf.erb'), (2, 'main')], default=0),
|
||||
),
|
||||
]
|
||||
|
|
@ -49,6 +49,17 @@ class NewsQuerySet(models.QuerySet):
|
|||
class News(BaseAttributes, TranslatedFieldsMixin):
|
||||
"""News model."""
|
||||
|
||||
# template choices
|
||||
NEWSPAPER = 0
|
||||
MAIN_PDF_ERB = 1
|
||||
MAIN = 2
|
||||
|
||||
TEMPLATE_CHOICES = (
|
||||
(NEWSPAPER, 'newspaper'),
|
||||
(MAIN_PDF_ERB, 'main.pdf.erb'),
|
||||
(MAIN, 'main'),
|
||||
)
|
||||
|
||||
news_type = models.ForeignKey(NewsType, on_delete=models.PROTECT,
|
||||
verbose_name=_('news type'))
|
||||
title = TJSONField(blank=True, null=True, default=None,
|
||||
|
|
@ -78,6 +89,7 @@ class News(BaseAttributes, TranslatedFieldsMixin):
|
|||
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'),
|
||||
on_delete=models.SET_NULL)
|
||||
|
|
|
|||
|
|
@ -89,6 +89,9 @@ class NewsBackOfficeDetailSerializer(NewsBackOfficeBaseSerializer,
|
|||
source='country', write_only=True,
|
||||
queryset=location_models.Country.objects.all())
|
||||
|
||||
template_display = serializers.CharField(source='get_template_display',
|
||||
read_only=True)
|
||||
|
||||
class Meta(NewsBackOfficeBaseSerializer.Meta, NewsDetailSerializer.Meta):
|
||||
"""Meta class."""
|
||||
|
||||
|
|
@ -97,5 +100,7 @@ class NewsBackOfficeDetailSerializer(NewsBackOfficeBaseSerializer,
|
|||
'description',
|
||||
'news_type_id',
|
||||
'country_id',
|
||||
'template',
|
||||
'template_display',
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user