:bug: Fix Bug: can't compare datetime.date to NoneType

huangqimin 5 jaren geleden
bovenliggende
commit
95936d0718
3 gewijzigde bestanden met toevoegingen van 29 en 1 verwijderingen
  1. 26 0
      coupon/migrations/0006_auto_20191230_1516.py
  2. 1 1
      coupon/models.py
  3. 2 0
      member/models.py

+ 26 - 0
coupon/migrations/0006_auto_20191230_1516.py

@@ -0,0 +1,26 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.26 on 2019-12-30 07:16
3
+from __future__ import unicode_literals
4
+
5
+from django.db import migrations, models
6
+import shortuuidfield.fields
7
+
8
+
9
+class Migration(migrations.Migration):
10
+
11
+    dependencies = [
12
+        ('coupon', '0005_auto_20191223_1830'),
13
+    ]
14
+
15
+    operations = [
16
+        migrations.AddField(
17
+            model_name='usercouponinfo',
18
+            name='user_coupon_id',
19
+            field=shortuuidfield.fields.ShortUUIDField(blank=True, db_index=True, editable=False, help_text='\u7528\u6237\u5238\u552f\u4e00\u6807\u8bc6', max_length=22, null=True, unique=True),
20
+        ),
21
+        migrations.AlterField(
22
+            model_name='usercouponinfo',
23
+            name='coupon_id',
24
+            field=models.CharField(blank=True, db_index=True, help_text='\u5238\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='coupon_id'),
25
+        ),
26
+    ]

+ 1 - 1
coupon/models.py

@@ -48,7 +48,7 @@ class UserCouponInfo(BaseModelMixin):
48 48
     brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
49 49
 
50 50
     user_coupon_id = ShortUUIDField(_(u'user_coupon_id'), max_length=32, blank=True, null=True, help_text=u'用户券唯一标识', db_index=True, unique=True)
51
-    coupon_id = ShortUUIDField(_(u'coupon_id'), max_length=32, blank=True, null=True, help_text=u'券唯一标识', db_index=True)
51
+    coupon_id = models.CharField(_(u'coupon_id'), max_length=32, blank=True, null=True, help_text=u'券唯一标识', db_index=True)
52 52
     user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
53 53
 
54 54
     coupon_title = models.CharField(_(u'coupon_title'), max_length=255, blank=True, null=True, help_text=u'券标题')

+ 2 - 0
member/models.py

@@ -311,6 +311,8 @@ class MemberActivityInfo(BaseModelMixin):
311 311
 
312 312
     @property
313 313
     def final_state(self):
314
+        if not self.date:
315
+            return u'报名中'
314 316
         tdate = tc.local_date()
315 317
         if tdate < self.date:
316 318
             return u'报名中'