Add outtake lensman

Brightcells 7 年之前
父节点
当前提交
a6195fa70d

+ 15 - 6
account/admin.py

@@ -10,13 +10,15 @@ from account.models import (LensmanIncomeExpensesInfo, LensmanInfo, LensmanLogin
10 10
 
11 11
 class LensmanInfoAdmin(admin.ModelAdmin):
12 12
     exclude = ('username', 'password', 'encryption')
13
+    list_display = ('lensman_id', 'unionid', 'username', 'name', 'sex', 'phone', 'location', 'proportion', 'nomark', 'origin', 'balance', 'user_status', 'outtake_status', 'status', 'created_at', 'updated_at')
14
+    list_filter = ('is_common_lensman', 'is_outtake_lensman', 'sex', 'user_status', 'outtake_status', 'status')
13 15
     readonly_fields = ('lensman_id', )
14
-    list_display = ('lensman_id', 'unionid', 'username', 'name', 'sex', 'phone', 'location', 'proportion', 'nomark', 'origin', 'balance', 'user_status', 'status', 'created_at', 'updated_at')
15 16
     search_fields = ('name', 'phone', 'location')
16
-    list_filter = ('sex', 'user_status', 'status')
17 17
 
18 18
     @transaction.atomic
19 19
     def save_model(self, request, obj, form, change):
20
+        obj.save()
21
+
20 22
         if not obj.lensman_id:
21 23
             try:
22 24
                 user_id = UserInfo.objects.select_for_update().get(unionid=obj.unionid).user_id
@@ -33,8 +35,12 @@ class LensmanInfoAdmin(admin.ModelAdmin):
33 35
             'location': obj.location,
34 36
             'islensman': True,
35 37
             'user_status': obj.user_status,
38
+            'is_common_lensman': obj.is_common_lensman,
39
+            'is_outtake_lensman': obj.is_outtake_lensman,
36 40
         }
41
+
37 42
         user, created = UserInfo.objects.get_or_create(user_id=obj.lensman_id, defaults=fields)
43
+
38 44
         if not created:
39 45
             fields.pop('user_from', None)
40 46
             for key, value in fields.iteritems():
@@ -52,10 +58,10 @@ class LensmanIncomeExpensesInfoAdmin(admin.ModelAdmin):
52 58
 
53 59
 
54 60
 class TourGuideInfoAdmin(admin.ModelAdmin):
55
-    readonly_fields = ('tourguide_id', )
56 61
     list_display = ('tourguide_id', 'unionid', 'name', 'sex', 'phone', 'location', 'no', 'user_status', 'status', 'created_at', 'updated_at')
57
-    search_fields = ('name', 'phone', 'location', 'no')
58 62
     list_filter = ('sex', 'user_status', 'status')
63
+    readonly_fields = ('tourguide_id', )
64
+    search_fields = ('name', 'phone', 'location', 'no')
59 65
 
60 66
     @transaction.atomic
61 67
     def save_model(self, request, obj, form, change):
@@ -76,8 +82,11 @@ class TourGuideInfoAdmin(admin.ModelAdmin):
76 82
             'location': obj.location,
77 83
             'istourguide': True,
78 84
             'user_status': obj.user_status,
85
+            'outtake_status': obj.outtake_status,
79 86
         }
87
+
80 88
         user, created = UserInfo.objects.get_or_create(user_id=obj.tourguide_id, defaults=fields)
89
+
81 90
         if not created:
82 91
             fields.pop('user_from', None)
83 92
             for key, value in fields.iteritems():
@@ -86,10 +95,10 @@ class TourGuideInfoAdmin(admin.ModelAdmin):
86 95
 
87 96
 
88 97
 class UserInfoAdmin(admin.ModelAdmin):
98
+    list_display = ('user_id', 'user_from', 'username', 'openid', 'unionid', 'name', 'sex', 'nickname', 'phone', 'location', 'islensman', 'istourguide', 'balance', 'user_status', 'outtake_status', 'status', 'created_at', 'updated_at')
99
+    list_filter = ('user_from', 'sex', 'islensman', 'istourguide', 'user_status', 'outtake_status', 'status')
89 100
     readonly_fields = ('user_id', )
