53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
|
"""
|
||
|
Author: Michel Peltriaux
|
||
|
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||
|
Contact: michel.peltriaux@sgdnord.rlp.de
|
||
|
Created on: 19.08.21
|
||
|
|
||
|
"""
|
||
|
from django.db.models import QuerySet
|
||
|
|
||
|
from compensation.filters import CompensationTableFilter
|
||
|
|
||
|
|
||
|
class EmaTableFilter(CompensationTableFilter):
|
||
|
"""
|
||
|
Since EMA and compensation are basically the same, we can reuse CompensationTableFilter and extend the MAE filter
|
||
|
in the future by inheriting.
|
||
|
"""
|
||
|
|
||
|
def _filter_show_all(self, queryset, name, value) -> QuerySet:
|
||
|
""" Filters queryset depending on value of 'show_all' setting
|
||
|
|
||
|
Args:
|
||
|
queryset ():
|
||
|
name ():
|
||
|
value ():
|
||
|
|
||
|
Returns:
|
||
|
|
||
|
"""
|
||
|
if not value:
|
||
|
return queryset.filter(
|
||
|
users__in=[self.user], # requesting user has access
|
||
|
)
|
||
|
else:
|
||
|
return queryset
|
||
|
|
||
|
def _filter_show_recorded(self, queryset, name, value) -> QuerySet:
|
||
|
""" Filters queryset depending on value of 'show_recorded' setting
|
||
|
|
||
|
Args:
|
||
|
queryset ():
|
||
|
name ():
|
||
|
value ():
|
||
|
|
||
|
Returns:
|
||
|
|
||
|
"""
|
||
|
if not value:
|
||
|
return queryset.filter(
|
||
|
recorded=None,
|
||
|
)
|
||
|
else:
|
||
|
return queryset
|