mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-30 01:46:24 +01:00
Add logging to redirects
This commit is contained in:
parent
ba825e2346
commit
759234e3d2
@ -32,6 +32,9 @@ class Redirect(models.Model):
|
||||
def title(self):
|
||||
return self.old_path
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
@property
|
||||
def link(self):
|
||||
if self.redirect_page:
|
||||
|
@ -24,6 +24,7 @@ from wagtail.contrib.redirects.permissions import permission_policy
|
||||
from wagtail.contrib.redirects.utils import (
|
||||
get_file_storage, get_format_cls_by_extension, get_import_formats, get_supported_extensions,
|
||||
write_to_file_storage)
|
||||
from wagtail.core.log_actions import log
|
||||
|
||||
|
||||
permission_checker = PermissionPolicyChecker(permission_policy)
|
||||
@ -85,6 +86,7 @@ def edit(request, redirect_id):
|
||||
form = RedirectForm(request.POST, request.FILES, instance=theredirect)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
log(instance=theredirect, action='wagtail.edit')
|
||||
messages.success(request, _("Redirect '{0}' updated.").format(theredirect.title), buttons=[
|
||||
messages.button(reverse('wagtailredirects:edit', args=(theredirect.id,)), _('Edit'))
|
||||
])
|
||||
@ -111,6 +113,7 @@ def delete(request, redirect_id):
|
||||
raise PermissionDenied
|
||||
|
||||
if request.method == 'POST':
|
||||
log(instance=theredirect, action='wagtail.delete')
|
||||
theredirect.delete()
|
||||
messages.success(request, _("Redirect '{0}' deleted.").format(theredirect.title))
|
||||
return redirect('wagtailredirects:index')
|
||||
@ -126,6 +129,7 @@ def add(request):
|
||||
form = RedirectForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
theredirect = form.save()
|
||||
log(instance=theredirect, action='wagtail.edit')
|
||||
|
||||
messages.success(request, _("Redirect '{0}' added.").format(theredirect.title), buttons=[
|
||||
messages.button(reverse('wagtailredirects:edit', args=(theredirect.id,)), _('Edit'))
|
||||
@ -333,7 +337,8 @@ def create_redirects_from_dataset(dataset, config):
|
||||
errors.append([from_link, to_link, error])
|
||||
continue
|
||||
|
||||
form.save()
|
||||
redirect = form.save()
|
||||
log(instance=redirect, action='wagtail.create')
|
||||
successes += 1
|
||||
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user