From 7a6655930750180dac3b261f9f8ff81521f4886a Mon Sep 17 00:00:00 2001 From: Kuroshini Date: Mon, 27 Jan 2020 19:38:47 +0300 Subject: [PATCH] remove obviously unnecessary field --- .../0012_remove_subscribe_subscribe_date.py | 17 +++++++++++++++++ apps/notification/models.py | 5 ++++- apps/notification/serializers/common.py | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 apps/notification/migrations/0012_remove_subscribe_subscribe_date.py diff --git a/apps/notification/migrations/0012_remove_subscribe_subscribe_date.py b/apps/notification/migrations/0012_remove_subscribe_subscribe_date.py new file mode 100644 index 00000000..cc805e4b --- /dev/null +++ b/apps/notification/migrations/0012_remove_subscribe_subscribe_date.py @@ -0,0 +1,17 @@ +# Generated by Django 2.2.7 on 2020-01-27 16:37 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('notification', '0011_auto_20200124_1351'), + ] + + operations = [ + migrations.RemoveField( + model_name='subscribe', + name='subscribe_date', + ), + ] diff --git a/apps/notification/models.py b/apps/notification/models.py index 094fcad4..a176034e 100644 --- a/apps/notification/models.py +++ b/apps/notification/models.py @@ -187,7 +187,6 @@ class SubscribeQuerySet(models.QuerySet): class Subscribe(ProjectBaseMixin): """Subscribe model.""" - subscribe_date = models.DateTimeField(_('Last subscribe date'), default=now(), blank=True, null=True) unsubscribe_date = models.DateTimeField(_('Last unsubscribe date'), blank=True, null=True, default=None) subscriber = models.ForeignKey(Subscriber, on_delete=models.CASCADE, null=True) @@ -198,6 +197,10 @@ class Subscribe(ProjectBaseMixin): objects = SubscribeQuerySet.as_manager() + @property + def subscribe_date(self): + return self.created + class Meta: """Meta class.""" diff --git a/apps/notification/serializers/common.py b/apps/notification/serializers/common.py index 6d5e9beb..282a763c 100644 --- a/apps/notification/serializers/common.py +++ b/apps/notification/serializers/common.py @@ -163,6 +163,9 @@ class SubscribeObjectSerializer(serializers.ModelSerializer): 'unsubscribe_date', 'subscription_type' ) + extra_kwargs = { + 'subscribe_date': {'read_only': True}, + } def get_subscription_type(self, instance): return SubscriptionTypeSerializer(