Bladeren bron

限制重复添加路径

peng 2 jaren geleden
bovenliggende
commit
1129d92c96
1 gewijzigde bestanden met toevoegingen van 10 en 7 verwijderingen
  1. 10 7
      controller/LangAVSSController.py

+ 10 - 7
controller/LangAVSSController.py

@@ -118,13 +118,16 @@ class LangAVSSView(TemplateView):
                         for location in locations:
                             # print(location['filename'])
                             # 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)
         else:
             return response.json(444)