90
-    list_display = ('user_id', 'user_from', 'username', 'openid', 'unionid', 'name', 'sex', 'nickname', 'phone', 'location', 'islensman', 'istourguide', 'balance', 'user_status', 'status', 'created_at', 'updated_at')
91 101
     search_fields = ('name', 'phone', 'location')
92
-    list_filter = ('user_from', 'sex', 'islensman', 'istourguide', 'user_status', 'status')
93 102
 
94 103
 
95 104
 class UserLoginLogInfoAdmin(admin.ModelAdmin):

+ 55 - 0
account/migrations/0024_auto_20170917_1825.py

@@ -0,0 +1,55 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.3 on 2017-09-17 10:25
3
+from __future__ import unicode_literals
4
+
5
+from django.db import migrations, models
6
+
7
+
8
+class Migration(migrations.Migration):
9
+
10
+    dependencies = [
11
+        ('account', '0023_auto_20170709_1923'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.AddField(
16
+            model_name='lensmaninfo',
17
+            name='is_common_lensman',
18
+            field=models.BooleanField(db_index=True, default=False, help_text='\u662f\u5426\u4e3a\u666e\u901a\u6444\u5f71\u5e08', verbose_name='is_common_lensman'),
19
+        ),
20
+        migrations.AddField(
21
+            model_name='lensmaninfo',
22
+            name='is_outtake_lensman',
23
+            field=models.BooleanField(db_index=True, default=False, help_text='\u662f\u5426\u4e3a\u82b1\u7d6e\u6444\u5f71\u5e08', verbose_name='is_outtake_lensman'),
24
+        ),
25
+        migrations.AddField(
26
+            model_name='lensmaninfo',
27
+            name='outtake_status',
28
+            field=models.IntegerField(choices=[(-1, '\u5df2\u62d2\u7edd'), (0, '\u672a\u9a8c\u8bc1'), (1, '\u5df2\u6fc0\u6d3b'), (2, '\u5df2\u7981\u7528'), (3, '\u5df2\u5220\u9664'), (10, '\u5df2\u5206\u914d')], default=0, help_text='\u82b1\u7d6e\u6444\u5f71\u5e08\u5ba1\u6838\u72b6\u6001', verbose_name='outtake_status'),
29
+        ),
30
+        migrations.AddField(
31
+            model_name='userinfo',
32
+            name='is_common_lensman',
33
+            field=models.BooleanField(db_index=True, default=False, help_text='\u662f\u5426\u4e3a\u666e\u901a\u6444\u5f71\u5e08', verbose_name='is_common_lensman'),
34
+        ),
35
+        migrations.AddField(
36
+            model_name='userinfo',
37
+            name='is_outtake_lensman',
38
+            field=models.BooleanField(db_index=True, default=False, help_text='\u662f\u5426\u4e3a\u82b1\u7d6e\u6444\u5f71\u5e08', verbose_name='is_outtake_lensman'),
39
+        ),
40
+        migrations.AddField(
41
+            model_name='userinfo',
42
+            name='outtake_status',
43
+            field=models.IntegerField(choices=[(0, '\u672a\u9a8c\u8bc1'), (1, '\u5df2\u6fc0\u6d3b'), (2, '\u5df2\u7981\u7528'), (3, '\u5df2\u5220\u9664'), (10, '\u5df2\u5206\u914d')], default=0, help_text='\u82b1\u7d6e\u6444\u5f71\u5e08\u72b6\u6001', verbose_name='outtake_status'),
44
+        ),
45
+        migrations.AlterField(
46
+            model_name='lensmaninfo',
47
+            name='user_status',
48
+            field=models.IntegerField(choices=[(-1, '\u5df2\u62d2\u7edd'), (0, '\u672a\u9a8c\u8bc1'), (1, '\u5df2\u6fc0\u6d3b'), (2, '\u5df2\u7981\u7528'), (3, '\u5df2\u5220\u9664'), (10, '\u5df2\u5206\u914d')], default=0, help_text='\u666e\u901a\u6444\u5f71\u5e08\u5ba1\u6838\u72b6\u6001', verbose_name='user_status'),
49
+        ),
50
+        migrations.AlterField(
51
+            model_name='userinfo',
52
+            name='user_status',
53
+            field=models.IntegerField(choices=[(0, '\u672a\u9a8c\u8bc1'), (1, '\u5df2\u6fc0\u6d3b'), (2, '\u5df2\u7981\u7528'), (3, '\u5df2\u5220\u9664'), (10, '\u5df2\u5206\u914d')], default=0, help_text='\u7528\u6237\u72b6\u6001', verbose_name='user_status'),
54
+        ),
55
+    ]

+ 28 - 8
account/models.py

@@ -4,10 +4,10 @@ from django.db import models
4 4
 from django.utils.translation import ugettext_lazy as _
5 5
 from jsonfield import JSONField
6 6
 
7
-from pai2.basemodels import CreateUpdateMixin
7
+from pai2.basemodels import CreateUpdateMixin, LensmanTypeBoolMixin, LensmanTypeMixin
8 8
 
9 9
 
10
-class LensmanInfo(CreateUpdateMixin):
10
+class LensmanInfo(CreateUpdateMixin, LensmanTypeBoolMixin):
11 11
     MALE = 1
12 12
     FEMALE = 0
13 13
 
@@ -54,7 +54,8 @@ class LensmanInfo(CreateUpdateMixin):
54 54
     freeze_income_balance = models.IntegerField(_(u'freeze_income_balance'), default=0, help_text=u'摄影师收入冻结余额(分)')
55 55
     freeze_expense_balance = models.IntegerField(_(u'freeze_expense_balance'), default=0, help_text=u'摄影师支出冻结余额(分)')
56 56
 
57
-    user_status = models.IntegerField(_(u'user_status'), choices=USER_STATUS, default=UNVERIFIED)
57
+    user_status = models.IntegerField(_(u'user_status'), choices=USER_STATUS, default=UNVERIFIED, help_text=u'普通摄影师审核状态')
58
+    outtake_status = models.IntegerField(_(u'outtake_status'), choices=USER_STATUS, default=UNVERIFIED, help_text=u'花絮摄影师审核状态')
58 59
     refused_reason = models.TextField(_(u'refused_reason'), blank=True, null=True, help_text=u'审核拒绝原因')
59 60
 
60 61
     signup_ip = models.CharField(_(u'signup_ip'), max_length=255, blank=True, null=True, help_text=_(u'注册IP'))
@@ -68,17 +69,30 @@ class LensmanInfo(CreateUpdateMixin):
68 69
     def __unicode__(self):
69 70
         return unicode(self.pk)
70 71
 
71
-    @property
72
-    def data(self):
72
+    def final_status(self, lensman_type):
73
+        if lensman_type == self.COMMON:  # 普通摄影师校验
74
+            return self.user_status
75
+        elif lensman_type == self.OUTTAKE:  # 花絮摄影师校验
76
+            return self.outtake_status
77
+        return self.user_status
78
+
79
+    def data(self, lensman_type):
73 80
         return {
74 81
             'name': self.name,
75 82
             'sex': self.sex,
76 83
             'phone': self.phone,
77 84
             'location': self.location,
78
-            'status': self.user_status,
85
+            'status': self.final_status(lensman_type),
79 86
             'refused_reason': self.refused_reason,
80 87
         }
81 88
 
89
+    def modified(self, lensman_type):
90
+        if lensman_type == self.COMMON:  # 普通摄影师校验
91
+            return self.user_status in [self.UNVERIFIED, self.REFUSED]
92
+        elif lensman_type == self.OUTTAKE:  # 花絮摄影师校验
93
+            return self.outtake_status in [self.UNVERIFIED, self.REFUSED]
94
+        return False
95
+
82 96
 
83 97
 class LensmanLoginLogInfo(CreateUpdateMixin):
84 98
     SUCCESS = 0
@@ -198,6 +212,10 @@ class TourGuideInfo(CreateUpdateMixin):
198 212
             'refused_reason': self.refused_reason,
199 213
         }
200 214
 
215
+    @property
216
+    def modified(self):
217
+        return self.user_status in [self.UNVERIFIED, self.REFUSED]
218
+
201 219
 
202 220
 class WechatInfo(CreateUpdateMixin):
203 221
     MALE = 1
@@ -226,7 +244,7 @@ class WechatInfo(CreateUpdateMixin):
226 244
         return unicode(self.pk)
227 245
 
228 246
 
229
-class UserInfo(CreateUpdateMixin):
247
+class UserInfo(CreateUpdateMixin, LensmanTypeBoolMixin):
230 248
     APP_USER = 0
231 249
     WX_USER = 1
232 250
     USER_USER = 8
@@ -302,7 +320,8 @@ class UserInfo(CreateUpdateMixin):
302 320
     freeze_income_balance = models.IntegerField(_(u'freeze_income_balance'), default=0, help_text=u'用户收入冻结余额(分)')
303 321
     freeze_expense_balance = models.IntegerField(_(u'freeze_expense_balance'), default=0, help_text=u'用户支出冻结余额(分)')
304 322
 
305
-    user_status = models.IntegerField(_(u'user_status'), choices=USER_STATUS, default=UNVERIFIED)
323
+    user_status = models.IntegerField(_(u'user_status'), choices=USER_STATUS, default=UNVERIFIED, help_text=u'用户状态')
324
+    outtake_status = models.IntegerField(_(u'outtake_status'), choices=USER_STATUS, default=UNVERIFIED, help_text=u'花絮摄影师状态')
306 325
 
