kopia lustrzana https://github.com/wagtail/wagtail
Add ReferenceIndex.get_grouped_references_to() method
rodzic
ff363dee87
commit
885b4783ee
|
@ -684,7 +684,7 @@ class DeleteView(
|
|||
def get_usage(self):
|
||||
if not self.usage_url:
|
||||
return None
|
||||
return ReferenceIndex.get_references_to(self.object).group_by_source_object()
|
||||
return ReferenceIndex.get_grouped_references_to(self.object)
|
||||
|
||||
def get_success_url(self):
|
||||
next_url = get_valid_next_url_from_request(self.request)
|
||||
|
@ -878,7 +878,7 @@ class UnpublishView(HookResponseMixin, WagtailAdminTemplateMixin, TemplateView):
|
|||
return get_object_or_404(self.model, pk=unquote(self.pk))
|
||||
|
||||
def get_usage(self):
|
||||
return ReferenceIndex.get_references_to(self.object).group_by_source_object()
|
||||
return ReferenceIndex.get_grouped_references_to(self.object)
|
||||
|
||||
def get_objects_to_unpublish(self):
|
||||
# Hook to allow child classes to have more objects to unpublish (e.g. page descendants)
|
||||
|
|
|
@ -166,7 +166,7 @@ class AbstractDocument(CollectionMember, index.Indexed, models.Model):
|
|||
return reverse("wagtaildocs_serve", args=[self.id, self.filename])
|
||||
|
||||
def get_usage(self):
|
||||
return ReferenceIndex.get_references_to(self).group_by_source_object()
|
||||
return ReferenceIndex.get_grouped_references_to(self)
|
||||
|
||||
@property
|
||||
def usage_url(self):
|
||||
|
|
|
@ -311,7 +311,7 @@ class AbstractImage(ImageFileMixin, CollectionMember, index.Indexed, models.Mode
|
|||
return full_path
|
||||
|
||||
def get_usage(self):
|
||||
return ReferenceIndex.get_references_to(self).group_by_source_object()
|
||||
return ReferenceIndex.get_grouped_references_to(self)
|
||||
|
||||
@property
|
||||
def usage_url(self):
|
||||
|
|
|
@ -482,7 +482,7 @@ class ReferenceIndex(models.Model):
|
|||
@classmethod
|
||||
def get_references_to(cls, object):
|
||||
"""
|
||||
Returns all inboud references for the given object.
|
||||
Returns all inbound references for the given object.
|
||||
|
||||
Args:
|
||||
object (Model): The model instance to fetch ReferenceIndex records for
|
||||
|
@ -495,6 +495,20 @@ class ReferenceIndex(models.Model):
|
|||
to_object_id=object.pk,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_grouped_references_to(cls, object):
|
||||
"""
|
||||
Returns all inbound references for the given object, grouped by the object
|
||||
they are found on.
|
||||
|
||||
Args:
|
||||
object (Model): The model instance to fetch ReferenceIndex records for
|
||||
|
||||
Returns:
|
||||
A ReferenceGroups object
|
||||
"""
|
||||
return cls.get_references_to(object).group_by_source_object()
|
||||
|
||||
@property
|
||||
def _content_type(self):
|
||||
# Accessing a ContentType from a ForeignKey does not make use of the
|
||||
|
|
Ładowanie…
Reference in New Issue