Duplicate entry

Brightcells 8 anni fa
parent
commit
b65f84e502
4 ha cambiato i file con 31 aggiunte e 4 eliminazioni
  1. 3 2
      group/lensman_views.py
  2. 23 0
      photo/migrations/0009_auto_20160907_1018.py
  3. 4 1
      photo/models.py
  4. 1 1
      requirements.txt

+ 3 - 2
group/lensman_views.py

@@ -199,9 +199,10 @@ def lensman_photo_upload_api(request):
199 199
             lensman_id=lensman_id,
200 200
             session_id=session_id,
201 201
             photo_id=photo_id,
202
-            p_photo_path=p_photo_path,
203
-            m_photo_path=m_photo_path,
204 202
         )
203
+        photo.p_photo_path = p_photo_path
204
+        photo.m_photo_path = m_photo_path
205
+        photo.save()
205 206
 
206 207
         # 写 GroupPhotoInfo 表
207 208
         photo_path = photo.p_photo_path

+ 23 - 0
photo/migrations/0009_auto_20160907_1018.py

@@ -0,0 +1,23 @@
1
+# -*- coding: utf-8 -*-
2
+from __future__ import unicode_literals
3
+
4
+from django.db import models, migrations
5
+
6
+
7
+class Migration(migrations.Migration):
8
+
9
+    dependencies = [
10
+        ('photo', '0008_auto_20160901_1439'),
11
+    ]
12
+
13
+    operations = [
14
+        migrations.AlterField(
15
+            model_name='photosinfo',
16
+            name='photo_id',
17
+            field=models.CharField(max_length=255, blank=True, help_text='\u7167\u7247\u552f\u4e00\u6807\u8bc6', null=True, verbose_name='photo_id', db_index=True),
18
+        ),
19
+        migrations.AlterUniqueTogether(
20
+            name='photosinfo',
21
+            unique_together=set([('lensman_id', 'session_id', 'photo_id')]),
22
+        ),
23
+    ]

+ 4 - 1
photo/models.py

@@ -32,7 +32,7 @@ class UUIDInfo(CreateUpdateMixin):
32 32
 class PhotosInfo(CreateUpdateMixin):
33 33
     lensman_id = models.CharField(_(u'lensman_id'), max_length=255, blank=True, null=True, help_text=u'摄影师唯一标识', db_index=True)
34 34
     session_id = models.CharField(_(u'session_id'), max_length=255, blank=True, null=True, help_text=u'照片组唯一标识', db_index=True)
35
-    photo_id = models.CharField(_(u'photo_id'), max_length=255, blank=True, null=True, help_text=u'照片唯一标识', db_index=True, unique=True)
35
+    photo_id = models.CharField(_(u'photo_id'), max_length=255, blank=True, null=True, help_text=u'照片唯一标识', db_index=True)
36 36
     p_photo_path = models.CharField(_(u'p_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,Box上传,有水印,服务器添加')
37 37
     m_photo_path = models.CharField(_(u'm_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,Box上传,无水印')
38 38
     l_photo_path = models.CharField(_(u'l_photo_path'), max_length=255, blank=True, null=True, help_text=u'照片存放路径,美化大图')
@@ -44,6 +44,9 @@ class PhotosInfo(CreateUpdateMixin):
44 44
         index_together = [
45 45
             ['lensman_id', 'session_id'],
46 46
         ]
47
+        unique_together = (
48
+            ('lensman_id', 'session_id', 'photo_id'),
49
+        )
47 50
 
48 51
     def __unicode__(self):
49 52
         return u'{0.pk}'.format(self)

+ 1 - 1
requirements.txt

@@ -25,7 +25,7 @@ pep8==1.6.2
25 25
 pytz==2015.7
26 26
 records==0.4.3
27 27
 redis==2.10.5
28
-redis-extensions==1.0.7
28
+redis-extensions==1.0.8
29 29
 rlog==0.2
30 30
 shortuuid==0.4.2
31 31
 uWSGI==2.0.11.1