:art: BRAND_NOT_MATCH & image4

Kimi.Huang 5 年之前
父节点
当前提交
0b4650d2bb
共有 3 个文件被更改,包括 45 次插入2 次删除
  1. 21 0
      mch/migrations/0038_modelinfo_image4.py
  2. 20 2
      mch/models.py
  3. 4 0
      page/sale_views.py

+ 21 - 0
mch/migrations/0038_modelinfo_image4.py

@@ -0,0 +1,21 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.22 on 2019-07-21 14:13
3
+from __future__ import unicode_literals
4
+
5
+from django.db import migrations, models
6
+import django_models_ext.fileext
7
+
8
+
9
+class Migration(migrations.Migration):
10
+
11
+    dependencies = [
12
+        ('mch', '0037_modelinfo_image3'),
13
+    ]
14
+
15
+    operations = [
16
+        migrations.AddField(
17
+            model_name='modelinfo',
18
+            name='image4',
19
+            field=models.ImageField(blank=True, help_text='\u56fe\u72474', null=True, upload_to=django_models_ext.fileext.upload_path, verbose_name='image4'),
20
+        ),
21
+    ]

+ 20 - 2
mch/models.py

@@ -152,6 +152,7 @@ class ModelInfo(BaseModelMixin):
152 152
 
153 153
     image2 = models.ImageField(_(u'image2'), upload_to=upload_path, blank=True, null=True, help_text=u'图片2')
154 154
     image3 = models.ImageField(_(u'image3'), upload_to=upload_path, blank=True, null=True, help_text=u'图片3')
155
+    image4 = models.ImageField(_(u'image4'), upload_to=upload_path, blank=True, null=True, help_text=u'图片4')
155 156
 
156 157
     factory_yuan = models.FloatField(_(u'factory_yuan'), default=1000, help_text=u'出厂价(元)')
157 158
     factory_fee = models.IntegerField(_(u'factory_fee'), default=100000, help_text=u'出厂价(分)')
@@ -194,6 +195,14 @@ class ModelInfo(BaseModelMixin):
194 195
         return upload_file_url(self.image3)
195 196
 
196 197
     @property
198
+    def image4_path(self):
199
+        return upload_file_path(self.image4)
200
+
201
+    @property
202
+    def image4_url(self):
203
+        return upload_file_url(self.image4)
204
+
205
+    @property
197 206
     def images(self):
198 207
         imgs = []
199 208
         if self.image:
@@ -203,12 +212,17 @@ class ModelInfo(BaseModelMixin):
203 212
             })
204 213
         if self.image2:
205 214
             imgs.append({
206
-                'image_url2': self.image2_url,
215
+                'image_url': self.image2_url,
207 216
                 'url': self.url or '',
208 217
             })
209 218
         if self.image3:
210 219
             imgs.append({
211
-                'image_url3': self.image3_url,
220
+                'image_url': self.image3_url,
221
+                'url': self.url or '',
222
+            })
223
+        if self.image4:
224
+            imgs.append({
225
+                'image_url': self.image4_url,
212 226
                 'url': self.url or '',
213 227
             })
214 228
         return imgs
@@ -237,6 +251,10 @@ class ModelInfo(BaseModelMixin):
237 251
             'image_url': self.image_url,
238 252
             'image2_path': self.image2_path,
239 253
             'image2_url': self.image2_url,
254
+            'image3_path': self.image3_path,
255
+            'image3_url': self.image3_url,
256
+            'image4_path': self.image4_path,
257
+            'image4_url': self.image4_url,
240 258
             'factory_yuan': self.factory_yuan,
241 259
             'integral': self.integral,
242 260
         }

+ 4 - 0
page/sale_views.py

@@ -35,6 +35,7 @@ CIPHER_PREFIX = {
35 35
 @logit
36 36
 @transaction.atomic
37 37
 def clerk_sale_decrypt_api(request):
38
+    brand_id = request.POST.get('brand_id', '')
38 39
     ciphertext = request.POST.get('ciphertext', '')
39 40
 
40 41
     prefix, cipherlen, ciphertext = ciphertext.split('+', 2)
@@ -59,6 +60,9 @@ def clerk_sale_decrypt_api(request):
59 60
     except BrandInfo.DoesNotExist:
60 61
         brand = None
61 62
 
63
+    if brand and brand.brand_id != brand_id:
64
+        return response(ProductBrandStatusCode.BRAND_NOT_MATCH)
65
+
62 66
     try:
63 67
         model = ModelInfo.objects.get(pk=model_pk)
64 68
     except ModelInfo.DoesNotExist: