d1f43f8c64
* adds Ema model (basically Compensation inherited) * adds index view for EMAs * fixes drop-down link bug for menu 'More' in navbar * refactors some more forms to use process_request() * adds modified attribute to BaseResource for easy last_modified check * adds setting of modified attribute in all places where UserAction.EDITED is added to log * adds EMA_ACCOUNT_IDENTIFIER_LENGTH and EMA_ACCOUNT_IDENTIFIER_TEMPLATE to ema/settings.py * adds EmaAdmin to ema/admin.py * fixes wrong title in intervention detail view html for revocations * adds support for subtitle variable to BaseTable and generic_index.html * drops next_version attribute from models * adds/updates translations * adds default ordering for UserActionLogEntry * removes extra ordering in log modal rendering
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 |