mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Set up a LogContext for the user on all admin views
This commit is contained in:
parent
1a0e53ba09
commit
4126aff021
@ -14,6 +14,7 @@ from django.utils.translation import gettext as _
|
||||
from django.utils.translation import override
|
||||
|
||||
from wagtail.admin import messages
|
||||
from wagtail.core.log_actions import LogContext
|
||||
from wagtail.core.models import GroupPagePermission
|
||||
|
||||
|
||||
@ -167,6 +168,7 @@ def require_admin_access(view_func):
|
||||
l18n.set_language(preferred_language)
|
||||
time_zone = user.wagtail_userprofile.get_current_time_zone()
|
||||
activate_tz(time_zone)
|
||||
with LogContext(user=user):
|
||||
if preferred_language:
|
||||
with override(preferred_language):
|
||||
response = view_func(request, *args, **kwargs)
|
||||
|
@ -18,7 +18,7 @@ from wagtail.admin import messages
|
||||
from wagtail.admin.edit_handlers import ObjectList, extract_panel_definitions_from_model_class
|
||||
from wagtail.admin.forms.search import SearchForm
|
||||
from wagtail.core import hooks
|
||||
from wagtail.core.log_actions import LogContext, log
|
||||
from wagtail.core.log_actions import log
|
||||
from wagtail.core.models import Locale, TranslatableMixin
|
||||
from wagtail.search.backends import get_search_backend
|
||||
from wagtail.search.index import class_is_indexed
|
||||
@ -212,7 +212,6 @@ def create(request, app_label, model_name):
|
||||
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
with LogContext(user=request.user):
|
||||
log(instance=instance, action='wagtail.create')
|
||||
|
||||
messages.success(
|
||||
@ -294,7 +293,7 @@ def edit(request, app_label, model_name, pk):
|
||||
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
log(instance=instance, action='wagtail.edit', user=request.user)
|
||||
log(instance=instance, action='wagtail.edit')
|
||||
|
||||
messages.success(
|
||||
request,
|
||||
@ -371,7 +370,7 @@ def delete(request, app_label, model_name, pk=None):
|
||||
|
||||
if request.method == 'POST':
|
||||
for instance in instances:
|
||||
log(instance=instance, action='wagtail.delete', user=request.user)
|
||||
log(instance=instance, action='wagtail.delete')
|
||||
instance.delete()
|
||||
|
||||
if count == 1:
|
||||
|
Loading…
Reference in New Issue
Block a user