add public/private indicator on explorer and page editor

This commit is contained in:
Matt Westcott 2014-06-05 11:04:37 +01:00
parent 1e71e10cd2
commit cae0d8fecb
5 changed files with 17 additions and 3 deletions

View file

@ -0,0 +1,6 @@
{% load i18n %}
{% if page.get_view_restrictions %}
<div>{% trans 'Private' %}</div>
{% else %}
<div>{% trans 'Public' %}</div>
{% endif %}

View file

@ -16,6 +16,9 @@
<div class="right col3">
{% trans "Status:" %} {% if page.live %}<a href="{{ page.url }}" class="status-tag {% if page.live %}primary{% endif %}">{{ page.status_string }}</a>{% else %}<span class="status-tag">{{ page.status_string }}</span>{% endif %}
</div>
{% include "wagtailadmin/pages/_view_permission_indicator.html" with page=page only %}
</div>
</header>

View file

@ -48,6 +48,9 @@
{% else %}
<h2>{{ parent_page.title }}</h2>
{% endif %}
{% include "wagtailadmin/pages/_view_permission_indicator.html" with page=parent_page only %}
<ul class="actions">
{% if parent_page_perms.can_edit and 'edit' not in hide_actions|default:'' %}
<li><a href="{% url 'wagtailadmin_pages_edit' parent_page.id %}" class="button button-small">{% trans 'Edit' %}</a></li>
@ -249,4 +252,4 @@
</li>
</ul>
</div>
{% endif %}
{% endif %}

View file

@ -811,6 +811,9 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, Indexed)):
def get_prev_siblings(self, inclusive=False):
return self.get_siblings(inclusive).filter(path__lte=self.path).order_by('-path')
def get_view_restrictions(self):
return PageViewRestriction.objects.filter(page__in=self.get_ancestors(inclusive=True))
password_required_template = getattr(settings, 'PASSWORD_REQUIRED_TEMPLATE', 'wagtailcore/password_required.html')
def serve_password_required_response(self, request, form, action_url):
"""

View file

@ -1,11 +1,10 @@
from django.core.urlresolvers import reverse
from wagtail.wagtailcore import hooks
from wagtail.wagtailcore.models import PageViewRestriction
from wagtail.wagtailcore.forms import PasswordPageViewRestrictionForm
def check_view_restrictions(page, request):
restrictions = PageViewRestriction.objects.filter(page__in=page.get_ancestors(inclusive=True))
restrictions = page.get_view_restrictions()
if restrictions:
passed_restrictions = request.session.get('passed_page_view_restrictions', [])