Add forbidden duplicate upload photo

Brightcells лет %!s(int64=8): %!d(string=назад)
Родитель
Сommit
ec611ba992
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      group/lensman_views.py

+ 2 - 2
group/lensman_views.py

@@ -176,7 +176,7 @@ def lensman_photo_upload_api(request):
176 176
 
177 177
         group_id = group.group_id
178 178
 
179
-    if photo:
179
+    if photo and r.acquire_lock('{}:{}:{}'.format(group_id, user_id, photo.name), ex=60):
180 180
         # 写 PhotosInfo 表
181 181
         m_photo_path, ext = file_save(photo, prefix='photo', ext='jpeg')
182 182
         p_photo_path = 'photo/{}{}'.format(shortuuid.uuid(), ext)
@@ -318,7 +318,7 @@ def lensman_origin_photo_upload_api(request):
318 318
         order.reback_at = tc.utc_datetime()
319 319
         order.save()
320 320
 
321
-    if photo:
321
+    if photo and r.acquire_lock('{}:{}:{}'.format(order_id, user_id, photo.name), ex=60):
322 322
         # 写 PhotosInfo 表
323 323
         r_photo_path, ext = file_save(photo, prefix='photo', ext='jpeg')
324 324