Commit 4736dc22 by Oláh István Gergely

dashboard: fix in GroupList

parent e856cd60
...@@ -955,12 +955,39 @@ class NodeList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView): ...@@ -955,12 +955,39 @@ class NodeList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
number_of_VMs=Count('instance_set')).select_related('host') number_of_VMs=Count('instance_set')).select_related('host')
class GroupList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView): class GroupList(LoginRequiredMixin, SingleTableView):
template_name = "dashboard/group-list.html" template_name = "dashboard/group-list.html"
model = Group modul = Group
table_class = GroupListTable table_class = GroupListTable
table_pagination = False table_pagination = False
def get(self, *args, **kwargs):
if self.request.is_ajax():
pks = [i[0] for i in GroupProfile.get_objects_with_level(
'operator', self.request.user).values_list('pk')]
groups = Group.objects.filter(groupprofile__in=pks)
groups = [{
'url': reverse("dashboard.views.group-detail",
kwargs={'pk': i.pk}),
'name': i.name} for i in groups]
return HttpResponse(
json.dumps(list(groups)),
content_type="application/json",
)
else:
return super(GroupList, self).get(*args, **kwargs)
def get_queryset(self):
logger.debug('GroupList.get_queryset() called. User: %s',
unicode(self.request.user))
pks = [i[0] for i in GroupProfile.get_objects_with_level(
'operator', self.request.user).values_list('pk')]
groups = Group.objects.filter(groupprofile__in=pks)
s = self.request.GET.get("s")
if s:
groups = groups.filter(name__icontains=s)
return groups
class GroupRemoveUserView(CheckedDetailView, DeleteView): class GroupRemoveUserView(CheckedDetailView, DeleteView):
model = Group model = Group
......
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