td> 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 "

fix Cross domain bug · d323851d83 - Gogs: Go Git Service

fix Cross domain bug

FFIB 6 年之前
父节点
当前提交
d323851d83
共有 2 个文件被更改,包括 3 次插入0 次删除
  1. 2 0
      kodosale/settings.py
  2. 1 0
      requirements_dj.txt

+ 2 - 0
kodosale/settings.py

@@ -53,6 +53,7 @@ INSTALLED_APPS = [
53 53
     'django_uniapi',
54 54
     'django_admin',
55 55
     'django_we',
56
+    'corsheaders',
56 57
     'commands',
57 58
     'api',
58 59
     'account',
@@ -63,6 +64,7 @@ INSTALLED_APPS = [
63 64
 ]
64 65
 
65 66
 MIDDLEWARE = [
67
+    'corsheaders.middleware.CorsMiddleware',
66 68
     'django.middleware.security.SecurityMiddleware',
67 69
     'django.contrib.sessions.middleware.SessionMiddleware',
68 70
     'django.middleware.common.CommonMiddleware',

+ 1 - 0
requirements_dj.txt

@@ -14,3 +14,4 @@ django-shortuuidfield==0.1.3
14 14
 django-six==1.0.4
15 15
 django-uniapi==1.0.7
16 16
 django-we==1.5.5
17
+django-cors-headers==3.0.2