会员活动增加activity_section字段

FFIB 2 anni fa
parent
commit
5e1536a8ec
3 ha cambiato i file con 44 aggiunte e 0 eliminazioni
  1. 8 0
      api/admin_views.py
  2. 20 0
      member/migrations/0056_memberactivityinfo_activity_section.py
  3. 16 0
      member/models.py

+ 8 - 0
api/admin_views.py

@@ -776,12 +776,16 @@ def member_activity_list(request, administrator):
776 776
     page = request.POST.get('page', 1)
777 777
     num = request.POST.get('num', 20)
778 778
     activity_state = request.POST.get('activity_state', '')
779
+    activity_section = request.POST.get('activity_section', '')
779 780
 
780 781
     logs = MemberActivityInfo.objects.filter(status=True)
781 782
 
782 783
     if activity_type:
783 784
         logs = logs.filter(activity_type=activity_type)
784 785
 
786
+    if activity_section:
787
+        logs = logs.filter(activity_section=activity_section)
788
+
785 789
     if activity_state:
786 790
         logs = logs.filter(activity_state=activity_state)
787 791
 
@@ -824,6 +828,7 @@ def member_activity_detail(request, administrator):
824 828
 def member_activity_update(request, administrator):
825 829
     activity_id = request.POST.get('activity_id', '')
826 830
     activity_type = int(request.POST.get('activity_type', 0))
831
+    activity_section = int(request.POST.get('activity_section', 3))
827 832
     title = request.POST.get('title', '')
828 833
     subtitle = request.POST.get('subtitle', '')
829 834
     start_date = tc.to_date(request.POST.get('start_date', '') or settings.DEFAULT_START_DATE)
@@ -854,6 +859,7 @@ def member_activity_update(request, administrator):
854 859
         return response(MemberActivityStatusCode.ACTIVITY_NOT_FOUND)
855 860
 
856 861
     log.activity_type = activity_type
862
+    log.activity_section = activity_section
857 863
     log.title = title
858 864
     log.subtitle = subtitle
859 865
     log.date = date
@@ -886,6 +892,7 @@ def member_activity_update(request, administrator):
886 892
 @check_admin
887 893
 def member_activity_create(request, administrator):
888 894
     activity_type = int(request.POST.get('activity_type', 0))
895
+    activity_section = int(request.POST.get('activity_section', 3))
889 896
     title = request.POST.get('title', '')
890 897
     subtitle = request.POST.get('subtitle', '')
891 898
     start_date = tc.to_date(request.POST.get('start_date', '') or settings.DEFAULT_START_DATE)
@@ -913,6 +920,7 @@ def member_activity_create(request, administrator):
913 920
     act = MemberActivityInfo.objects.create(
914 921
         brand_id=administrator.brand_id,
915 922
         activity_type=activity_type,
923
+        activity_section=activity_section,
916 924
         title=title,
917 925
         subtitle=subtitle,
918 926
         date=date,

+ 20 - 0
member/migrations/0056_memberactivityinfo_activity_section.py

@@ -0,0 +1,20 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+# Generated by Django 3.2.6 on 2023-04-24 06:58
4
+
5
+from django.db import migrations, models
6
+
7
+
8
+class Migration(migrations.Migration):
9
+
10
+    dependencies = [
11
+        ('member', '0055_auto_20230418_1602'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.AddField(
16
+            model_name='memberactivityinfo',
17
+            name='activity_section',
18
+            field=models.IntegerField(choices=[(0, 'Tamron Life'), (1, 'Tamron LRC直播课'), (2, '会员投稿'), (3, '其他')], db_index=True, default=3, help_text='活动分区', verbose_name='activity_section'),
19
+        ),
20
+    ]

+ 16 - 0
member/models.py

@@ -374,9 +374,17 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin):
374 374
         (2, u'下线'),
375 375
     )
376 376
 
377
+    ACTIVITY_SECTION = (
378
+        (0, u'Tamron Life'),
379
+        (1, u'Tamron LRC直播课'),
380
+        (2, u'会员投稿'),
381
+        (3, u'其他'),
382
+    )
383
+
377 384
     activity_id = ShortUUIDField(_(u'activity_id'), max_length=32, blank=True, help_text=u'活动唯一标识', db_index=True, unique=True)
378 385
 
379 386
     activity_type = models.IntegerField(_(u'activity_type'), choices=ACTIVITY_TYPE, default=0, help_text=u'活动类型', db_index=True)
387
+    activity_section = models.IntegerField(_(u'activity_section'), choices=ACTIVITY_SECTION, default=3, help_text=u'活动分区', db_index=True)
380 388
 
381 389
     title = models.CharField(_(u'title'), max_length=255, blank=True, default='', help_text=u'活动名称')
382 390
     subtitle = models.CharField(_(u'subtitle'), max_length=255, blank=True, default='', help_text=u'活动二级名称')
@@ -506,6 +514,8 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin):
506 514
             'activity_id': self.activity_id,
507 515
             'activity_type': self.activity_type,
508 516
             'activity_type_str': dict(MemberActivityInfo.ACTIVITY_TYPE).get(self.activity_type),
517
+            'activity_section': self.activity_section,
518
+            'activity_section_str': dict(MemberActivityInfo.ACTIVITY_SECTION).get(self.activity_section),
509 519
             'title': self.title,
510 520
             'subtitle': self.subtitle,
511 521
             'date': tc.local_date_string(self.date),
@@ -542,6 +552,8 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin):
542 552
             'activity_id': self.activity_id,
543 553
             'activity_type': self.activity_type,
544 554
             'activity_type_str': dict(MemberActivityInfo.ACTIVITY_TYPE).get(self.activity_type),
555
+            'activity_section': self.activity_section,
556
+            'activity_section_str': dict(MemberActivityInfo.ACTIVITY_SECTION).get(self.activity_section),
545 557
             'title': self.title,
546 558
             'subtitle': self.subtitle,
547 559
             'date': tc.local_date_string(self.date),
@@ -580,6 +592,8 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin):
580 592
             'activity_id': self.activity_id,
581 593
             'activity_type': self.activity_type,
582 594
             'activity_type_str': dict(MemberActivityInfo.ACTIVITY_TYPE).get(self.activity_type),
595
+            'activity_section': self.activity_section,
596
+            'activity_section_str': dict(MemberActivityInfo.ACTIVITY_SECTION).get(self.activity_section),
583 597
             'title': self.title,
584 598
             'subtitle': self.subtitle,
585 599
             'date': tc.local_date_string(self.date),
@@ -619,6 +633,8 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin):
619 633
             'activity_id': self.activity_id,
620 634
             'activity_type': self.activity_type,
621 635
             'activity_type_str': dict(MemberActivityInfo.ACTIVITY_TYPE).get(self.activity_type),
636
+            'activity_section': self.activity_section,
637
+            'activity_section_str': dict(MemberActivityInfo.ACTIVITY_SECTION).get(self.activity_section),
622 638
             'title': self.title,
623 639
             'subtitle': self.subtitle,
624 640
             'date': tc.local_date_string(self.date),