Implemented filtering carousel entries by country code when country code specified and international carousel when not
This commit is contained in:
parent
63304aa2d1
commit
28331e5274
18
apps/main/migrations/0045_carousel_is_international.py
Normal file
18
apps/main/migrations/0045_carousel_is_international.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.7 on 2019-12-23 14:34
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0044_auto_20191217_1125'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='carousel',
|
||||
name='is_international',
|
||||
field=models.BooleanField(default=False, verbose_name='is international'),
|
||||
),
|
||||
]
|
||||
|
|
@ -214,6 +214,9 @@ class CarouselQuerySet(models.QuerySet):
|
|||
"""Filter collection by country code."""
|
||||
return self.filter(country__code=code)
|
||||
|
||||
def get_international(self):
|
||||
return self.filter(is_international=True)
|
||||
|
||||
|
||||
class Carousel(models.Model):
|
||||
"""Carousel model."""
|
||||
|
|
@ -221,6 +224,7 @@ class Carousel(models.Model):
|
|||
object_id = models.PositiveIntegerField(blank=True, null=True, default=None)
|
||||
content_object = generic.GenericForeignKey('content_type', 'object_id')
|
||||
|
||||
is_international = models.BooleanField(default=False, verbose_name=_('is international'))
|
||||
old_id = models.PositiveIntegerField(_('old id'), blank=True, null=True, default=None)
|
||||
title = models.CharField(_('old title'), max_length=255, blank=True, null=True, default=None)
|
||||
link = models.CharField(_('old link'), max_length=255, blank=True, null=True, default=None)
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@ from django.utils.translation import ugettext_lazy as _
|
|||
from rest_framework import serializers
|
||||
from notification import models
|
||||
from utils.methods import get_user_ip
|
||||
from utils.serializers import TranslatedField
|
||||
|
||||
|
||||
class SubscriptionTypeSerializer(serializers.ModelSerializer):
|
||||
"""Subscription type serializer."""
|
||||
|
||||
name_translated = TranslatedField()
|
||||
class Meta:
|
||||
"""Meta class."""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user