1792 1481
 
1793
-def administrator_update(request):
1794
-    brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
1795
-    admin_id = request.POST.get('admin_id', '')
1796
-
1482
+@check_admin
1483
+def administrator_update(request, administrator):
1797 1484
     target_admin_id = request.POST.get('target_admin_id', '')
1798 1485
     admin_type = int(request.POST.get('admin_type', -1))
1799 1486
     phone = request.POST.get('phone', '')
1800 1487
     name = request.POST.get('name', '')
1801 1488
     password = request.POST.get('password', '')
1802 1489
 
1803
-    if brand_id != settings.KODO_DEFAULT_BRAND_ID:
1804
-        return response(ProductBrandStatusCode.BRAND_NOT_MATCH)
1805
-
1806
-    try:
1807
-        administrator = AdministratorInfo.objects.get(admin_id=admin_id, user_status=AdministratorInfo.ACTIVATED, status=True)
1808
-    except AdministratorInfo.DoesNotExist:
1809
-        return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND)
1810
-
1811 1490
     if administrator.admin_type != AdministratorInfo.ADMINISTRATOR:
1812 1491
         return response(AdministratorStatusCode.ADMINISTRATOR_PERMISSION_DENIED)
1813 1492
 
@@ -1832,19 +1511,10 @@ def administrator_update(request):
1832 1511
     return response(200, 'Update Admin Success', u'更新后台管理员成功')
1833 1512
 
1834 1513
 
1835
-def administrator_delete(request):
1836
-    brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
1837
-    admin_id = request.POST.get('admin_id', '')
1514
+@check_admin
1515
+def administrator_delete(request, administrator):
1838 1516
     target_admin_id = request.POST.get('target_admin_id', '')
1839 1517
 
1840
-    if brand_id != settings.KODO_DEFAULT_BRAND_ID:
1841
-        return response(ProductBrandStatusCode.BRAND_NOT_MATCH)
1842
-
1843
-    try:
1844
-        administrator = AdministratorInfo.objects.get(admin_id=admin_id, user_status=AdministratorInfo.ACTIVATED, status=True)
1845
-    except AdministratorInfo.DoesNotExist:
1846
-        return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND)
1847
-
1848 1518
     if administrator.admin_type != AdministratorInfo.ADMINISTRATOR:
1849 1519
         return response(AdministratorStatusCode.ADMINISTRATOR_PERMISSION_DENIED)
1850 1520
 
@@ -1853,21 +1523,12 @@ def administrator_delete(request):
1853 1523
     return response(200, 'Delete Admin Success', u'删除后台管理员成功')
1854 1524
 
1855 1525
 
1856
-def administrator_login_list(request):
1857
-    brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
1858
-    admin_id = request.POST.get('admin_id', '')
1526
+@check_admin
1527
+def administrator_login_list(request, administrator):
1859 1528
     page = request.POST.get('page', 1)
1860 1529
     num = request.POST.get('num', 20)
1861 1530
     target_admin_id = request.POST.get('target_admin_id', '')
1862 1531
 
1863
-    if brand_id != settings.KODO_DEFAULT_BRAND_ID:
1864
-        return response(ProductBrandStatusCode.BRAND_NOT_MATCH)
1865
-
1866
-    try:
1867
-        administrator = AdministratorInfo.objects.get(admin_id=admin_id, user_status=AdministratorInfo.ACTIVATED, status=True)
1868
-    except AdministratorInfo.DoesNotExist:
1869
-        return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND)
1870
-
1871 1532
     if administrator.admin_type != AdministratorInfo.ADMINISTRATOR:
1872 1533
         return response(AdministratorStatusCode.ADMINISTRATOR_PERMISSION_DENIED)
1873 1534
 

+ 8 - 3
api/urls.py

