kopia lustrzana https://github.com/wagtail/wagtail
Add a page_type_display_name shortcut property
rodzic
b5a84ca46c
commit
a3b1cb6c28
|
@ -170,6 +170,8 @@ In addition to the model fields provided, ``Page`` has many properties and metho
|
|||
|
||||
.. autoattribute:: cached_content_type
|
||||
|
||||
.. autoattribute:: page_type_display_name
|
||||
|
||||
.. automethod:: get_url
|
||||
|
||||
.. automethod:: get_full_url
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<a href="{% url 'wagtailadmin_explore' revision.content_object.get_parent.id %}">{{ revision.content_object.get_parent.specific_deferred.get_admin_display_title }}</a>
|
||||
</td>
|
||||
<td class="type" valign="top">
|
||||
{{ revision.content_object.content_type.model_class.get_verbose_name }}
|
||||
{{ revision.content_object.page_type_display_name }}
|
||||
</td>
|
||||
<td valign="top">
|
||||
<div class="human-readable-date" title="{{ revision.created_at|date:"DATETIME_FORMAT" }}">{% blocktrans trimmed with time_period=revision.created_at|timesince_simple %}{{ time_period }}{% endblocktrans %} </div>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<td class="updated" valign="bottom">{% if parent_page.latest_revision_created_at %}<div class="human-readable-date" title="{{ parent_page.latest_revision_created_at|date:"DATETIME_FORMAT" }}">{% blocktrans trimmed with time_period=parent_page.latest_revision_created_at|timesince %}{{ time_period }} ago{% endblocktrans %}</div>{% endif %}</td>
|
||||
<td class="type" valign="bottom">
|
||||
{% if not parent_page.is_root %}
|
||||
{{ parent_page.content_type.model_class.get_verbose_name }}
|
||||
{{ parent_page.page_type_display_name }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="status" valign="bottom">
|
||||
|
@ -69,7 +69,7 @@
|
|||
</td>
|
||||
{% endif %}
|
||||
<td class="updated" valign="top">{% if page.latest_revision_created_at %}<div class="human-readable-date" title="{{ page.latest_revision_created_at|date:"DATETIME_FORMAT" }}">{% blocktrans trimmed with time_period=page.latest_revision_created_at|timesince %}{{ time_period }} ago{% endblocktrans %}</div>{% endif %}</td>
|
||||
<td class="type" valign="top">{{ page.content_type.model_class.get_verbose_name }}</td>
|
||||
<td class="type" valign="top">{{ page.page_type_display_name }}</td>
|
||||
<td class="status" valign="top">
|
||||
{% include "wagtailadmin/shared/page_status_tag.html" with page=page %}
|
||||
</td>
|
||||
|
|
|
@ -57,9 +57,7 @@
|
|||
{% endif %}
|
||||
<td class="updated">{% if page.latest_revision_created_at %}<div class="human-readable-date" title="{{ page.latest_revision_created_at|date:"DATETIME_FORMAT" }}">{% blocktrans trimmed with time_period=page.latest_revision_created_at|timesince %}{{ time_period }} ago{% endblocktrans %}</div>{% endif %}</td>
|
||||
<td class="type">
|
||||
{% if not page.is_root %}
|
||||
{{ page.content_type.model_class.get_verbose_name }}
|
||||
{% endif %}
|
||||
{{ page.page_type_display_name }}
|
||||
</td>
|
||||
<td class="status">
|
||||
{% if not page.is_root %}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{{ page.content_type.model_class.get_verbose_name }}
|
||||
{{ page.page_type_display_name }}
|
||||
</td>
|
||||
<td>
|
||||
{% include "wagtailadmin/shared/page_status_tag.html" with page=page %}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{{ page.content_type.model_class.get_verbose_name }}
|
||||
{{ page.page_type_display_name }}
|
||||
</td>
|
||||
<td>
|
||||
{% include "wagtailadmin/shared/page_status_tag.html" with page=page %}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{{ page.content_type.model_class.get_verbose_name }}
|
||||
{{ page.page_type_display_name }}
|
||||
</td>
|
||||
<td>
|
||||
{% include "wagtailadmin/shared/page_status_tag.html" with page=page %}
|
||||
|
|
|
@ -805,6 +805,16 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
|
|||
"""
|
||||
return ContentType.objects.get_for_id(self.content_type_id)
|
||||
|
||||
@property
|
||||
def page_type_display_name(self):
|
||||
"""
|
||||
A human-readable version of this page's type
|
||||
"""
|
||||
if not self.specific_class or self.is_root():
|
||||
return ""
|
||||
else:
|
||||
return self.specific_class.get_verbose_name()
|
||||
|
||||
@property
|
||||
def localized_draft(self):
|
||||
"""
|
||||
|
|
Ładowanie…
Reference in New Issue