Procházet zdrojové kódy

修复下载文件路径缺失和排序

peng před 2 roky
rodič
revize
6903c093de
1 změnil soubory, kde provedl 16 přidání a 16 odebrání
  1. 16 16
      controller/LangArea.py

+ 16 - 16
controller/LangArea.py

@@ -264,26 +264,26 @@ class LangAreaView(TemplateView):
                                                                                                     'langkeyclassmodel__clazz__name',
                                                                                                     'langvalmodel__word_val',
                                                                                                     'langlocationmodel__filename',
-                                                                                                    'langlocationmodel__line')
+                                                                                                    'langlocationmodel__line').order_by(
+            'langkeyclassmodel__clazz__name', 'word_key')
         for lkc in lkc_qs:
             # print(lkc)
             name = lkc['langkeyclassmodel__clazz__name']
-            hasClass = result.__contains__(name)
-            if hasClass is False:
-                result[name] = {}
-
             source = lkc['word_key']
-            if not result[name].__contains__(source):
-                result[name][source] = {}
-            message = result[name][source]
-
-            message['source'] = source
-            message['translation'] = lkc['langvalmodel__word_val']
-
-            # location
-            locations = []
-            locations.append({'filename': lkc['langlocationmodel__filename'], 'line': lkc['langlocationmodel__line']})
-            message['locations'] = locations
+            hasClass = result.__contains__(name)
+            if not hasClass:
+                result[name] = {source: {'source': source, 'translation': lkc['langvalmodel__word_val'], 'locations': [
+                    {'filename': lkc['langlocationmodel__filename'], 'line': lkc['langlocationmodel__line']}]}}
+            else:
+                hasKey = result[name].__contains__(source)
+                if not hasKey:
+                    result[name][source] = {'source': source, 'translation': lkc['langvalmodel__word_val'],
+                                            'locations': [
+                                                {'filename': lkc['langlocationmodel__filename'],
+                                                 'line': lkc['langlocationmodel__line']}]}
+                else:
+                    result[name][source]['locations'].append({'filename': lkc['langlocationmodel__filename'],
+                                                              'line': lkc['langlocationmodel__line']})
         print(result)
         return result