kopia lustrzana https://github.com/wagtail/wagtail
Rename page_log_action_registry to wagtail.core.log_actions.registry
This reflects the fact that we only expect one registry to exist. Also, drop the need for log models to keep track of which registry they're attached to (because there's only one)pull/7535/head
rodzic
69c77be969
commit
74187b4fb4
|
|
@ -13,13 +13,13 @@ from django.utils.translation import gettext as _
|
|||
from wagtail.admin.auth import user_has_any_page_permission, user_passes_test
|
||||
from wagtail.admin.filters import DateRangePickerWidget, WagtailFilterSet
|
||||
from wagtail.admin.views.reports import ReportView
|
||||
from wagtail.core.log_actions import page_log_action_registry
|
||||
from wagtail.core.log_actions import registry as log_action_registry
|
||||
from wagtail.core.models import (
|
||||
Page, PageLogEntry, PageRevision, TaskState, UserPagePermissionsProxy, WorkflowState)
|
||||
|
||||
|
||||
class PageHistoryReportFilterSet(WagtailFilterSet):
|
||||
action = django_filters.ChoiceFilter(choices=page_log_action_registry.get_choices)
|
||||
action = django_filters.ChoiceFilter(choices=log_action_registry.get_choices)
|
||||
hide_commenting_actions = django_filters.BooleanFilter(
|
||||
label=_('Hide commenting actions'),
|
||||
method='filter_hide_commenting_actions',
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@ from django.utils.encoding import force_str
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from wagtail.admin.filters import DateRangePickerWidget, WagtailFilterSet
|
||||
from wagtail.core.log_actions import page_log_action_registry
|
||||
from wagtail.core.log_actions import registry as log_action_registry
|
||||
from wagtail.core.models import Page, PageLogEntry, UserPagePermissionsProxy
|
||||
|
||||
from .base import ReportView
|
||||
|
||||
|
||||
class SiteHistoryReportFilterSet(WagtailFilterSet):
|
||||
action = django_filters.ChoiceFilter(choices=page_log_action_registry.get_choices)
|
||||
action = django_filters.ChoiceFilter(choices=log_action_registry.get_choices)
|
||||
hide_commenting_actions = django_filters.BooleanFilter(
|
||||
label=_('Hide commenting actions'),
|
||||
method='filter_hide_commenting_actions',
|
||||
|
|
@ -93,5 +93,5 @@ class LogEntriesView(ReportView):
|
|||
).prefetch_related('page')
|
||||
|
||||
def get_action_label(self, action):
|
||||
from wagtail.core.log_actions import page_log_action_registry
|
||||
return force_str(page_log_action_registry.get_action_label(action))
|
||||
from wagtail.core.log_actions import log_action_registry
|
||||
return force_str(log_action_registry.get_action_label(action))
|
||||
|
|
|
|||
|
|
@ -93,4 +93,4 @@ class LogActionRegistry:
|
|||
return self.formatters[action].label
|
||||
|
||||
|
||||
page_log_action_registry = LogActionRegistry()
|
||||
registry = LogActionRegistry()
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ from treebeard.mp_tree import MP_Node
|
|||
|
||||
from wagtail.core.fields import StreamField
|
||||
from wagtail.core.forms import TaskStateCommentForm
|
||||
from wagtail.core.log_actions import page_log_action_registry
|
||||
from wagtail.core.query import PageQuerySet
|
||||
from wagtail.core.signals import (
|
||||
page_published, page_unpublished, post_page_move, pre_page_move, pre_validate_delete,
|
||||
|
|
@ -3998,8 +3997,6 @@ class PageLogEntry(BaseLogEntry):
|
|||
|
||||
objects = PageLogEntryManager()
|
||||
|
||||
action_registry = page_log_action_registry
|
||||
|
||||
class Meta:
|
||||
ordering = ['-timestamp', '-id']
|
||||
verbose_name = _('page log entry')
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ from django.utils import timezone
|
|||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from wagtail.core.log_actions import registry as log_action_registry
|
||||
|
||||
|
||||
class LogEntryQuerySet(models.QuerySet):
|
||||
def get_users(self):
|
||||
|
|
@ -104,8 +106,6 @@ class BaseLogEntry(models.Model):
|
|||
|
||||
objects = BaseLogEntryManager()
|
||||
|
||||
action_registry = None
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
verbose_name = _('log entry')
|
||||
|
|
@ -117,7 +117,7 @@ class BaseLogEntry(models.Model):
|
|||
return super().save(*args, **kwargs)
|
||||
|
||||
def clean(self):
|
||||
if not self.action_registry.action_exists(self.action):
|
||||
if not log_action_registry.action_exists(self.action):
|
||||
raise ValidationError({'action': _("The log action '{}' has not been registered.").format(self.action)})
|
||||
|
||||
def __str__(self):
|
||||
|
|
@ -170,7 +170,7 @@ class BaseLogEntry(models.Model):
|
|||
|
||||
@cached_property
|
||||
def formatter(self):
|
||||
return self.action_registry.get_formatter(self)
|
||||
return log_action_registry.get_formatter(self)
|
||||
|
||||
@cached_property
|
||||
def message(self):
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue