瀏覽代碼

限制重复添加路径

peng 2 年之前
父節點
當前提交
1129d92c96
共有 1 個文件被更改,包括 10 次插入7 次删除
  1. 10 7
      controller/LangAVSSController.py

+ 10 - 7
controller/LangAVSSController.py

@@ -118,13 +118,16 @@ class LangAVSSView(TemplateView):
                         for location in locations:
                         for location in locations:
                             # print(location['filename'])
                             # print(location['filename'])
                             # print(location['line'])
                             # print(location['line'])
-
-                            locationValue = {
-                                'lk': lkModel,
-                                'filename': location['filename'],
-                                'line': location['line']
-                            }
-                            LangLocationModel.objects.create(**locationValue)
+                            langlocaltionmodel = LangLocationModel.objects.filter(lk=lkModel, filename=location['filename'])
+                            if langlocaltionmodel.exists():
+                                langlocaltionmodel.update(line=location['line'])
+                            else:
+                                locationValue = {
+                                    'lk': lkModel,
+                                    'filename': location['filename'],
+                                    'line': location['line']
+                                }
+                                LangLocationModel.objects.create(**locationValue)
             return response.json(0)
             return response.json(0)
         else:
         else:
             return response.json(444)
             return response.json(444)