@@ -165,7 +165,7 @@ urlpatterns += [
165 165
     url(r'^admin/member/goods/order/batch/update$', admin_views.member_goods_order_batch_update, name='member_goods_order_batch_update'),
166 166
 
167 167
     url(r'^admin/member/activity/list$', admin_views.member_activity_list, name='member_activity_list'),
168
-    url(r'^admin/member/activity/details$', admin_views.member_activity_details, name='member_activity_details'),
168
+    url(r'^admin/member/activity/details$', admin_views.member_activity_detail, name='member_activity_detail'),
169 169
     url(r'^admin/member/activity/update$', admin_views.member_activity_update, name='member_activity_update'),
170 170
     url(r'^admin/member/activity/create$', admin_views.member_activity_create, name='member_activity_create'),
171 171
     url(r'^admin/member/activity/share/list$', admin_views.member_activity_share_list, name='member_activity_share_list'),
@@ -175,14 +175,19 @@ urlpatterns += [
175 175
     url(r'^admin/member/activity/contribute/audit$', admin_views.member_activity_contribute_audit, name='admin_member_activity_contribute_audit'),
176 176
     url(r'^admin/member/activity/contribute/selected$', admin_views.member_activity_contribute_selected, name='admin_member_activity_contribute_selected'),
177 177
 
178
+    url(r'^admin/member/activity/contribute/welfare/list$', admin_views.member_activity_contribute_welfare_list, name='member_activity_contribute_welfare_list'),
179
+    url(r'^admin/member/activity/contribute/welfare/detail$', admin_views.member_activity_contribute_welfare_detail, name='member_activity_contribute_welfare_detail'),
180
+    url(r'^admin/member/activity/contribute/welfare/update$', admin_views.member_activity_contribute_welfare_update, name='member_activity_contribute_welfare_update'),
181
+    url(r'^admin/member/activity/contribute/welfare/create$', admin_views.member_activity_contribute_welfare_create, name='member_activity_contribute_welfare_create'),
182
+
178 183
     url(r'^admin/coupon/list$', admin_views.coupon_list, name='coupon_list'),
179
-    url(r'^admin/coupon/details$', admin_views.coupon_details, name='coupon_update'),
184
+    url(r'^admin/coupon/details$', admin_views.coupon_detail, name='coupon_detail'),
180 185
     url(r'^admin/coupon/create$', admin_views.coupon_create, name='coupon_create'),
181 186
     url(r'^admin/coupon/update$', admin_views.coupon_update, name='coupon_update'),
182 187
     url(r'^admin/coupon/delete$', admin_views.coupon_delete, name='coupon_delete'),
183 188
 
184 189
     url(r'^admin/member/goods/list$', admin_views.member_goods_list, name='member_goods_list'),
185
-    url(r'^admin/member/goods/details$', admin_views.member_goods_details, name='member_goods_details'),
190
+    url(r'^admin/member/goods/details$', admin_views.member_goods_detail, name='member_goods_detail'),
186 191
     url(r'^admin/member/goods/create$', admin_views.member_goods_create, name='member_goods_create'),
187 192
     url(r'^admin/member/goods/update$', admin_views.member_goods_update, name='member_goods_update'),
188 193
 

+ 39 - 0
kodo/decorators.py

@@ -0,0 +1,39 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from __future__ import division
4
+
5
+from functools import wraps
6
+
7
+from django.conf import settings
8
+from django_response import response
9
+
10
+from mch.models import AdministratorInfo
11
+from utils.error.errno_utils import AdministratorStatusCode, ProductBrandStatusCode
12
+
13
+
14
+def check_admin(func=None):
15
+    def decorator(func):
16
+        @wraps(func)
17
+        def returned_wrapper(request, *args, **kwargs):
18
+            brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
19
+            admin_id = request.POST.get('admin_id', '')
20
+
21
+            if brand_id != settings.KODO_DEFAULT_BRAND_ID:
22
+                return response(ProductBrandStatusCode.BRAND_NOT_MATCH)
23
+
24
+            try:
25
+                administrator = AdministratorInfo.objects.get(admin_id=admin_id, user_status=AdministratorInfo.ACTIVATED, status=True)
26
+            except AdministratorInfo.DoesNotExist:
27
+                return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND)
28
+
29
+            return func(request, administrator=administrator, *args, **kwargs)
30
+
31
+        return returned_wrapper
32
+
33
+    if not func:
34
+        def foo(func):
35
+            return decorator(func)
36
+
37
+        return foo
38
+
39
+    return decorator(func)

+ 9 - 3
member/admin.py

@@ -5,9 +5,9 @@ from django.contrib import admin
5 5
 from django_admin import DeleteModelAdmin
6 6
 
7 7
 from account.models import UserInfo
8
-from member.models import (GoodsInfo, GoodsOrderInfo, MemberActivityContributionInfo, MemberActivityGroupShareInfo,
9
-                           MemberActivityInfo, MemberActivitySigninInfo, MemberActivitySignupInfo, RightInfo,
10
-                           ShotTypeInfo)
8
+from member.models import (GoodsInfo, GoodsOrderInfo, MemberActivityContributionInfo,
9
+                           MemberActivityContributionWelfareInfo, MemberActivityGroupShareInfo, MemberActivityInfo,
10
+                           MemberActivitySigninInfo, MemberActivitySignupInfo, RightInfo, ShotTypeInfo)
11 11
 from pre.custom_message import sendwxasubscribemessage
12 12
 from utils.redis.rshot import update_member_shot_data
13 13
 
@@ -103,6 +103,11 @@ class MemberActivityContributionInfoAdmin(admin.ModelAdmin):
103 103
     list_filter = ('activity_id', 'content_type', 'is_audit_pass', 'is_selected', 'status')
104 104
 
105 105
 
106
+class MemberActivityContributionWelfareInfoAdmin(admin.ModelAdmin):
107
+    list_display = ('welfare_id', 'welfare_type', 'welfare_title', 'welfare_detail', 'welfare_value', 'welfare_image', 'status', 'created_at', 'updated_at')
108
+    list_filter = ('welfare_type', 'status')
109
+
110
+
106 111
 admin.site.register(GoodsInfo, GoodsInfoAdmin)
107 112
 admin.site.register(GoodsOrderInfo, GoodsOrderInfoAdmin)
108 113
 admin.site.register(RightInfo, RightInfoAdmin)
@@ -112,3 +117,4 @@ admin.site.register(MemberActivitySignupInfo, MemberActivitySignupInfoAdmin)
112 117
 admin.site.register(MemberActivitySigninInfo, MemberActivitySigninInfoAdmin)
113 118
 admin.site.register(MemberActivityGroupShareInfo, MemberActivityGroupShareInfoAdmin)
114 119
 admin.site.register(MemberActivityContributionInfo, MemberActivityContributionInfoAdmin)
120
+admin.site.register(MemberActivityContributionWelfareInfo, MemberActivityContributionWelfareInfoAdmin)

+ 43 - 0
member/migrations/0038_auto_20221025_0141.py

@@ -0,0 +1,43 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 3.2.16 on 2022-10-24 17:41
3
+
4
+from django.db import migrations, models
5
+import django_models_ext.fileext
6
+import shortuuidfield.fields
7
+import simditor.fields
8
+
9
+
10
+class Migration(migrations.Migration):
11
+
12
+    dependencies = [
13
+        ('member', '0037_auto_20221023_2010'),
14
+    ]
15
+
16
+    operations = [
17
+        migrations.CreateModel(
18
+            name='MemberActivityContributionWelfareInfo',
19
+            fields=[
20
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21
+                ('status', models.BooleanField(default=True, help_text='Status', verbose_name='status')),
22
+                ('created_at', models.DateTimeField(auto_now_add=True, help_text='Create Time', verbose_name='created_at')),
23
+                ('updated_at', models.DateTimeField(auto_now=True, help_text='Update Time', verbose_name='updated_at')),
24
+                ('brand_id', models.CharField(blank=True, db_index=True, help_text='品牌唯一标识', max_length=32, null=True, verbose_name='brand_id')),
25
+                ('brand_name', models.CharField(blank=True, help_text='品牌名称', max_length=255, null=True, verbose_name='brand_name')),
26
+                ('welfare_id', shortuuidfield.fields.ShortUUIDField(blank=True, db_index=True, editable=False, help_text='福利唯一标识', max_length=22, null=True, unique=True)),
27
+                ('welfare_type', models.IntegerField(choices=[(0, '实物'), (1, '积分'), (2, '虚拟')], db_index=True, default=0, help_text='福利类型', verbose_name='welfare_type')),
28
+                ('welfare_title', models.CharField(blank=True, help_text='福利标题', max_length=255, null=True, verbose_name='welfare_title')),
29
+                ('welfare_detail', simditor.fields.RichTextField(blank=True, help_text='福利详情', null=True, verbose_name='welfare_detail')),
30
+                ('welfare_value', models.IntegerField(default=0, help_text='福利数量', verbose_name='welfare_value')),
31
+                ('welfare_image', models.ImageField(blank=True, help_text='福利图片', null=True, upload_to=django_models_ext.fileext.upload_path, verbose_name='welfare_image')),
32
+            ],
33
+            options={
34
+                'verbose_name': '会员活动投稿福利信息',
35
+                'verbose_name_plural': '会员活动投稿福利信息',
36
+            },
37
+        ),
38
+        migrations.AlterField(
39
+            model_name='memberactivitycontributioninfo',
40
+            name='content_type',
41
+            field=models.IntegerField(choices=[(0, '投稿'), (1, '创作日记')], db_index=True, default=0, help_text='内容类型', verbose_name='content_type'),
42
+        ),
43
+    ]

+ 19 - 0
member/migrations/0039_memberactivitycontributionwelfareinfo_is_upload_qiniu.py

@@ -0,0 +1,19 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 3.2.16 on 2022-10-24 17:59
3
+
4
+from django.db import migrations, models
5
+
6
+
7
+class Migration(migrations.Migration):
8
+
9
+    dependencies = [
10
+        ('member', '0038_auto_20221025_0141'),
11
+    ]
12
+
13
+    operations = [
14
+        migrations.AddField(
15
+            model_name='memberactivitycontributionwelfareinfo',
16
+            name='is_upload_qiniu',
17
+            field=models.BooleanField(default=False, help_text='是否已上传七牛', verbose_name='is_upload_qiniu'),
18
+        ),
19
+    ]

+ 50 - 0
member/models.py

@@ -718,3 +718,53 @@ class MemberActivityContributionInfo(BaseModelMixin):
718 718
             'video_url': self.video_url or '',
719 719
             'created_at': tc.local_string(utc_dt=self.created_at),
720 720
         }