307 326
     assign_ip = models.CharField(_(u'assign_ip'), max_length=255, blank=True, null=True, help_text=_(u'分配IP'))
308 327
     assign_at = models.DateTimeField(_(u'assign_at'), blank=True, null=True, help_text=_(u'分配时间'))
@@ -344,6 +363,7 @@ class UserInfo(CreateUpdateMixin):
344 363
             'username': self.username,
345 364
             'nickname': self.nickname,
346 365
             'avatar': self.avatar,
366
+            'lensman_type': self.lensman_type,
347 367
         }
348 368
 
349 369
 

+ 9 - 2
box/views.py

@@ -10,18 +10,25 @@ from utils.redis.connect import r
10 10
 
11 11
 @logit
12 12
 def login_qrcode_api(request):
13
+    lensman_type = int(request.POST.get('lensman_type', 0))
13 14
     unionid = request.POST.get('unionid', '')
14 15
     token = request.POST.get('token', '')
15 16
 
16 17
     if not r.token_exists(unionid, token):
17 18
         return response(TokenStatusCode.TOKEN_HAS_EXPIRED)
18 19
 
20
+    # 用户校验
19 21
     try:
20 22
         user = UserInfo.objects.get(unionid=unionid, islensman=True, status=True)
21 23
     except UserInfo.DoesNotExist:
22 24
         return response(LensmanStatusCode.LENSMAN_NOT_FOUND)
23 25
 
24
-    if user.user_status != UserInfo.ACTIVATED:
25
-        return response(LensmanStatusCode.LENSMAN_NOT_ACTIVATED)
26
+    # 用户状态校验
27
+    if lensman_type == UserInfo.COMMON:  # 普通摄影师校验
28
+        if user.is_common_lensman and user.user_status != UserInfo.ACTIVATED:
29
+            return response(LensmanStatusCode.LENSMAN_NOT_ACTIVATED)
30
+    elif lensman_type == UserInfo.OUTTAKE:  # 花絮摄影师校验
31
+        if user.is_outtake_lensman and user.outtake_status != UserInfo.ACTIVATED:
32
+            return response(LensmanStatusCode.LENSMAN_NOT_ACTIVATED)
26 33
 
27 34
     return response(200, 'Lensman Login Success', u'摄影师登录成功', user.data)

+ 44 - 13
group/lensman_views.py

@@ -32,6 +32,7 @@ from utils.storage_qiniu_utils import file_save
32 32
 @logit
33 33
 def lensman_submit_api(request):
34 34
     """ 摄影师信息提交 """
35
+    lensman_type = int(request.POST.get('lensman_type', 0))
35 36
     unionid = request.POST.get('unionid', '')
36 37
     openid = request.POST.get('openid', '')
37 38
     phone = request.POST.get('phone', '')
@@ -48,28 +49,48 @@ def lensman_submit_api(request):
48 49
     }
49 50
 
50 51
     lensman, created = LensmanInfo.objects.get_or_create(unionid=unionid, defaults=fields)
52
+
51 53
     # 状态为 UNVERIFIED 的允许修改, 其他需要登录摄影师 APP 进行信息的修改
