change news states

This commit is contained in:
Kuroshini 2020-02-05 16:12:28 +03:00
parent 2eeb67e10f
commit ce9aa30074
4 changed files with 23 additions and 10 deletions

View File

@ -69,7 +69,6 @@ def send_team_invite_to_existing_user(user_id, country_code, user_role_id, resta
f'DETAIL: Exception occurred for user: {user_id}') f'DETAIL: Exception occurred for user: {user_id}')
@shared_task @shared_task
def team_role_revoked(user_id, country_code, restaurant_name): def team_role_revoked(user_id, country_code, restaurant_name):
"""Send email to establishment team member with role acceptance link""" """Send email to establishment team member with role acceptance link"""

View File

@ -0,0 +1,18 @@
# Generated by Django 2.2.7 on 2020-02-05 13:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('news', '0055_auto_20200131_1232'),
]
operations = [
migrations.AlterField(
model_name='news',
name='state',
field=models.PositiveSmallIntegerField(choices=[(0, 'published'), (1, 'not published')], default=1, verbose_name='State'),
),
]

View File

@ -278,16 +278,12 @@ class News(GalleryMixin, BaseAttributes, TranslatedFieldsMixin, HasTagsMixin,
) )
# STATE CHOICES # STATE CHOICES
REMOVE = 0 PUBLISHED = 0
HIDDEN = 1 UNPUBLISHED = 1
PUBLISHED = 2
UNPUBLISHED = 3
PUBLISHED_STATES = [PUBLISHED] PUBLISHED_STATES = [PUBLISHED]
STATE_CHOICES = ( STATE_CHOICES = (
(REMOVE, _('remove')), # simply stored in DB news. not shown anywhere
(HIDDEN, _('hidden')), # not shown in api/web or api/mobile
(PUBLISHED, _('published')), # shown everywhere (PUBLISHED, _('published')), # shown everywhere
(UNPUBLISHED, _('not published')), # newly created news (UNPUBLISHED, _('not published')), # newly created news
) )

View File

@ -92,9 +92,9 @@ class NewsSerializer(serializers.Serializer):
states = { states = {
'new': News.UNPUBLISHED, 'new': News.UNPUBLISHED,
'published': News.PUBLISHED, 'published': News.PUBLISHED,
'hidden': News.HIDDEN, 'hidden': News.UNPUBLISHED,
'published_exclusive': News.PUBLISHED, 'published_exclusive': News.UNPUBLISHED,
'scheduled_exclusively': News.PUBLISHED, 'scheduled_exclusively': News.UNPUBLISHED,
} }
return states.get(data['page__state'], News.UNPUBLISHED) return states.get(data['page__state'], News.UNPUBLISHED)