Commit 0e9039cf by Oláh István Gergely

dashboard: fix GroupList

parent 656289ad
...@@ -981,17 +981,15 @@ class NodeList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView): ...@@ -981,17 +981,15 @@ class NodeList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
class GroupList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView): class GroupList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
template_name = "dashboard/group-list.html" template_name = "dashboard/group-list.html"
modul = Group
table_class = GroupListTable table_class = GroupListTable
table_pagination = False table_pagination = False
def get(self, *args, **kwargs): def get(self, *args, **kwargs):
user = self.request.user
if self.request.is_ajax(): if self.request.is_ajax():
groups = [] pks = [i[0] for i in GroupProfile.get_objects_with_level(
if user.has_module_perms('auth'): 'operator', self.request.user).values_list('pk')]
pks = [i[0] for i in GroupProfile.get_objects_with_level( groups = Group.objects.filter(groupprofile__in=pks)
'operator', user).values_list('pk')]
groups = Group.objects.filter(groupprofile__in=pks)
groups = [{ groups = [{
'url': reverse("dashboard.views.group-detail", 'url': reverse("dashboard.views.group-detail",
kwargs={'pk': i.pk}), kwargs={'pk': i.pk}),
...@@ -1004,14 +1002,11 @@ class GroupList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView): ...@@ -1004,14 +1002,11 @@ class GroupList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
return super(GroupList, self).get(*args, **kwargs) return super(GroupList, self).get(*args, **kwargs)
def get_queryset(self): def get_queryset(self):
user = self.request.user
logger.debug('GroupList.get_queryset() called. User: %s', logger.debug('GroupList.get_queryset() called. User: %s',
unicode(self.request.user)) unicode(self.request.user))
groups = [] pks = [i[0] for i in GroupProfile.get_objects_with_level(
if user.has_module_perms('auth'): 'operator', self.request.user).values_list('pk')]
pks = [i[0] for i in GroupProfile.get_objects_with_level( groups = Group.objects.filter(groupprofile__in=pks)
'operator', user).values_list('pk')]
groups = Group.objects.filter(groupprofile__in=pks)
s = self.request.GET.get("s") s = self.request.GET.get("s")
if s: if s:
groups = groups.filter(name__icontains=s) groups = groups.filter(name__icontains=s)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment