Commit b2eb2f5a by Kálmán Viktor

dashboard: fix vm list filter

parent 1e2a59ed
...@@ -1133,9 +1133,9 @@ class VmResourcesForm(forms.ModelForm): ...@@ -1133,9 +1133,9 @@ class VmResourcesForm(forms.ModelForm):
vm_search_choices = ( vm_search_choices = (
(0, _("owned")), ("owned", _("owned")),
(1, _("shared")), ("shared", _("shared")),
(2, _("all")), ("all", _("all")),
) )
...@@ -1154,5 +1154,5 @@ class VmListSearchForm(forms.Form): ...@@ -1154,5 +1154,5 @@ class VmListSearchForm(forms.Form):
# set initial value, otherwise it would be overwritten by request.GET # set initial value, otherwise it would be overwritten by request.GET
if not self.data.get("stype"): if not self.data.get("stype"):
data = self.data.copy() data = self.data.copy()
data['stype'] = 2 data['stype'] = "all"
self.data = data self.data = data
...@@ -262,7 +262,7 @@ $(function () { ...@@ -262,7 +262,7 @@ $(function () {
$("#dashboard-vm-search-form").submit(function() { $("#dashboard-vm-search-form").submit(function() {
var vm_list_items = $("#dashboard-vm-list .list-group-item"); var vm_list_items = $("#dashboard-vm-list .list-group-item");
if(vm_list_items.length == 1) { if(vm_list_items.length == 1 && vm_list_items.first().prop("href")) {
window.location.href = vm_list_items.first().prop("href"); window.location.href = vm_list_items.first().prop("href");
return false; return false;
} }
......
...@@ -1611,9 +1611,9 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView): ...@@ -1611,9 +1611,9 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
def create_default_queryset(self): def create_default_queryset(self):
cleaned_data = self.search_form.cleaned_data cleaned_data = self.search_form.cleaned_data
stype = cleaned_data.get('stype', 2) stype = cleaned_data.get('stype', "all")
superuser = stype == 2 superuser = stype == "all"
shared = stype == 1 shared = stype == "shared"
level = "owner" if stype == 0 else "user" level = "owner" if stype == 0 else "user"
queryset = Instance.get_objects_with_level( queryset = Instance.get_objects_with_level(
level, self.request.user, level, self.request.user,
......
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