Add field has_watermark for GroupPhotoInfo

Brightcells 7 年 前
コミット
3b92e37156
共有7 個のファイルを変更した51 個の追加24 個の削除を含む
  1. 2 2
      group/admin.py
  2. 1 0
      group/lensman_views.py
  3. 20 0
      group/migrations/0036_groupphotoinfo_has_watermark.py
  4. 1 0
      group/models.py
  5. 1 0
      group/views.py
  6. 23 19
      photo/views.py
  7. 3 3
      requirements.txt

+ 2 - 2
group/admin.py

@@ -17,8 +17,8 @@ class GroupUserInfoAdmin(admin.ModelAdmin):
17 17
 
18 18
 
19 19
 class GroupPhotoInfoAdmin(admin.ModelAdmin):
20
-    list_display = ('photo_id', 'group_id', 'user_id', 'nickname', 'photo_path', 'photo_thumbnail_path', 'photo_thumbnail2_path', 'status', 'created_at', 'updated_at')
21
-    list_filter = ('photo_from', 'status')
20
+    list_display = ('photo_id', 'group_id', 'user_id', 'nickname', 'photo_path', 'has_watermark', 'photo_thumbnail_path', 'photo_thumbnail2_path', 'status', 'created_at', 'updated_at')
21
+    list_filter = ('has_watermark', 'photo_from', 'status')
22 22
 
23 23
 
24 24
 class GroupPhotoOrderInfoAdmin(admin.ModelAdmin):

+ 1 - 0
group/lensman_views.py

@@ -171,6 +171,7 @@ def lensman_photo_upload_api(request):
171 171
                 'nickname': user.final_nickname,
172 172
                 'avatar': user.avatar,
173 173
                 'photo_path': photo_info.photo_watermark_path,
174
+                'has_watermark': True,
174 175
                 'photo_w': photo_info.photo_w,
175 176
                 'photo_h': photo_info.photo_h,
176 177
                 'photo_thumbnail_path': photo_info.photo_thumbnail_path,

+ 20 - 0
group/migrations/0036_groupphotoinfo_has_watermark.py

@@ -0,0 +1,20 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.3 on 2017-08-21 03:13
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', '0035_groupuserinfo_admin_status'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.AddField(
16
+            model_name='groupphotoinfo',
17
+            name='has_watermark',
18
+            field=models.BooleanField(db_index=True, default=False, help_text='\u662f\u5426\u6709\u6c34\u5370', verbose_name='has_watermark'),
19
+        ),
20
+    ]

+ 1 - 0
group/models.py

@@ -228,6 +228,7 @@ class GroupPhotoInfo(CreateUpdateMixin):
228 228
     photo_md5 = models.CharField(_(u'photo_md5'), max_length=255, blank=True, null=True, help_text=u'照片 MD5', db_index=True)
229 229
 
