summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauréline Guérin <zebuline@entrouvert.com>2019-10-22 07:19:06 (GMT)
committerLauréline Guérin <zebuline@entrouvert.com>2019-10-28 08:13:02 (GMT)
commitce355fa83341bc45acf032311eb82dbbdd4095e8 (patch)
treeac183723e7ad8317c731ad6c04adfe82563e962f
parent82503cdd7d6817cd4c17aaad482b7843efef3d51 (diff)
downloadcombo-ce355fa83341bc45acf032311eb82dbbdd4095e8.zip
combo-ce355fa83341bc45acf032311eb82dbbdd4095e8.tar.gz
combo-ce355fa83341bc45acf032311eb82dbbdd4095e8.tar.bz2
page: display page visibility on page list (#16028)wip/16028-page-visibility
-rw-r--r--combo/data/models.py4
-rw-r--r--combo/manager/static/css/combo.manager.css9
-rw-r--r--combo/manager/templates/combo/manager_home.html17
-rw-r--r--tests/test_manager.py22
4 files changed, 46 insertions, 6 deletions
diff --git a/combo/data/models.py b/combo/data/models.py
index a760980..88ad3b1 100644
--- a/combo/data/models.py
+++ b/combo/data/models.py
@@ -336,7 +336,9 @@ class Page(models.Model):
def visibility(self):
if self.public:
return _('Public')
- return _('Private (%s)') % ', '.join([x.name for x in self.groups.all()])
+ groups = self.groups.all()
+ groupnames = ', '.join([x.name for x in groups]) if groups else _('logged users')
+ return _('Private (%s)') % groupnames
def is_visible(self, user=None):
return element_is_visible(self, user=user)
diff --git a/combo/manager/static/css/combo.manager.css b/combo/manager/static/css/combo.manager.css
index 99d49e7..e9cc94e 100644
--- a/combo/manager/static/css/combo.manager.css
+++ b/combo/manager/static/css/combo.manager.css
@@ -53,7 +53,8 @@ div.cell > h3 {
white-space: nowrap;
}
-div.cell h3 .group1 {
+div.cell h3 .group1,
+div.page .group1 {
display: inline-block;
overflow: hidden;
white-space: nowrap;
@@ -68,7 +69,8 @@ div.cell h3 span.extra-css-class {
}
div.cell h3 span.additional-label,
-div.cell h3 span.visibility-summary {
+div.cell h3 span.visibility-summary,
+div.page span.visibility-summary {
font-size: 80%;
padding-left: 1em;
display: inline-block;
@@ -78,7 +80,8 @@ div.cell h3 span.visibility-summary {
vertical-align: middle;
}
-div.cell h3 span.visibility-summary::before {
+div.cell h3 span.visibility-summary::before,
+div.page span.visibility-summary::before {
content: "\f06e"; /* fa-eye */
font-family: FontAwesome;
}
diff --git a/combo/manager/templates/combo/manager_home.html b/combo/manager/templates/combo/manager_home.html
index 305ac61..d158b26 100644
--- a/combo/manager/templates/combo/manager_home.html
+++ b/combo/manager/templates/combo/manager_home.html
@@ -28,8 +28,21 @@ Use drag and drop with the ⣿ handles to reorder and change hierarchy of pages.
<div class="objects-list" id="pages-list" data-page-order-url="{% url 'combo-manager-page-order' %}">
{% for page in object_list %}
- <div class="level-{{page.level}}" data-page-id="{{page.id}}" data-level="{{page.level}}">
- <span class="handle">⣿</span> <a href="{% url 'combo-manager-page-view' pk=page.id %}">{{ page.title }}</a>
+ <div class="page level-{{page.level}}" data-page-id="{{page.id}}" data-level="{{page.level}}">
+ <span class="handle">⣿</span>
+ <span class="group1">
+ <a href="{% url 'combo-manager-page-view' pk=page.id %}">{{ page.title }}</a>
+ </span>
+ {% if not page.public %}
+ <span class="visibility-summary" title="{% trans 'Restricted visibility' %}">
+ {% with page.groups.all as page_groups %}
+ {% for group in page_groups %}{{ group.name }}{% if not forloop.last %}, {% endif %}
+ {% empty %}
+ {% trans "logged users" %}
+ {% endfor %}
+ {% endwith %}
+ </span>
+ {% endif %}
</div>
{% endfor %}
</div>
diff --git a/tests/test_manager.py b/tests/test_manager.py
index d5c67aa..136e8f9 100644
--- a/tests/test_manager.py
+++ b/tests/test_manager.py
@@ -186,6 +186,28 @@ def test_page_edit_picture(app, admin_user):
assert '<img' in resp.text
assert Page.objects.get(id=page.id).picture.url in resp.text
+
+def test_page_placeholder_restricted_visibility(app, admin_user):
+ app = login(app)
+
+ page = Page.objects.create()
+ group = Group.objects.create(name='foobar')
+
+ resp = app.get(reverse('combo-manager-homepage'))
+ assert '<span class="visibility-summary"' not in resp.text
+
+ page.public = False
+ page.save()
+ resp = app.get(reverse('combo-manager-homepage'))
+ assert '<span class="visibility-summary" title="Restricted visibility">' in resp.text
+ assert 'foobar' not in resp.text
+
+ page.groups.set([group])
+ resp = app.get(reverse('combo-manager-homepage'))
+ assert '<span class="visibility-summary" title="Restricted visibility">' in resp.text
+ assert 'foobar' in resp.text
+
+
def test_delete_page(app, admin_user):
Page.objects.all().delete()
page = Page(title='One', slug='one', template_name='standard')