721
+
722
+
723
+class MemberActivityContributionWelfareInfo(BaseModelMixin):
724
+    WELFARE_TYPE = (
725
+        (0, u'实物'),
726
+        (1, u'积分'),
727
+        (2, u'虚拟'),
728
+    )
729
+
730
+    brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
731
+    brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
732
+
733
+    welfare_id = ShortUUIDField(_(u'welfare_id'), max_length=32, blank=True, null=True, help_text=u'福利唯一标识', db_index=True, unique=True)
734
+
735
+    welfare_type = models.IntegerField(_(u'welfare_type'), choices=WELFARE_TYPE, default=0, help_text=u'福利类型', db_index=True)
736
+
737
+    welfare_title = models.CharField(_(u'welfare_title'), max_length=255, blank=True, null=True, help_text=u'福利标题')
738
+    welfare_detail = RichTextField(_(u'welfare_detail'), blank=True, null=True, help_text=u'福利详情')
739
+    welfare_value = models.IntegerField(_(u'welfare_value'), default=0, help_text=_(u'福利数量'))
740
+    welfare_image = models.ImageField(_(u'welfare_image'), upload_to=upload_path, blank=True, null=True, help_text=u'福利图片')
741
+
742
+    is_upload_qiniu = models.BooleanField(_(u'is_upload_qiniu'), default=False, help_text=_(u'是否已上传七牛'))
743
+
744
+    class Meta:
745
+        verbose_name = _(u'会员活动投稿福利信息')
746
+        verbose_name_plural = _(u'会员活动投稿福利信息')
747
+
748
+    def __unicode__(self):
749
+        return '%d' % self.pk
750
+
751
+    @property
752
+    def welfare_image_path(self):
753
+        return upload_file_path(self.welfare_image)
754
+
755
+    @property
756
+    def welfare_image_url(self):
757
+        return qiniu_file_url(self.welfare_image.name, bucket='tamron') if self.is_upload_qiniu else upload_file_url(self.welfare_image)
758
+
759
+    @property
760
+    def data(self):
761
+        return {
762
+            'welfare_id': self.welfare_id,
763
+            'welfare_type': self.welfare_type,
764
+            'welfare_type_str': dict(MemberActivityContributionWelfareInfo.WELFARE_TYPE).get(self.welfare_type),
765
+            'welfare_title': self.welfare_title,
766
+            'welfare_detail': self.welfare_detail,
767
+            'welfare_value': self.welfare_value,
768
+            'welfare_image_url': self.welfare_image_url,
769
+            'welfare_image_path': self.welfare_image_path,
770
+        }

Kodo/kodo - Gogs: Go Git Service

1 Коммиты (986fd850cf956890c429360c36689ae017c071e9)

Автор SHA1 Сообщение Дата
  Brightcells 680f424408 Update water mark лет %!s(int64=8): %!d(string=назад)