52
-    if lensman.user_status not in [LensmanInfo.UNVERIFIED, LensmanInfo.REFUSED]:
53
-        return response(LensmanStatusCode.LENSMAN_ALREADY_NOT_UNVERIFIED)
54
-    if not created:
55
-        for key, value in fields.iteritems():
56
-            setattr(lensman, key, value)
57
-        lensman.save()
54
+    # 用户状态校验
55
+    if lensman_type == UserInfo.COMMON:  # 普通摄影师校验
56
+        if lensman.is_common_lensman and lensman.user_status not in [LensmanInfo.UNVERIFIED, LensmanInfo.REFUSED]:
57
+            return response(LensmanStatusCode.LENSMAN_ALREADY_NOT_UNVERIFIED)
58
+    elif lensman_type == UserInfo.OUTTAKE:  # 花絮摄影师校验
59
+        if lensman.is_common_lensman and lensman.user_status not in [LensmanInfo.UNVERIFIED, LensmanInfo.REFUSED]:
60
+            return response(LensmanStatusCode.LENSMAN_ALREADY_NOT_UNVERIFIED)
61
+
62
+    for key, value in fields.iteritems():
63
+        setattr(lensman, key, value)
64
+
65
+    if lensman_type == LensmanInfo.COMMON:
66
+        lensman.is_common_lensman = True
67
+    elif lensman_type == LensmanInfo.OUTTAKE:
68
+        lensman.is_outtake_lensman = True
69
+
70
+    lensman.save()
58 71
 
59
-    return response(200, 'Submit Success', u'提交成功', {})
72
+    return response(200, 'Submit Success', u'提交成功')
60 73
 
61 74
 
62 75
 @logit
63 76
 @transaction.atomic
64 77
 def lensman_wx_authorize_api(request):
78
+    lensman_type = int(request.POST.get('lensman_type', 0))
79
+    unionid = request.POST.get('unionid', '')
80
+
81
+    # 用户校验
65 82
     try:
66
-        user = UserInfo.objects.select_for_update().get(unionid=request.POST.get('unionid', ''), islensman=True, status=True)
83
+        user = UserInfo.objects.select_for_update().get(unionid=unionid, islensman=True, status=True)
67 84
     except UserInfo.DoesNotExist:
68 85
         return response(LensmanStatusCode.LENSMAN_NOT_FOUND)
69 86
 
70
-    # 用户是否激活
71
-    if user.user_status != UserInfo.ACTIVATED:
72
-        return response(LensmanStatusCode.LENSMAN_NOT_ACTIVATED)
87
+    # 用户状态校验
88
+    if lensman_type == UserInfo.COMMON:  # 普通摄影师校验
89
+        if user.is_common_lensman and user.user_status != UserInfo.ACTIVATED:
90
+            return response(LensmanStatusCode.LENSMAN_NOT_ACTIVATED)
91
+    elif lensman_type == UserInfo.OUTTAKE:  # 花絮摄影师校验
92
+        if user.is_outtake_lensman and user.outtake_status != UserInfo.ACTIVATED:
93
+            return response(LensmanStatusCode.LENSMAN_NOT_ACTIVATED)
73 94
 
74 95
     # Set User Key's Value
75 96
     user.openid_lensman = request.POST.get('openid', '')
@@ -114,6 +135,7 @@ def lensman_price_fix_api(request):
114 135
 @logit
115 136
 def lensman_photo_upload_api(request):
116 137
     """ 摄影师照片上传 """
138
+    lensman_type = int(request.POST.get('lensman_type', 0))
117 139
     user_id = lensman_id = request.POST.get('user_id', '')
118 140
     nickname = request.POST.get('nickname', '')
119 141
     group_id = request.POST.get('group_id', '')
@@ -125,9 +147,17 @@ def lensman_photo_upload_api(request):
125 147
 
126 148
     # 用户校验
127 149
     try:
128
-        user = UserInfo.objects.get(user_id=user_id, status=True)
150
+        user = UserInfo.objects.get(user_id=user_id, islensman=True, status=True)
129 151
     except UserInfo.DoesNotExist:
