:art: Fix Brand Not Found

huangqimin vor 5 Jahren
Ursprung
Commit
3a060a4b31
1 geänderte Dateien mit 5 neuen Zeilen und 5 gelöschten Zeilen
  1. 5 5
      api/mch_views.py

+ 5 - 5
api/mch_views.py

@@ -216,7 +216,7 @@ def consumer_info_api(request):
216 216
     encryptedData = request.POST.get('encryptedData', '')
217 217
     lat = request.POST.get('lat', .0)
218 218
     lon = request.POST.get('lon', .0)
219
-    brandID = request.POST.get('BrandID', '')
219
+    brandID = request.POST.get('brand_id', '') or request.POST.get('BrandID', '')
220 220
     modelID = request.POST.get('ModelID', '')
221 221
     distributorID = request.POST.get('DistributorID', '')
222 222
     serialNo = request.POST.get('SerialNo', '')
@@ -241,17 +241,17 @@ def consumer_info_api(request):
241 241
     user.save()
242 242
 
243 243
     try:
244
-        brand = BrandInfo.objects.get(pk=brandID)
244
+        brand = BrandInfo.objects.get(brand_id=brandID)
245 245
     except BrandInfo.DoesNotExist:
246 246
         brand = None
247
-    except ValueError:
248
-        brand = None
249 247
 
250 248
     if not brand:
251 249
         try:
252
-            brand = BrandInfo.objects.get(brand_id=brandID)
250
+            brand = BrandInfo.objects.get(pk=brandID)
253 251
         except BrandInfo.DoesNotExist:
254 252
             return response(ProductBrandStatusCode.BRAND_NOT_FOUND)
253
+        except ValueError:
254
+            return response(ProductBrandStatusCode.BRAND_NOT_FOUND)
255 255
 
256 256
     try:
257 257
         model = ModelInfo.objects.get(pk=modelID)