@@ -32,7 +32,7 @@ urlpatterns += [ |
||
| 32 | 32 |
|
| 33 | 33 |
url(r'^l/wx/authorize$', lensman_views.lensman_wx_authorize_api, name='lensman_wx_authorize_api'), # 微信用户授权 |
| 34 | 34 |
|
| 35 |
- url(r'^l/photos/upload$', lensman_views.lensman_upload_photo_api, name='lensman_upload_photo_api'), # 摄影师上传照片 |
|
| 35 |
+ url(r'^l/upload$', lensman_views.lensman_photo_upload_api, name='lensman_photo_upload_api'), # 摄影师照片上传 |
|
| 36 | 36 |
] |
| 37 | 37 |
|
| 38 | 38 |
# 群组相关 |
@@ -105,15 +105,16 @@ def lensman_wx_authorize_api(request): |
||
| 105 | 105 |
return response(200, 'Lensman Login Success', u'摄影师登录成功', user.data) |
| 106 | 106 |
|
| 107 | 107 |
|
| 108 |
-def lensman_upload_photo_api(request): |
|
| 108 |
+@logit |
|
| 109 |
+def lensman_photo_upload_api(request): |
|
| 109 | 110 |
""" |
| 110 |
- 摄影师上传照片 |
|
| 111 |
+ 摄影师照片上传 |
|
| 111 | 112 |
:param request: |
| 112 | 113 |
:return: |
| 113 | 114 |
""" |
| 114 | 115 |
user_id = lensman_id = request.POST.get('user_id', '')
|
| 115 | 116 |
nickname = request.POST.get('nickname', '')
|
| 116 |
- session_id = request.POST.get('session', '')
|
|
| 117 |
+ session_id = request.POST.get('session_id', '')
|
|
| 117 | 118 |
|
| 118 | 119 |
photo_id = request.POST.get('photo_id', '')
|
| 119 | 120 |
|
@@ -48,11 +48,11 @@ urlpatterns = [ |
||
| 48 | 48 |
|
| 49 | 49 |
urlpatterns += [ |
| 50 | 50 |
# url(r'^api/', include('api.urls', namespace='api')),
|
| 51 |
- url(r'^s/(?P<session>\w+)$', photo_views.session_detail, name='session_detail'), # Session 详情 |
|
| 52 |
- url(r'^p/(?P<photo>\w+)$', photo_views.photo_standard, name='photo_standard'), # standard thumbnail, available for free |
|
| 53 |
- url(r'^m/(?P<photo>\w+)$', photo_views.photo_medium, name='photo_medium'), # medium/mobile version, without watermark, login or paid by others |
|
| 54 |
- url(r'^l/(?P<photo>\w+)$', photo_views.photo_large, name='photo_large'), # large, might support server side panning later, login required |
|
| 55 |
- url(r'^r/(?P<photo>\w+)$', photo_views.photo_raw, name='photo_raw'), # raw image, only for finishers |
|
| 51 |
+ url(r'^s/(?P<session_id>\w+)$', photo_views.session_detail, name='session_detail'), # Session 详情 |
|
| 52 |
+ url(r'^p/(?P<photo_id>\w+)$', photo_views.photo_standard, name='photo_standard'), # standard thumbnail, available for free |
|
| 53 |
+ url(r'^m/(?P<photo_id>\w+)$', photo_views.photo_medium, name='photo_medium'), # medium/mobile version, without watermark, login or paid by others |
|
| 54 |
+ url(r'^l/(?P<photo_id>\w+)$', photo_views.photo_large, name='photo_large'), # large, might support server side panning later, login required |
|
| 55 |
+ url(r'^r/(?P<photo_id>\w+)$', photo_views.photo_raw, name='photo_raw'), # raw image, only for finishers |
|
| 56 | 56 |
] |
| 57 | 57 |
|
| 58 | 58 |
urlpatterns += [ |
@@ -68,17 +68,17 @@ class PhotosInfo(CreateUpdateMixin): |
||
| 68 | 68 |
def data(self): |
| 69 | 69 |
return {
|
| 70 | 70 |
'pk': self.pk, |
| 71 |
- 'user': self.lensman_id, |
|
| 72 |
- 'session': self.session_id, |
|
| 73 |
- 'photo': self.photo_id, |
|
| 71 |
+ 'user_id': self.lensman_id, |
|
| 72 |
+ 'session_id': self.session_id, |
|
| 73 |
+ 'photo_id': self.photo_id, |
|
| 74 | 74 |
} |
| 75 | 75 |
|
| 76 | 76 |
@property |
| 77 | 77 |
def detail(self): |
| 78 | 78 |
return {
|
| 79 | 79 |
'pk': self.pk, |
| 80 |
- 'user': self.lensman_id, |
|
| 81 |
- 'session': self.session_id, |
|
| 82 |
- 'photo': self.photo_id, |
|
| 80 |
+ 'user_id': self.lensman_id, |
|
| 81 |
+ 'session_id': self.session_id, |
|
| 82 |
+ 'photo_id': self.photo_id, |
|
| 83 | 83 |
'photo_url': self.p_photo_url, |
| 84 | 84 |
} |
@@ -81,15 +81,15 @@ def uuid(request): |
||
| 81 | 81 |
# name with the symbol <. The difference between @ and < is then that @ makes a file get attached in the post as a file upload, |
| 82 | 82 |
# while the < makes a text field and just get the contents for that text field from a file. |
| 83 | 83 |
# |
| 84 |
-# curl -X POST -F user=xxxxxxx -F session=xxxxxxx -F photo_id=xxxxxxx -F photo=@xxxxxxx.jpg http://api.pai.ai/photos/upload |
|
| 84 |
+# curl -X POST -F user_id=xxxxxxx -F session_id=xxxxxxx -F photo_id=xxxxxxx -F photo=@xxxxxxx.jpg http://api.pai.ai/photos/upload |
|
| 85 | 85 |
def upload_photo(request): |
| 86 | 86 |
""" |
| 87 | 87 |
上传图片 |
| 88 | 88 |
:param request: |
| 89 | 89 |
:return: |
| 90 | 90 |
""" |
| 91 |
- lensman_id = request.POST.get('user', '')
|
|
| 92 |
- session_id = request.POST.get('session', '')
|
|
| 91 |
+ lensman_id = request.POST.get('user_id', '')
|
|
| 92 |
+ session_id = request.POST.get('session_id', '')
|
|
| 93 | 93 |
photo_id = request.POST.get('photo_id', '')
|
| 94 | 94 |
|
| 95 | 95 |
photo = request.FILES.get('photo', '')
|
@@ -261,18 +261,18 @@ def session_join_api(request): |
||
| 261 | 261 |
}) |
| 262 | 262 |
|
| 263 | 263 |
|
| 264 |
-def session_detail(request, session): |
|
| 265 |
- photos = PhotosInfo.objects.filter(session_id=session) |
|
| 264 |
+def session_detail(request, session_id): |
|
| 265 |
+ photos = PhotosInfo.objects.filter(session_id=session_id) |
|
| 266 | 266 |
return render(request, 'photo/session_detail.html', {'photos': photos})
|
| 267 | 267 |
|
| 268 | 268 |
|
| 269 |
-def photo_standard(request, photo): |
|
| 270 |
- photo = PhotosInfo.objects.get(photo_id=photo) |
|
| 269 |
+def photo_standard(request, photo_id): |
|
| 270 |
+ photo = PhotosInfo.objects.get(photo_id=photo_id) |
|
| 271 | 271 |
return render(request, 'photo/photo_detail.html', {'photo_url': photo.p_photo_url})
|
| 272 | 272 |
|
| 273 | 273 |
|
| 274 |
-def photo_standard_api(request, photo): |
|
| 275 |
- photo = PhotosInfo.objects.get(photo_id=photo) |
|
| 274 |
+def photo_standard_api(request, photo_id): |
|
| 275 |
+ photo = PhotosInfo.objects.get(photo_id=photo_id) |
|
| 276 | 276 |
return JsonResponse({
|
| 277 | 277 |
'status': 200, |
| 278 | 278 |
'message': u'获取照片详情成功', |
@@ -282,18 +282,18 @@ def photo_standard_api(request, photo): |
||
| 282 | 282 |
}) |
| 283 | 283 |
|
| 284 | 284 |
|
| 285 |
-def photo_medium(request, photo): |
|
| 286 |
- photo = PhotosInfo.objects.get(photo_id=photo) |
|
| 285 |
+def photo_medium(request, photo_id): |
|
| 286 |
+ photo = PhotosInfo.objects.get(photo_id=photo_id) |
|
| 287 | 287 |
return render(request, 'photo/photo_detail.html', {'photo_url': photo.m_photo_url})
|
| 288 | 288 |
|
| 289 | 289 |
|
| 290 |
-def photo_large(request, photo): |
|
| 291 |
- photo = PhotosInfo.objects.get(photo_id=photo) |
|
| 290 |
+def photo_large(request, photo_id): |
|
| 291 |
+ photo = PhotosInfo.objects.get(photo_id=photo_id) |
|
| 292 | 292 |
return render(request, 'photo/photo_detail.html', {'photo_url': photo.l_photo_url})
|
| 293 | 293 |
|
| 294 | 294 |
|
| 295 |
-def photo_raw(request, photo): |
|
| 296 |
- photo = PhotosInfo.objects.get(photo_id=photo) |
|
| 295 |
+def photo_raw(request, photo_id): |
|
| 296 |
+ photo = PhotosInfo.objects.get(photo_id=photo_id) |
|
| 297 | 297 |
return render(request, 'photo/photo_detail.html', {'photo_url': photo.r_photo_url})
|
| 298 | 298 |
|
| 299 | 299 |
|