|
|
@ -17,7 +17,6 @@ from django.http.response import Http404 |
|
|
from django.shortcuts import redirect |
|
|
from django.shortcuts import redirect |
|
|
from django.utils.decorators import classonlymethod |
|
|
from django.utils.decorators import classonlymethod |
|
|
from django.utils.encoding import force_text |
|
|
from django.utils.encoding import force_text |
|
|
from sapl.translation import ugettext_lazy as _ |
|
|
|
|
|
from django.utils.translation import string_concat |
|
|
from django.utils.translation import string_concat |
|
|
from django.views.generic import (CreateView, DeleteView, DetailView, ListView, |
|
|
from django.views.generic import (CreateView, DeleteView, DetailView, ListView, |
|
|
UpdateView) |
|
|
UpdateView) |
|
|
@ -28,8 +27,10 @@ from sapl.crispy_layout_mixin import CrispyLayoutFormMixin, get_field_display |
|
|
from sapl.rules.map_rules import (RP_ADD, RP_CHANGE, RP_DELETE, RP_DETAIL, |
|
|
from sapl.rules.map_rules import (RP_ADD, RP_CHANGE, RP_DELETE, RP_DETAIL, |
|
|
RP_LIST) |
|
|
RP_LIST) |
|
|
from sapl.settings import BASE_DIR |
|
|
from sapl.settings import BASE_DIR |
|
|
|
|
|
from sapl.translation import ugettext_lazy as _ |
|
|
from sapl.utils import normalize |
|
|
from sapl.utils import normalize |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(BASE_DIR.name) |
|
|
logger = logging.getLogger(BASE_DIR.name) |
|
|
|
|
|
|
|
|
ACTION_LIST, ACTION_CREATE, ACTION_DETAIL, ACTION_UPDATE, ACTION_DELETE = \ |
|
|
ACTION_LIST, ACTION_CREATE, ACTION_DETAIL, ACTION_UPDATE, ACTION_DELETE = \ |
|
|
@ -382,6 +383,7 @@ class CrudBaseMixin(CrispyLayoutFormMixin): |
|
|
|
|
|
|
|
|
class CrudListView(PermissionRequiredContainerCrudMixin, ListView): |
|
|
class CrudListView(PermissionRequiredContainerCrudMixin, ListView): |
|
|
permission_required = (RP_LIST, ) |
|
|
permission_required = (RP_LIST, ) |
|
|
|
|
|
lookup_search = 'search__icontains' |
|
|
|
|
|
|
|
|
@classmethod |
|
|
@classmethod |
|
|
def get_url_regex(cls): |
|
|
def get_url_regex(cls): |
|
|
@ -520,7 +522,7 @@ class CrudListView(PermissionRequiredContainerCrudMixin, ListView): |
|
|
for item in query: |
|
|
for item in query: |
|
|
if not item: |
|
|
if not item: |
|
|
continue |
|
|
continue |
|
|
q = q & models.Q(search__icontains=item) |
|
|
q = q & models.Q(**{self.lookup_search: item}) |
|
|
|
|
|
|
|
|
if q: |
|
|
if q: |
|
|
queryset = queryset.filter(q) |
|
|
queryset = queryset.filter(q) |
|
|
|