230 230
     photo_path = models.CharField(_(u'photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径')
231
+    has_watermark = models.BooleanField(_(u'has_watermark'), default=False, help_text=_(u'是否有水印'), db_index=True)
231 232
     photo_w = models.IntegerField(_(u'photo_w'), default=0, help_text=u'照片宽度')
232 233
     photo_h = models.IntegerField(_(u'photo_h'), default=0, help_text=u'照片高度')
233 234
 

+ 1 - 0
group/views.py

@@ -289,6 +289,7 @@ def flyimg_upload_api(request):
289 289
                 'nickname': nickname or user.final_nickname,
290 290
                 'avatar': user.avatar,
291 291
                 'photo_path': photo_info.photo_path,
292
+                'has_watermark': False,
292 293
                 'photo_w': photo_info.photo_w,
293 294
                 'photo_h': photo_info.photo_h,
294 295
                 'photo_thumbnail_path': photo_info.photo_thumbnail_path,

+ 23 - 19
photo/views.py

@@ -181,26 +181,30 @@ def session_join_api(request):
181 181
             photo_info = file_save(photo_path=photo.p_photo_path, prefix='photo', ext='.jpeg', thumbnail=True)
182 182
 
183 183
             # 群组照片记录创建
184
-            group_photo = GroupPhotoInfo.objects.create(
184
+            group_photo, created = GroupPhotoInfo.objects.get_or_create(
185 185
                 group_id=group_id,
186
-                user_id=lensman_id,
187
-                nickname=lensman.final_nickname,
188
-                avatar=lensman.avatar,
189
-                photo_path=photo_info.photo_path,
190
-                photo_w=photo_info.photo_w,
191
-                photo_h=photo_info.photo_h,
192
-                photo_thumbnail_path=photo_info.photo_thumbnail_path,
193
-                photo_thumbnail_w=photo_info.photo_thumbnail_w,
194
-                photo_thumbnail_h=photo_info.photo_thumbnail_h,
195
-                photo_thumbnail2_path=photo_info.photo_thumbnail2_path,
196
-                photo_thumbnail2_w=photo_info.photo_thumbnail2_w,
197
-                photo_thumbnail2_h=photo_info.photo_thumbnail2_h,
198
-                photo_from=GroupPhotoInfo.SESSION_GROUP,
199
-                session_id=photo.session_id,
200
-                lensman_id=photo.lensman_id,
201
-                lensman_photo_id=photo.photo_id,
202
-                nomark=price_info.get('nomark', 999),
203
-                origin=price_info.get('origin', 999),
186
+                user_id=user_id,
187
+                photo_md5=photo_info.photo_md5,
188
+                defaults={
189
+                    'nickname': user.final_nickname,
190
+                    'avatar': user.avatar,
191
+                    'photo_path': photo_info.photo_watermark_path,
192
+                    'has_watermark': True,
193
+                    'photo_w': photo_info.photo_w,
194
+                    'photo_h': photo_info.photo_h,
195
+                    'photo_thumbnail_path': photo_info.photo_thumbnail_path,
196
+                    'photo_thumbnail_w': photo_info.photo_thumbnail_w,
197
+                    'photo_thumbnail_h': photo_info.photo_thumbnail_h,
198
+                    'photo_thumbnail2_path': photo_info.photo_thumbnail2_path,
199
+                    'photo_thumbnail2_w': photo_info.photo_thumbnail2_w,
200
+                    'photo_thumbnail2_h': photo_info.photo_thumbnail2_h,
201
+                    'photo_from': GroupPhotoInfo.SESSION_GROUP,
202
+                    'session_id': photo.session_id,
203
+                    'lensman_id': photo.lensman_id,
204
+                    'lensman_photo_id': photo.photo_id,
205
+                    'nomark': price_info.get('nomark', 999),
206
+                    'origin': price_info.get('origin', 999),
207
+                }
204 208
             )
205 209
 
206 210
         if group_photo:

+ 3 - 3
requirements.txt

@@ -1,5 +1,4 @@
1 1
 -e git+https://github.com/Brightcells/django-q.git#egg=django-q
2
--e git+https://github.com/andymccurdy/redis-py.git#egg=redis-py
3 2
 CodeConvert==2.0.4
4 3
 Django==1.8.4
5 4
 MySQL-python==1.2.5
@@ -19,7 +18,7 @@ django-rlog==1.0.7
19 18
 django-shortuuidfield==0.1.3
20 19
 django-six==1.0.2
21 20
 django-uniapi==1.0.0
22
-django-we==1.0.7
21
+django-we==1.0.10
23 22
 djangorestframework==3.6.3
24 23
 furl==1.0.0
25 24
 hiredis==0.2.0
@@ -37,8 +36,9 @@ pywe-response==1.0.1
37 36
 pywe-sign==1.0.6
38 37
 pywe-xml==1.0.0
39 38
 qiniu==7.1.4
39
+redis==2.10.6
40 40
 redis-extensions==1.1.1
41
-requests==2.18.3
41
+requests==2.18.4
42 42
 rlog==0.2
43 43
 shortuuid==0.5.0
44 44
 uWSGI==2.0.15