mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Add auditable superuser mode (#824)
* Remove is_superuser everywhere * Session handling * List of sessions, relative timeout * Absolute timeout * Optionally pseudo-force audit comments * Fix failing tests * Add tests * Add docs * Rebsae migration * Typos * Fix tests
This commit is contained in:
@@ -3,8 +3,10 @@ from importlib import import_module
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import Resolver404, get_script_prefix, resolve
|
||||
from django.db.models import Q
|
||||
from django.utils.translation import get_language
|
||||
|
||||
from pretix.base.models.auth import StaffSession
|
||||
from pretix.base.settings import GlobalSettingsObject
|
||||
|
||||
from ..helpers.i18n import get_javascript_format, get_moment_locale
|
||||
@@ -93,10 +95,19 @@ def contextprocessor(request):
|
||||
ctx['warning_update_check_active'] = False
|
||||
gs = GlobalSettingsObject()
|
||||
ctx['global_settings'] = gs.settings
|
||||
if request.user.is_superuser:
|
||||
if request.user.is_staff:
|
||||
if gs.settings.update_check_result_warning:
|
||||
ctx['warning_update_available'] = True
|
||||
if not gs.settings.update_check_ack and 'runserver' not in sys.argv:
|
||||
ctx['warning_update_check_active'] = True
|
||||
|
||||
if request.user.is_authenticated:
|
||||
ctx['staff_session'] = request.user.has_active_staff_session(request.session.session_key)
|
||||
ctx['staff_need_to_explain'] = (
|
||||
StaffSession.objects.filter(user=request.user, date_end__isnull=False).filter(
|
||||
Q(comment__isnull=True) | Q(comment="")
|
||||
)
|
||||
if request.user.is_staff and settings.PRETIX_ADMIN_AUDIT_COMMENTS else StaffSession.objects.none()
|
||||
)
|
||||
|
||||
return ctx
|
||||
|
||||
Reference in New Issue
Block a user