Browse Source

Fix AppList and ModelList models/exclude parsers

Denis K 8 years ago
parent
commit
c65b66e988
1 changed files with 6 additions and 4 deletions
  1. 6 4
      jet/dashboard/modules.py

+ 6 - 4
jet/dashboard/modules.py

@@ -317,12 +317,13 @@ class AppList(DashboardModule):
         app_to_remove = []
 
         for app in app_list:
+            app_name = app.get('app_label', app.get('name', ''))
             app['models'] = filter(
-                lambda model: self.models is None or model['object_name'] in self.models or app.get('app_label', app.get('name')) + '.*' in self.models,
+                lambda model: self.models is None or ('%s.%s' % (app_name, model['object_name'])) in self.models or ('%s.*' % app_name) in self.models,
                 app['models']
             )
             app['models'] = filter(
-                lambda model: self.exclude is None or model['object_name'] not in self.exclude and app.get('app_label', app.get('name')) + '.*' not in self.exclude,
+                lambda model: self.exclude is None or (('%s.%s' % (app_name, model['object_name'])) not in self.exclude and ('%s.*' % app_name) not in self.exclude),
                 app['models']
             )
             app['models'] = list(app['models'])
@@ -389,12 +390,13 @@ class ModelList(DashboardModule):
         models = []
 
         for app in app_list:
+            app_name = app.get('app_label', app.get('name', ''))
             app['models'] = filter(
-                lambda model: self.models is None or model['object_name'] in self.models or app.get('app_label', app.get('name')) + '.*' in self.models,
+                lambda model: self.models is None or ('%s.%s' % (app_name, model['object_name'])) in self.models or ('%s.*' % app_name) in self.models,
                 app['models']
             )
             app['models'] = filter(
-                lambda model: self.exclude is None or model['object_name'] not in self.exclude and app.get('app_label', app.get('name')) + '.*' not in self.exclude,
+                lambda model: self.exclude is None or (('%s.%s' % (app_name, model['object_name'])) not in self.exclude and ('%s.*' % app_name) not in self.exclude),
                 app['models']
             )
             app['models'] = list(app['models'])