#255 Filter by created user
* adds new checkbox filter for all major data types wich shows only entries, where the performing user has been the initial creator of * adds help texts for checkbox filters * adds translations
This commit is contained in:
@@ -24,6 +24,7 @@ class RecordableTableFilterMixin(django_filters.FilterSet):
|
||||
widget=forms.CheckboxInput(
|
||||
attrs={
|
||||
"class": "form-check-input",
|
||||
"title": _("If activated also shows entries which have been already recorded"),
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
53
konova/filters/mixins/self_created.py
Normal file
53
konova/filters/mixins/self_created.py
Normal file
@@ -0,0 +1,53 @@
|
||||
"""
|
||||
Author: Michel Peltriaux
|
||||
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||||
Contact: ksp-servicestelle@sgdnord.rlp.de
|
||||
Created on: 06.12.22
|
||||
|
||||
"""
|
||||
import django_filters
|
||||
from django import forms
|
||||
from django.db.models import QuerySet
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class SelfCreatedTableFilterMixin(django_filters.FilterSet):
|
||||
""" A mixin for AbstractTableFilter
|
||||
|
||||
Specialized on filtering recordable model types
|
||||
|
||||
"""
|
||||
sc = django_filters.BooleanFilter(
|
||||
method='filter_show_self_created',
|
||||
label=_("Show only self created"),
|
||||
label_suffix=_(""),
|
||||
widget=forms.CheckboxInput(
|
||||
attrs={
|
||||
"class": "form-check-input",
|
||||
"title": _("If activated only shows entries which have been created by you"),
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def filter_show_self_created(self, queryset, name, value) -> QuerySet:
|
||||
""" Filters queryset depending on value of 'self_created' setting
|
||||
|
||||
Args:
|
||||
queryset ():
|
||||
name ():
|
||||
value ():
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
if value:
|
||||
return queryset.filter(
|
||||
created__user=self.user,
|
||||
)
|
||||
else:
|
||||
return queryset
|
||||
|
||||
@@ -24,6 +24,7 @@ class ShareableTableFilterMixin(django_filters.FilterSet):
|
||||
widget=forms.CheckboxInput(
|
||||
attrs={
|
||||
"class": "form-check-input",
|
||||
"title": _("If activated also shows entries which are not shared with you"),
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ from konova.filters.mixins.geo_reference import GeoReferencedTableFilterMixin
|
||||
from konova.filters.mixins.keyword import KeywordTableFilterMixin
|
||||
from konova.filters.mixins.office import ConservationOfficeTableFilterMixin, RegistrationOfficeTableFilterMixin
|
||||
from konova.filters.mixins.record import RecordableTableFilterMixin
|
||||
from konova.filters.mixins.self_created import SelfCreatedTableFilterMixin
|
||||
from konova.filters.mixins.share import ShareableTableFilterMixin
|
||||
|
||||
|
||||
@@ -46,8 +47,10 @@ class QueryTableFilter(KeywordTableFilterMixin,
|
||||
pass
|
||||
|
||||
|
||||
class CheckboxTableFilter(ShareableTableFilterMixin, RecordableTableFilterMixin):
|
||||
class CheckboxTableFilter(ShareableTableFilterMixin,
|
||||
RecordableTableFilterMixin,
|
||||
SelfCreatedTableFilterMixin):
|
||||
""" TableFilter holding different filter options for checkbox related filtering
|
||||
|
||||
"""
|
||||
pass
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user