'view restrictions' renamed 'privacy' and general wagtail styling of privacy status completed

This commit is contained in:
Dave Cranwell 2014-06-10 14:33:08 +01:00 committed by Matt Westcott
parent 9e94c83843
commit ff33a00deb
25 changed files with 161 additions and 155 deletions

View file

@ -78,9 +78,9 @@ class PasswordResetForm(PasswordResetForm):
class PageViewRestrictionForm(forms.Form):
restriction_type = forms.ChoiceField(choices=[
('none', ugettext_lazy("This page is viewable by all visitors")),
('password', ugettext_lazy("This page is only viewable to users who enter this password:")),
restriction_type = forms.ChoiceField(label="Visibility", choices=[
('none', ugettext_lazy("Public")),
('password', ugettext_lazy("Private, accessible with the following password")),
], widget=forms.RadioSelect)
password = forms.CharField(required=False)

View file

@ -0,0 +1,18 @@
$(function() {
/* Interface to set permissions from the explorer / editor */
$('a.action-set-privacy').click(function() {
ModalWorkflow({
'url': this.href,
'responses': {
'setPermission': function(isPublic) {
if (isPublic) {
$('.privacy-indicator').removeClass('private').addClass('public');
} else {
$('.privacy-indicator').removeClass('public').addClass('private');
}
}
}
});
return false;
});
});

View file

@ -1,18 +0,0 @@
$(function() {
/* Interface to set view permissions from the explorer / editor */
$('a.action-set-view-permissions').click(function() {
ModalWorkflow({
'url': this.href,
'responses': {
'setPermission': function(isPublic) {
if (isPublic) {
$('.view-permission-indicator').removeClass('private').addClass('public');
} else {
$('.view-permission-indicator').removeClass('public').addClass('private');
}
}
}
});
return false;
});
});

View file

@ -121,8 +121,8 @@
color:lighten($color-grey-2,30%);
-webkit-font-smoothing: auto;
font-size:0.80em;
margin:0 0.5em;
background:white url("#{$static-root}bg-dark-diag.svg");
margin:0 0.5em 0.5em;
background:white url( "#{$static-root}bg-dark-diag.svg");
&.primary{
color:$color-grey-2;
@ -136,6 +136,20 @@ a.status-tag.primary:hover{
color:$color-teal;
}
.privacy-indicator {
&.public {
.label-private {
display: none;
}
}
&.private {
.label-public {
display: none;
}
}
}
/* free tagging tags from taggit */
.tag{
background-color:$color-teal;
@ -174,6 +188,7 @@ a.tag:hover{
}
}
/* make a block-level element inline */
.inline{
display:inline;

View file

@ -69,6 +69,10 @@ input, textarea, select, .richtext, .tagit{
outline:none;
background-color:$color-input-focus;
}
&:disabled, &[disabled], &:disabled:hover, &[disabled]:hover{
background-color:inherit;
cursor:not-allowed;
}
}
/* select boxes */
@ -135,6 +139,7 @@ input[type=radio]:before{
display:block;
content:"K";
width: 1em;
height:1em;
line-height: 1.1em;
padding: 4px;
background-color: white;
@ -741,6 +746,7 @@ input[type=submit], input[type=reset], input[type=button], .button, button{
.choice_field &,
.model_multiple_choice_field &,
.boolean_field &,
.choice_field &,
.model_choice_field &,
.image_field &,
.file_field &{

View file

@ -5,6 +5,10 @@ header{
margin-bottom:2em;
color:white;
a{
color:white;
}
h1, h2{
margin:0;
color:white;
@ -97,12 +101,6 @@ header{
}
}
.page-explorer header{
margin-bottom:0;
padding-bottom:0em;
}
@media screen and (min-width: $breakpoint-mobile){
header{
padding-top:1.5em;

View file

@ -379,6 +379,11 @@ table.listing{
}
}
.privacy-indicator{
font-size:0.9em;
opacity:0.7;
}
.table-headers{
.ord{
padding-right:0;

View file

@ -1,8 +0,0 @@
.view-permission-indicator {
&.public {
.label-private { display: none; }
}
&.private {
.label-public { display: none; }
}
}

View file

@ -452,15 +452,6 @@ input[type="submit"] {
*overflow: visible; /* 4 */
}
/**
* Re-set default cursor for disabled elements.
*/
button[disabled],
html input[disabled] {
cursor: default;
}
/**
* 1. Address box sizing set to content-box in IE 8/9.
* 2. Remove excess padding in IE 8/9.

View file

@ -0,0 +1,8 @@
{% load i18n %}
{% trans "Page privacy" as title_str %}
{% include "wagtailadmin/shared/header.html" with title=title_str icon="locked" %}
<div class="nice-padding">
<p>{% trans "This page has been made private by a parent page." %}</p>
<p>{% trans "You can edit the privacy settings on:" %} <a href="{% url 'wagtailadmin_pages_edit' page_with_restriction.id %}">{{ page_with_restriction.title }}</a>
</div>

View file

@ -0,0 +1,16 @@
{% load i18n %}
{% trans "Page privacy" as title_str %}
{% include "wagtailadmin/shared/header.html" with title=title_str icon="locked" %}
<div class="nice-padding">
<p>{% trans "<b>Note:</b> privacy changes apply to all children of this page too." %}</p>
<form action="{% url 'wagtailadmin_pages_set_privacy' page.id %}" method="POST">
{% csrf_token %}
<ul class="fields">
{% include "wagtailadmin/shared/field_as_li.html" with field=form.restriction_type %}
{% include "wagtailadmin/shared/field_as_li.html" with field=form.password li_classes="password-field" %}
</ul>
<input type="submit" value="Save" />
</form>
</div>

View file

@ -1,8 +0,0 @@
{% load i18n %}
{% trans "Access restricted" as title_str %}
{% include "wagtailadmin/shared/header.html" with title=title_str %}
<div class="nice-padding">
{% trans "Access to this page is restricted because it is within the section:" %}
<b>{{ page_with_restriction.title }}</b>
</div>

View file

@ -1,31 +0,0 @@
{% load i18n %}
{% trans "Set access restrictions" as title_str %}
{% include "wagtailadmin/shared/header.html" with title=title_str %}
<div class="nice-padding">
<form action="{% url 'wagtailadmin_pages_set_view_restrictions' page.id %}" method="POST">
{% csrf_token %}
<ul>
<li>
{# 'This page is viewable by all visitors' #}
{{ form.restriction_type.0 }}
</li>
<li>
{# 'This page is only viewable to users who enter this password:' #}
{{ form.restriction_type.1 }}
{# FIXME: need distinct CSS styling for the 'disabled' state #}
{{ form.password }}
{% if form.password.errors %}
<p class="error-message">
{% for error in form.password.errors %}
<span>{{ error }}</span>
{% endfor %}
</p>
{% endif %}
</li>
</ul>
<input type="submit" value="Set restriction">
</form>
<p>{% trans "Access restrictions will take effect on this page and all child pages." %}</p>
</div>

View file

@ -7,7 +7,6 @@
{% compress css %}
<link rel="stylesheet" href="{{ STATIC_URL }}wagtailadmin/scss/layouts/page-editor.scss" type="text/x-scss" />
<link rel="stylesheet" href="{{ STATIC_URL }}wagtailadmin/scss/panels/rich-text.scss" type="text/x-scss" />
<link rel="stylesheet" type="text/x-scss" href="{{ STATIC_URL }}wagtailadmin/scss/components/view-permission-indicator.scss">
{# we'll want tag-it included, for the benefit of any modals that use it, like images. #}
{# TODO: a method of injecting these sorts of things on demand when the modal is spawned #}

View file

@ -21,7 +21,7 @@
<script src="{{ STATIC_URL }}wagtailadmin/js/page-editor.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/page-chooser.js"></script>
<script src="{{ STATIC_URL }}admin/js/urlify.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/view-permission-indicator.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/privacy-indicator.js"></script>
{% hook_output 'insert_editor_js' %}
{% endcompress %}

View file

@ -0,0 +1,23 @@
{% load i18n wagtailadmin_tags %}
{% test_page_is_public page as is_public %}
{% if not page_perms %}
{% page_permissions page as page_perms %}
{% endif %}
<div class="privacy-indicator {% if is_public %}public{% else %}private{% endif %}">
{% trans "Privacy" %}
{% if page_perms.can_set_view_restrictions %}
<a href="{% url 'wagtailadmin_pages_set_privacy' page.id %}" class="status-tag primary action-set-privacy">
{# labels are shown/hidden in CSS according to the 'private' / 'public' class on view-permission-indicator #}
<span class="label-public icon icon-unlocked">{% trans 'Public' %}</span>
<span class="label-private icon icon-locked">{% trans 'Private' %}</span>
</a>
{% else %}
{% if is_public %}
<span class="label-public status-tag primary icon icon-unlocked ">{% trans 'Public' %}</span>
{% else %}
<span class="label-private status-tag primary icon icon-locked">{% trans 'Private' %}</span>
{% endif %}
{% endif %}
</div>

View file

@ -1,23 +0,0 @@
{% load i18n wagtailadmin_tags %}
{% test_page_is_public page as is_public %}
{% if not page_perms %}
{% page_permissions page as page_perms %}
{% endif %}
{% if page_perms.can_set_view_restrictions %}
<div class="view-permission-indicator {% if is_public %}public{% else %}private{% endif %}">
<a href="{% url 'wagtailadmin_pages_set_view_restrictions' page.id %}" class="button button-small action-set-view-permissions">
{# labels are shown/hidden in CSS according to the 'private' / 'public' class on view-permission-indicator #}
<span class="label-public">{% trans 'Public' %}</span>
<span class="label-private">{% trans 'Private' %}</span>
</a>
</div>
{% else %}
{# Read-only display, for users who don't have permission to set view restrictions #}
{% if is_public %}
<div class="view-permission-indicator public"><span class="label-public">{% trans 'Public' %}</span></div>
{% else %}
<div class="view-permission-indicator private"><span class="label-private">{% trans 'Private' %}</span></div>
{% endif %}
{% endif %}

View file

@ -15,11 +15,15 @@
<h1 class="icon icon-doc-empty-inverse">{% blocktrans with title=page.title %}Editing <span>{{ title }}</span>{% endblocktrans %}</h1>
</div>
<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 %}
{% 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 %}
{% include "wagtailadmin/pages/_privacy_indicator.html" with page=page page_perms=page_perms only %}
</div>
{% include "wagtailadmin/pages/_view_permission_indicator.html" with page=page page_perms=page_perms only %}
</div>
</header>

View file

@ -16,19 +16,12 @@
{% page_permissions parent_page as parent_page_perms %}
{% include "wagtailadmin/pages/list.html" with sortable=1 allow_navigation=1 full_width=1 parent_page=parent_page orderable=parent_page_perms.can_reorder_children %}
</form>
{% endblock %}
{% block extra_css %}
{% compress css %}
<link rel="stylesheet" type="text/x-scss" href="{{ STATIC_URL }}wagtailadmin/scss/components/view-permission-indicator.scss">
{% endcompress %}
{% endblock %}
{% block extra_js %}
{% comment %} modal-workflow is required by the view restrictions interface {% endcomment %}
<script src="{{ STATIC_URL }}wagtailadmin/js/modal-workflow.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/view-permission-indicator.js"></script>
<script src="{{ STATIC_URL }}wagtailadmin/js/privacy-indicator.js"></script>
<script type="text/javascript">
{% if ordering == 'ord' %}

View file

@ -31,30 +31,45 @@
<tr class="index {% if not parent_page.live %} inactive{% endif %} {% if moving or choosing %}{% if parent_page.can_choose %}can-choose{% endif %}{% endif %}">
<td class="title" {% if orderable %}colspan="2"{% endif %}>
{% if moving %}
{% if parent_page.can_choose %}
<h2><a href="{% url 'wagtailadmin_pages_move_confirm' page_to_move.id parent_page.id %}">{{ parent_page.title }}</a></h2>
{% else %}
<h2>{{ parent_page.title }}</h2>
{% endif %}
<h2>
{% if parent_page.can_choose %}
<a href="{% url 'wagtailadmin_pages_move_confirm' page_to_move.id parent_page.id %}">{{ parent_page.title }}</a><
{% else %}
{{ parent_page.title }}
{% endif %}
{% test_page_is_public parent_page as is_public %}
{% if not is_public %}
<span class="privacy-indicator icon icon-locked" title="This page is protected from public view"></span>
{% endif %}
</h2>
{% elif choosing %}
{% if parent_page.can_choose %}
<h2><a class="choose-page" href="#{{ parent_page.id }}" data-id="{{ parent_page.id }}" data-title="{{ parent_page.title }}" data-url="{{ parent_page.url }}">{{ parent_page.title }}</a></h2>
{% else %}
<h2>{{ parent_page.title }}</h2>
{% endif %}
<h2>
{% if parent_page.can_choose %}
<a class="choose-page" href="#{{ parent_page.id }}" data-id="{{ parent_page.id }}" data-title="{{ parent_page.title }}" data-url="{{ parent_page.url }}">{{ parent_page.title }}</a>
{% else %}
{{ parent_page.title }}
{% endif %}
{% test_page_is_public parent_page as is_public %}
{% if not is_public %}
<em>(private)</em>
{% endif %}
{% test_page_is_public parent_page as is_public %}
{% if not is_public %}
<span class="privacy-indicator icon icon-locked" title="This page is protected from public view"></span>
{% endif %}
</h2>
{% else %}
{% if parent_page_perms.can_edit and 'edit' not in hide_actions|default:'' %}
<h2><a href="{% url 'wagtailadmin_pages_edit' parent_page.id %}">{{ parent_page.title }}</a></h2>
{% else %}
<h2>{{ parent_page.title }}</h2>
{% endif %}
<h2>
{% if parent_page_perms.can_edit and 'edit' not in hide_actions|default:'' %}
<a href="{% url 'wagtailadmin_pages_edit' parent_page.id %}">{{ parent_page.title }}</a>
{% else %}
{{ parent_page.title }}
{% endif %}
{% include "wagtailadmin/pages/_view_permission_indicator.html" with page=parent_page page_perms=parent_page_perms only %}
{% test_page_is_public parent_page as is_public %}
{% if not is_public %}
<span class="privacy-indicator icon icon-locked" title="This page is protected from public view"></span>
{% endif %}
</h2>
<ul class="actions">
{% if parent_page_perms.can_edit and 'edit' not in hide_actions|default:'' %}
@ -160,11 +175,6 @@
{% else %}
{{ page.title }}
{% endif %}
{% test_page_is_public page as is_public %}
{% if not is_public %}
<em>(private)</em>
{% endif %}
{% else %}
{% if page_perms.can_edit and 'edit' not in hide_actions|default:'' %}
<a href="{% url 'wagtailadmin_pages_edit' page.id %}" title="{% trans 'Edit this page' %}">{{ page.title }}</a>
@ -172,6 +182,11 @@
{{ page.title }}
{% endif %}
{% endif %}
{% test_page_is_public page as is_public %}
{% if not is_public %}
<span class="privacy-indicator icon icon-locked" title="This page is protected from public view"></span>
{% endif %}
</h2>
{% if not moving and not choosing %}
<ul class="actions">

View file

@ -61,7 +61,10 @@ def fieldtype(bound_field):
try:
return camelcase_to_underscore(bound_field.field.__class__.__name__)
except AttributeError:
return ""
try:
return camelcase_to_underscore(bound_field.__class__.__name__)
except AttributeError:
return ""
@register.filter

View file

@ -1,7 +1,7 @@
from django.conf.urls import url
from wagtail.wagtailadmin.forms import PasswordResetForm
from wagtail.wagtailadmin.views import account, chooser, home, pages, tags, userbar, page_view_restrictions
from wagtail.wagtailadmin.views import account, chooser, home, pages, tags, userbar, page_privacy
from wagtail.wagtailcore import hooks
@ -67,7 +67,7 @@ urlpatterns += [
url(r'^pages/moderation/(\d+)/reject/$', pages.reject_moderation, name='wagtailadmin_pages_reject_moderation'),
url(r'^pages/moderation/(\d+)/preview/$', pages.preview_for_moderation, name='wagtailadmin_pages_preview_for_moderation'),
url(r'^pages/(\d+)/view_restrictions/$', page_view_restrictions.set_view_restrictions, name='wagtailadmin_pages_set_view_restrictions'),
url(r'^pages/(\d+)/privacy/$', page_privacy.set_privacy, name='wagtailadmin_pages_set_privacy'),
url(r'^choose-page/$', chooser.browse, name='wagtailadmin_choose_page'),
url(r'^choose-page/(\d+)/$', chooser.browse, name='wagtailadmin_choose_page_child'),

View file

@ -7,7 +7,7 @@ from wagtail.wagtailadmin.forms import PageViewRestrictionForm
from wagtail.wagtailadmin.modal_workflow import render_modal_workflow
@permission_required('wagtailadmin.access_admin')
def set_view_restrictions(request, page_id):
def set_privacy(request, page_id):
page = get_object_or_404(Page, id=page_id)
page_perms = page.permissions_for_user(request.user)
if not page_perms.can_set_view_restrictions():
@ -39,7 +39,7 @@ def set_view_restrictions(request, page_id):
page=page, password = form.cleaned_data['password'])
return render_modal_workflow(
request, None, 'wagtailadmin/page_view_restrictions/set_view_restrictions_done.js', {
request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', {
'is_public': (form.cleaned_data['restriction_type'] == 'none')
}
)
@ -60,7 +60,7 @@ def set_view_restrictions(request, page_id):
# display a message indicating that there is a restriction at ancestor level -
# do not provide the form for setting up new restrictions
return render_modal_workflow(
request, 'wagtailadmin/page_view_restrictions/ancestor_restriction.html', None,
request, 'wagtailadmin/page_privacy/ancestor_privacy.html', None,
{
'page_with_restriction': restriction.page,
}
@ -69,8 +69,8 @@ def set_view_restrictions(request, page_id):
# no restriction set at ancestor level - can set restrictions here
return render_modal_workflow(
request,
'wagtailadmin/page_view_restrictions/set_view_restrictions.html',
'wagtailadmin/page_view_restrictions/set_view_restrictions.js', {
'wagtailadmin/page_privacy/set_privacy.html',
'wagtailadmin/page_privacy/set_privacy.js', {
'page': page,
'form': form,
}