Merge pull request '# User filtering' (#435) from 433_Filter_by_user into master
Reviewed-on: #435
This commit is contained in:
commit
e47eda385d
55
konova/filters/mixins/user_log.py
Normal file
55
konova/filters/mixins/user_log.py
Normal file
@ -0,0 +1,55 @@
|
||||
"""
|
||||
Author: Michel Peltriaux
|
||||
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||||
Contact: ksp-servicestelle@sgdnord.rlp.de
|
||||
Created on: 19.08.24
|
||||
|
||||
"""
|
||||
import django_filters
|
||||
from django import forms
|
||||
from django.db.models import QuerySet, Q
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class UserLoggedTableFilterMixin(django_filters.FilterSet):
|
||||
ul = django_filters.CharFilter(
|
||||
method="filter_user_log",
|
||||
label=_(""),
|
||||
label_suffix=_(""),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"placeholder": _("Logged user"),
|
||||
"title": _("Search for entries where this person has been participated according to log history"),
|
||||
"class": "form-control",
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def filter_user_log(self, queryset, name, value) -> QuerySet:
|
||||
""" Filters queryset depending on value of input
|
||||
|
||||
Args:
|
||||
queryset (QuerySet): Incoming (prefiltered) queryset
|
||||
name (str): Name of input field
|
||||
value (str): Value of input field
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
value = value.replace(",", " ")
|
||||
value = value.strip()
|
||||
values = value.split(" ")
|
||||
|
||||
q = Q()
|
||||
for val in values:
|
||||
q &= (
|
||||
Q(log__user__username__icontains=val) |
|
||||
Q(log__user__first_name__icontains=val) |
|
||||
Q(log__user__last_name__icontains=val)
|
||||
)
|
||||
|
||||
queryset = queryset.filter(q)
|
||||
return queryset
|
@ -14,6 +14,7 @@ from konova.filters.mixins.office import ConservationOfficeTableFilterMixin, Reg
|
||||
from konova.filters.mixins.record import RecordableTableFilterMixin
|
||||
from konova.filters.mixins.self_created import SelfCreatedTableFilterMixin
|
||||
from konova.filters.mixins.share import ShareableTableFilterMixin
|
||||
from konova.filters.mixins.user_log import UserLoggedTableFilterMixin
|
||||
|
||||
|
||||
class AbstractTableFilter(django_filters.FilterSet):
|
||||
@ -40,7 +41,8 @@ class SelectionTableFilter(RegistrationOfficeTableFilterMixin,
|
||||
|
||||
class QueryTableFilter(KeywordTableFilterMixin,
|
||||
FileNumberTableFilterMixin,
|
||||
GeoReferencedTableFilterMixin):
|
||||
GeoReferencedTableFilterMixin,
|
||||
UserLoggedTableFilterMixin):
|
||||
""" TableFilter holding different filter options for query related filtering
|
||||
|
||||
"""
|
||||
|
Binary file not shown.
@ -29,6 +29,7 @@
|
||||
#: konova/filters/mixins/office.py:25 konova/filters/mixins/office.py:56
|
||||
#: konova/filters/mixins/office.py:57 konova/filters/mixins/record.py:23
|
||||
#: konova/filters/mixins/self_created.py:24 konova/filters/mixins/share.py:23
|
||||
#: konova/filters/mixins/user_log.py:17 konova/filters/mixins/user_log.py:18
|
||||
#: konova/forms/geometry_form.py:32 konova/forms/modals/document_form.py:26
|
||||
#: konova/forms/modals/document_form.py:36
|
||||
#: konova/forms/modals/document_form.py:50
|
||||
@ -43,7 +44,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-08-19 09:38+0200\n"
|
||||
"POT-Creation-Date: 2024-08-19 10:32+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -1786,6 +1787,17 @@ msgstr ""
|
||||
"Wenn aktiviert werden auch Einträge angezeigt, die nicht für Sie freigegeben "
|
||||
"sind"
|
||||
|
||||
#: konova/filters/mixins/user_log.py:21
|
||||
msgid "Logged user"
|
||||
msgstr "Bearbeitender Nutzer"
|
||||
|
||||
#: konova/filters/mixins/user_log.py:22
|
||||
msgid ""
|
||||
"Search for entries where this person has been participated according to log "
|
||||
"history"
|
||||
msgstr ""
|
||||
"Sucht nach Einträgen, an denen diese Person gearbeitet hat"
|
||||
|
||||
#: konova/forms/base_form.py:23 templates/form/collapsable/form.html:62
|
||||
msgid "Save"
|
||||
msgstr "Speichern"
|
||||
|
Loading…
Reference in New Issue
Block a user