130
-        return response(UserStatusCode.USER_NOT_FOUND)
152
+        return response(LensmanStatusCode.LENSMAN_NOT_FOUND)
153
+
154
+    # 用户状态校验
155
+    if lensman_type == UserInfo.COMMON:  # 普通摄影师校验
156
+        if user.is_common_lensman and user.user_status != UserInfo.ACTIVATED:
157
+            return response(LensmanStatusCode.LENSMAN_NOT_ACTIVATED)
158
+    elif lensman_type == UserInfo.OUTTAKE:  # 花絮摄影师校验
159
+        if user.is_outtake_lensman and user.outtake_status != UserInfo.ACTIVATED:
160
+            return response(LensmanStatusCode.LENSMAN_NOT_ACTIVATED)
131 161
 
132 162
     if not group_id:
133 163
         # 判断通过 session_id 创建的群组是否存在,如果不存在,则直接创建
@@ -186,6 +216,7 @@ def lensman_photo_upload_api(request):
186 216
                 'lensman_photo_id': photo.photo_id,
187 217
                 'nomark': price_info.get('nomark', 999),
188 218
                 'origin': price_info.get('origin', 999),
219
+                'lensman_type': lensman_type,
189 220
             }
190 221
         )
191 222
 

+ 20 - 0
group/migrations/0042_groupphotoinfo_lensman_type.py

@@ -0,0 +1,20 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.3 on 2017-09-17 10:06
3
+from __future__ import unicode_literals
4
+
5
+from django.db import migrations, models
6
+
7
+
8
+class Migration(migrations.Migration):
9
+
10
+    dependencies = [
11
+        ('group', '0041_auto_20170825_1342'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.AddField(
16
+            model_name='groupphotoinfo',
17
+            name='lensman_type',
18
+            field=models.IntegerField(choices=[(0, '\u666e\u901a\u6444\u5f71\u5e08'), (10, '\u82b1\u7d6e\u6444\u5f71\u5e08')], db_index=True, default=-1, help_text='\u6444\u5f71\u5e08\u7c7b\u522b', verbose_name='lensman_type'),
19
+        ),
20
+    ]

+ 3 - 2
group/models.py

@@ -5,7 +5,7 @@ from django.utils.translation import ugettext_lazy as _
5 5
 from shortuuidfield import ShortUUIDField
6 6
 from TimeConvert import TimeConvert as tc
7 7
 
8
-from pai2.basemodels import CreateUpdateMixin
8
+from pai2.basemodels import CreateUpdateMixin, LensmanTypeMixin
9 9
 from photo.models import PhotosInfo
10 10
 from utils.qiniucdn import qiniu_file_url
11 11
 from utils.redis.rgroup import get_group_photo_thumbup_flag
@@ -211,7 +211,7 @@ class GroupUserInfo(CreateUpdateMixin):
211 211
         }
212 212
 
213 213
 
214
-class GroupPhotoInfo(CreateUpdateMixin):
214
+class GroupPhotoInfo(CreateUpdateMixin, LensmanTypeMixin):
215 215
     APP_GROUP = 0
216 216
     SESSION_GROUP = 1
217 217
 
@@ -326,6 +326,7 @@ class GroupPhotoInfo(CreateUpdateMixin):
326 326
             'porder': porder,
327 327
             'created_at': created_at,
328 328
             'origin_expired_stamps': origin_expired_stamps(created_at, self.user_id),
329
+            'display_payment_btn': self.photo_from == self.SESSION_GROUP and self.lensman_type not in [self.OUTTAKE],
329 330
         }
330 331
 
331 332
 

+ 1 - 0
group/views.py

@@ -657,6 +657,7 @@ def pai2_home_api(request):
657 657
         'origin_expired_stamps': origin_expired_stamps(row[25], row[16]),
658 658
         'thumbup': get_group_photo_thumbup_flag(row[5], user_id),
659 659
         'porder': get_lensman_order_record(row[5], user_id) if row[21] == GroupPhotoInfo.SESSION_GROUP else {},
660
+        'display_payment_btn': row[21] == GroupPhotoInfo.SESSION_GROUP and row[26] not in [GroupPhotoInfo.OUTTAKE],
660 661
     } for row in rows]
661 662
 
