@@ -4,6 +4,7 @@ from django.conf.urls import include, url |
||
4 | 4 |
|
5 | 5 |
from api.activity import contribution_admin_views |
6 | 6 |
|
7 |
+ |
|
7 | 8 |
urlpatterns = [ |
8 | 9 |
url(r'^admin/member/activity/contribute/delete$', contribution_admin_views.member_activity_contribution_delete_api, name='member_activity_contribution_delete_api'), |
9 |
-] |
|
10 |
+] |
@@ -5,10 +5,10 @@ from django_query import get_query_value |
||
5 | 5 |
from django_response import response |
6 | 6 |
|
7 | 7 |
from kodo.decorators import check_admin |
8 |
- |
|
9 | 8 |
from member.models import MemberActivityContributionInfo |
10 | 9 |
from utils.error.errno_utils import MemberActivityContributionStatusCode |
11 | 10 |
|
11 |
+ |
|
12 | 12 |
@check_admin |
13 | 13 |
@transaction.atomic |
14 | 14 |
def member_activity_contribution_delete_api(request, administrator): |
@@ -22,4 +22,4 @@ def member_activity_contribution_delete_api(request, administrator): |
||
22 | 22 |
contribution.status = False |
23 | 23 |
contribution.save() |
24 | 24 |
|
25 |
- return response(200, 'Member Activity Contribution Delete Success', u'会员活动投稿删除成功') |
|
25 |
+ return response(200, 'Member Activity Contribution Delete Success', u'会员活动投稿删除成功') |
@@ -4,19 +4,19 @@ from django.conf import settings |
||
4 | 4 |
from django_logit import logit |
5 | 5 |
from django_response import response |
6 | 6 |
|
7 |
-from kodo.decorators import check_admin |
|
8 |
-from utils.error.errno_utils import ContractStatusCode, TencentCloudStatusCode |
|
9 |
-from utils.tencentcloud.ess import describe_file_urls |
|
10 |
- |
|
7 |
+from account.models import LensmanInfo, UserInfo |
|
11 | 8 |
from api.lensman import contract_mp_views |
12 |
- |
|
13 | 9 |
from apps.contract.models import LensmanContributionContractInfo |
14 |
-from account.models import LensmanInfo, UserInfo |
|
10 |
+from kodo.decorators import check_admin |
|
15 | 11 |
from member.models import MemberActivityInfo |
16 | 12 |
from pre.custom_message import sendwxasubscribemessage |
13 |
+from utils.error.errno_utils import ContractStatusCode, TencentCloudStatusCode |
|
14 |
+from utils.tencentcloud.ess import describe_file_urls |
|
15 |
+ |
|
17 | 16 |
|
18 | 17 |
WECHAT = settings.WECHAT |
19 | 18 |
|
19 |
+ |
|
20 | 20 |
@logit(res=True) |
21 | 21 |
@check_admin |
22 | 22 |
def get_signed_contribtion_contract_file_api(request, administrator): |
@@ -84,4 +84,4 @@ def start_contribution_contract_sign_api(request, administrator): |
||
84 | 84 |
|
85 | 85 |
res = sendwxasubscribemessage(openid=user.openid_miniapp, template_id=settings.TEMPLATE_ID_CONTRIBUTION_CONTRACT, data=data, miniprogram_state=None, lang=None, page='/pages/member/activity/activity?flow_id={}&contribution_id={}'.format(flow_id, contribution_id)) |
86 | 86 |
|
87 |
- return response(200, 'Start Contribution Contract Sign Success', u'发起投稿授权书签署成功', data={}) |
|
87 |
+ return response(200, 'Start Contribution Contract Sign Success', u'发起投稿授权书签署成功', data={}) |
@@ -17,6 +17,7 @@ from utils.error.errno_utils import ContractStatusCode |
||
17 | 17 |
from utils.redis.rimage import get_images_data |
18 | 18 |
from utils.tencentcloud.ess import (callback_decode, create_document, create_flow, create_scheme_url, start_flow, |
19 | 19 |
test_upload_document_files, upload_document_files) |
20 |
+from utils.thumbnail_utils import make_thumbnail2 |
|
20 | 21 |
|
21 | 22 |
|
22 | 23 |
@logit(res=True) |
@@ -71,6 +72,7 @@ def get_contribtion_contract_api(request): |
||
71 | 72 |
'scheme_url': scheme_url |
72 | 73 |
}) |
73 | 74 |
|
75 |
+ |
|
74 | 76 |
def get_contribtion_contract_sign_mppath_api(request): |
75 | 77 |
user_id = request.POST.get('user_id', '') |
76 | 78 |
flow_id = request.POST.get('flow_id', '') |
@@ -99,6 +101,7 @@ def get_contribtion_contract_sign_mppath_api(request): |
||
99 | 101 |
def generate_file_from_qiniu(file_url): |
100 | 102 |
try: |
101 | 103 |
data = requests.get(file_url).content |
104 |
+ data = make_thumbnail2(data) |
|
102 | 105 |
data = base64.b64encode(data).decode('utf-8') |
103 | 106 |
except Exception: |
104 | 107 |
data = None |
@@ -163,9 +166,8 @@ def create_contribution_contract_flow(lensman): |
||
163 | 166 |
|
164 | 167 |
def create_contribution_contract_document(lensman, contribution_id, file_ids, FlowId): |
165 | 168 |
# 创建电子签文档 https://qian.tencent.com/developers/companyApis/startFlows/CreateDocument |
166 |
- IMAGE_COMPONENTIDS = ['ComponentId_37', 'ComponentId_38','ComponentId_39','ComponentId_40','ComponentId_41','ComponentId_42', |
|
167 |
- 'ComponentId_43','ComponentId_44','ComponentId_45','ComponentId_46','ComponentId_47','ComponentId_48','ComponentId_49','ComponentId_50','ComponentId_51','ComponentId_52','ComponentId_53','ComponentId_54','ComponentId_55', 'ComponentId_55', 'ComponentId_56', 'ComponentId_57', 'ComponentId_58', 'ComponentId_59', 'ComponentId_60', 'ComponentId_9', 'ComponentId_10', 'ComponentId_11', 'ComponentId_12', 'ComponentId_13', 'ComponentId_14', 'ComponentId_15', 'ComponentId_16', 'ComponentId_17', 'ComponentId_18', 'ComponentId_19', 'ComponentId_20', 'ComponentId_21', 'ComponentId_22', 'ComponentId_23', 'ComponentId_24', 'ComponentId_25', 'ComponentId_26', 'ComponentId_27', 'ComponentId_28','ComponentId_29', 'ComponentId_30', 'ComponentId_31', 'ComponentId_32'] |
|
168 |
- |
|
169 |
+ IMAGE_COMPONENTIDS = ['ComponentId_37', 'ComponentId_38', 'ComponentId_39', 'ComponentId_40', 'ComponentId_41', 'ComponentId_42', 'ComponentId_43', 'ComponentId_44', 'ComponentId_45', 'ComponentId_46', 'ComponentId_47', 'ComponentId_48', 'ComponentId_49', 'ComponentId_50', 'ComponentId_51', 'ComponentId_52', 'ComponentId_53', 'ComponentId_54', 'ComponentId_55', 'ComponentId_55', 'ComponentId_56', 'ComponentId_57', 'ComponentId_58', 'ComponentId_59', 'ComponentId_60', 'ComponentId_9', 'ComponentId_10', 'ComponentId_11', 'ComponentId_12', 'ComponentId_13', 'ComponentId_14', 'ComponentId_15', 'ComponentId_16', 'ComponentId_17', 'ComponentId_18', 'ComponentId_19', 'ComponentId_20', 'ComponentId_21', 'ComponentId_22', 'ComponentId_23', 'ComponentId_24', 'ComponentId_25', 'ComponentId_26', 'ComponentId_27', 'ComponentId_28', 'ComponentId_29', 'ComponentId_30', 'ComponentId_31', 'ComponentId_32'] |
|
170 |
+ |
|
169 | 171 |
try: |
170 | 172 |
amount = LensmanContributionActivityIncomeExpensesInfo.objects.get(contribution_id=contribution_id, lensman_id=lensman.lensman_id).amount |
171 | 173 |
except LensmanContributionActivityIncomeExpensesInfo.DoesNotExist: |
@@ -9,7 +9,7 @@ urlpatterns = [ |
||
9 | 9 |
url(r'^mp/lensman/contribution/contract/get$', contract_mp_views.get_contribtion_contract_api, name='get_contribtion_contract_api'), |
10 | 10 |
url(r'^mp/lensman/contribution/contract/status/get$', contract_mp_views.get_contribtion_contract_status_api, name='get_contribtion_contract_status_api'), |
11 | 11 |
url(r'^mp/lensman/contribution/contract/sign/mppach/get$', contract_mp_views.get_contribtion_contract_sign_mppath_api, name='get_contribtion_contract_sign_mppath_api'), |
12 |
- |
|
12 |
+ |
|
13 | 13 |
url(r'^mp/ess/callback$', contract_mp_views.ess_callback, name='ess_callback'), |
14 | 14 |
] |
15 | 15 |
|
@@ -75,6 +75,7 @@ def lensman_audit(request, administrator): |
||
75 | 75 |
|
76 | 76 |
return response(200, 'Lensman Audit Pass Suceess', u'摄影师审核通过') |
77 | 77 |
|
78 |
+ |
|
78 | 79 |
@logit |
79 | 80 |
@check_admin |
80 | 81 |
def lensman_delete(request, administrator): |
@@ -393,4 +393,4 @@ urlpatterns += [ |
||
393 | 393 |
# 会员活动模块 |
394 | 394 |
urlpatterns += [ |
395 | 395 |
url(r'', include(('api.activity.activity_urls', 'activity'), namespace='activity')), |
396 |
-] |
|
396 |
+] |
@@ -112,7 +112,7 @@ class MaintenaceInfo(BaseModelMixin): |
||
112 | 112 |
'model_id': self.model_id, |
113 | 113 |
'model_name': model.model_name if model else '', |
114 | 114 |
'model_full_name': model.model_full_name if model else '', |
115 |
- #'model_image_url': model.image2_url, |
|
115 |
+ # 'model_image_url': model.image2_url, |
|
116 | 116 |
'log_id': self.log_id, |
117 | 117 |
'sn': self.sn, |
118 | 118 |
'desc': self.desc, |
@@ -153,7 +153,7 @@ def activity_contribute_create(request): |
||
153 | 153 |
try: |
154 | 154 |
lensman = LensmanInfo.objects.get(user_id=user_id, status=True) |
155 | 155 |
user_name = lensman.name |
156 |
- except: |
|
156 |
+ except LensmanInfo.DoesNotExist: |
|
157 | 157 |
pass |
158 | 158 |
|
159 | 159 |
try: |
@@ -44,7 +44,6 @@ def upload_document_files(files, file_type='png'): |
||
44 | 44 |
file_ids = file_ids + res.FileIds |
45 | 45 |
_files = _files[20:] |
46 | 46 |
|
47 |
- |
|
48 | 47 |
return file_ids |
49 | 48 |
|
50 | 49 |
|
@@ -4,6 +4,15 @@ from __future__ import division |
||
4 | 4 |
|
5 | 5 |
|
6 | 6 |
try: |
7 |
+ from cStringIO import StringIO |
|
8 |
+ from cStringIO import StringIO as BytesIO |
|
9 |
+except ImportError: |
|
10 |
+ try: |
|
11 |
+ from StringIO import StringIO |
|
12 |
+ from StringIO import StringIO as BytesIO |
|
13 |
+ except ImportError: |
|
14 |
+ from io import BytesIO, StringIO |
|
15 |
+try: |
|
7 | 16 |
from PIL import Image |
8 | 17 |
except ImportError: |
9 | 18 |
import Image |
@@ -17,3 +26,18 @@ def make_thumbnail(im_path, im_thumbnail_path=None, max_width=360): |
||
17 | 26 |
im.thumbnail((thumb_width, thumb_height), Image.ANTIALIAS) |
18 | 27 |
im.save(im_thumbnail_path or im_path, im.format or 'JPEG', quality=90) |
19 | 28 |
return width, height, thumb_width, thumb_height |
29 |
+ |
|
30 |
+ |
|
31 |
+def make_thumbnail2(data, w=360, h=240): |
|
32 |
+ im = Image.open(BytesIO(data)) |
|
33 |
+ fmt = im.format.lower() |
|
34 |
+ width, height = im.size |
|
35 |
+ if width > height: |
|
36 |
+ thumb_width, thumb_height = w, height * w / width |
|
37 |
+ else: |
|
38 |
+ thumb_width, thumb_height = width * h / height, h |
|
39 |
+ im.thumbnail((thumb_width, thumb_height), Image.ANTIALIAS) |
|
40 |
+ out = BytesIO() |
|
41 |
+ im.save(out, format=fmt) |
|
42 |
+ data = out.getvalue() |
|
43 |
+ return data |