662 663
     return response(200, 'Get Home Data Success', u'获取首页数据成功', {

+ 9 - 8
page/oauth_views.py

@@ -1,14 +1,14 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3
-import json
4
-
5 3
 from django.shortcuts import render
4
+from json_render import json_render
6 5
 
7 6
 from account.models import LensmanInfo, TourGuideInfo
8 7
 from utils.redis.connect import r
9 8
 
10 9
 
11 10
 def lensman_oauth(request):
11
+    lensman_type = int(request.GET.get('lt') or 0)
12 12
     unionid = request.GET.get('unionid', '')
13 13
 
14 14
     try:
@@ -17,8 +17,9 @@ def lensman_oauth(request):
17 17
         lensman = None
18 18
 
19 19
     return render(request, 'page/lensman_oauth.html', {
20
-        'lensman_info': lensman and lensman.data,
21
-        'modified': bool((not lensman) or (lensman and lensman.user_status in [LensmanInfo.UNVERIFIED, LensmanInfo.REFUSED])),  # 是否可以更改信息
20
+        'lensman_type': lensman_type,
21
+        'lensman_info': lensman and lensman.data(lensman_type),
22
+        'modified': bool((not lensman) or (lensman and lensman.modified(lensman_type))),  # 是否可以更改信息
22 23
     })
23 24
 
24 25
 
@@ -32,18 +33,18 @@ def tourguide_oauth(request):
32 33
 
33 34
     return render(request, 'page/tourguide_oauth.html', {
34 35
         'tourguide_info': tourguide and tourguide.data,
35
-        'modified': bool((not tourguide) or (tourguide and tourguide.user_status in [TourGuideInfo.UNVERIFIED, TourGuideInfo.REFUSED])),  # 是否可以更改信息
36
+        'modified': bool((not tourguide) or (tourguide and tourguide.modified)),  # 是否可以更改信息
36 37
     })
37 38
 
38 39
 
39 40
 def login_qrcode(request):
41
+    lensman_type = int(request.GET.get('lt') or 0)
40 42
     unionid = request.GET.get('unionid', '')
41 43
 
42 44
     data = {
45
+        'lensman_type': lensman_type,
43 46
         'unionid': unionid,
44 47
         'token': r.token(unionid)
45 48
     }
46 49
 
47
-    return render(request, 'page/login_qrcode.html', {
48
-        'data': json.dumps(data)
49
-    })
50
+    return json_render(request, 'page/login_qrcode.html', data)

+ 1 - 0
page/templates/page/lensman_oauth.html

@@ -147,6 +147,7 @@
147 147
                     }
148 148
 
149 149
                     return {
150
+                        lensman_type: '{{ lensman_type }}',
150 151
                         unionid: unionid,
151 152
                         openid: getURLParameter('openid'),
152 153
                         name: name,

+ 29 - 0
pai2/basemodels.py

@@ -75,3 +75,32 @@ class PaiaiSrcMixin(models.Model):
75 75
 
76 76
     class Meta:
77 77
         abstract = True
78
+
79
+
80
+class LensmanTypeChoicesMixin(models.Model):
81
+    NOTLENSMAN = -1
82
+    COMMON = 0
83
+    OUTTAKE = 10
84
+
85
+    LENSMAN_TYPE = (
86
+        (COMMON, u'普通摄影师'),
87
+        (OUTTAKE, u'花絮摄影师'),
88
+    )
89
+
90
+    class Meta:
91
+        abstract = True
92
+
93
+
94
+class LensmanTypeMixin(LensmanTypeChoicesMixin):
95
+    lensman_type = models.IntegerField(_(u'lensman_type'), choices=LensmanTypeChoicesMixin.LENSMAN_TYPE, default=LensmanTypeChoicesMixin.NOTLENSMAN, help_text=u'摄影师类别', db_index=True)
96
+
97
+    class Meta:
98
+        abstract = True
99
+
100
+
101
+class LensmanTypeBoolMixin(LensmanTypeChoicesMixin):
102
+    is_common_lensman = models.BooleanField(_(u'is_common_lensman'), default=False, help_text=u'是否为普通摄影师', db_index=True)
103
+    is_outtake_lensman = models.BooleanField(_(u'is_outtake_lensman'), default=False, help_text=u'是否为花絮摄影师', db_index=True)
104
+
105
+    class Meta:
106
+        abstract = True

+ 5 - 4
requirements.txt

@@ -10,6 +10,7 @@ django-curtail-uuid==1.0.0
10 10
 django-detect==1.0.5
11 11
 django-file-md5==1.0.1
12 12
 django-ip==1.0.0
13
+django-json-render==1.0.0
13 14
 django-json-response==1.1.5
14 15
 django-logit==1.0.6
15 16
 django-mobi==0.1.7
@@ -19,9 +20,9 @@ django-rlog==1.0.7
19 20
 django-shortuuidfield==0.1.3
20 21
 django-six==1.0.2
21 22
 django-uniapi==1.0.0
22
-django-we==1.0.10
23
+django-we==1.0.12
23 24
 djangorestframework==3.6.3
24
-furl==1.0.0
25
+furl==1.0.1
25 26
 hiredis==0.2.0
26 27
 isoweek==1.3.3
27 28
 jsonfield==2.0.2
@@ -30,13 +31,13 @@ pep8==1.7.0
30 31
 pysnippets==1.0.4
31 32
 pywe-jssdk==1.0.2
32 33
 pywe-miniapp==1.0.0
33
-pywe-oauth==1.0.4
34
+pywe-oauth==1.0.5
34 35
 pywe-pay==1.0.7
35 36
 pywe-pay-notify==1.0.1
36 37
 pywe-response==1.0.1
37 38
 pywe-sign==1.0.6
38 39
 pywe-xml==1.0.0
39
-qiniu==7.1.4
40
+qiniu==7.1.5
40 41
 redis==2.10.6
41 42
 redis-extensions==1.1.1
42 43
 requests==2.18.4

+ 5 - 0
utils/error/errno_utils.py

@@ -13,6 +13,8 @@ class LensmanStatusCode(BaseStatusCode):
13 13
     # 状态
14 14
     LENSMAN_ALREADY_NOT_UNVERIFIED = StatusCodeField(400010, 'Lensman Already Not Unverified', description=u'摄影师帐号已激活')
15 15
     LENSMAN_NOT_ACTIVATED = StatusCodeField(400015, 'Lensman Not Activated', description=u'摄影师帐号未激活')
16
+    # 类别
17
+    LENSMAN_TYPE_NOT_EXISTS = StatusCodeField(400020, 'Lensman Type Not Exists', description=u'摄影师类别不存在')
16 18
 
17 19
 
18 20
 class TourGuideStatusCode(BaseStatusCode):
@@ -34,6 +36,9 @@ class UserStatusCode(BaseStatusCode):
34 36
     USERNAME_HAS_REGISTERED = StatusCodeField(400503, 'Username Has Registered', description=u'用户名已注册')
35 37
     # 游客
36 38
     GUEST_NOT_ALLOWED = StatusCodeField(400511, 'Guest Not ALLOWED', description=u'游客登录未开启')
39
+    # 身份
40
+    USER_NOT_LENSMAN = StatusCodeField(400521, 'User Not Lensman', description=u'用户非摄影师')
41
+    USER_NOT_TOURGUIDE = StatusCodeField(400522, 'User Not Tourguide', description=u'用户非导游')
37 42
 
38 43
 
39 44
 class PhoneStatusCode(BaseStatusCode):

+ 1 - 1
utils/sql/raw.py

@@ -5,7 +5,7 @@ PAI2_HOME_API = (
5 5
     r"T1.group_id, T2.group_name, T2.group_default_avatar, T2.group_avatar, T2.group_from, T3.photo_id, "
6 6
     r"T3.photo_path, T3.has_watermark, T3.photo_w, T3.photo_h, T3.photo_thumbnail_path, T3.photo_thumbnail_w, T3.photo_thumbnail_h, "
7 7
     r"T3.photo_thumbnail2_path, T3.photo_thumbnail2_w, T3.photo_thumbnail2_h, T3.user_id, T3.nickname, T3.avatar, "
8
-    r"T3.comment_num, T3.thumbup_num, T3.photo_from, T3.session_id, T3.nomark, T3.origin, T3.created_at, T3.lensman_photo_id "
8
+    r"T3.comment_num, T3.thumbup_num, T3.photo_from, T3.session_id, T3.nomark, T3.origin, T3.created_at, T3.lensman_photo_id, T3.lensman_type "
9 9
     r"from (select * from group_groupuserinfo where user_id='{user_id}' and user_status=1 and status=1) as T1 "
10 10
     r"left outer join group_groupinfo as T2 on T1.group_id = T2.group_id "
11 11
     r"left outer join group_groupphotoinfo as T3 on T1.group_id = T3.group_id and T3.id > T1.current_id "