Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add published status to page detail and list

Adam Janikfdbdc139a0bb
diff --git a/saleor/dashboard/page/filters.py b/saleor/dashboard/page/filters.py
index 425fa9f5ed..70c4bb6171 100644
--- a/saleor/dashboard/page/filters.py
+++ b/saleor/dashboard/page/filters.py
@@ -8,6 +8,7 @@ SORT_BY_FIELDS = {
'title': pgettext_lazy('Page list sorting option', 'title'),
'url': pgettext_lazy('Page list sorting option', 'url')}
+
class PageFilter(SortedFilterSet):
title = CharFilter(
label=pgettext_lazy('Page list title filter label', 'Title'),
diff --git a/saleor/dashboard/page/views.py b/saleor/dashboard/page/views.py
index c29649119d..97eb280817 100644
--- a/saleor/dashboard/page/views.py
+++ b/saleor/dashboard/page/views.py
@@ -20,7 +20,8 @@ def page_list(request):
pages = get_paginator_items(
pages_filter.qs, settings.DASHBOARD_PAGINATE_BY,
request.GET.get('page'))
- ctx = {'pages': pages, 'filter_set': pages_filter,
+ ctx = {
+ 'pages': pages, 'filter_set': pages_filter,
'is_empty': not pages_filter.queryset.exists()}
return TemplateResponse(request, 'dashboard/page/list.html', ctx)
diff --git a/saleor/dashboard/templatetags/utils.py b/saleor/dashboard/templatetags/utils.py
index 46464c571b..8ec63224bd 100644
--- a/saleor/dashboard/templatetags/utils.py
+++ b/saleor/dashboard/templatetags/utils.py
@@ -1,5 +1,6 @@
from __future__ import unicode_literals
+import datetime
from json import dumps
from urllib.parse import urlencode
@@ -148,3 +149,10 @@ def sorting_header(context, field, label, is_wide=False):
'url': '%s?%s' % (request.path, request_get.urlencode()),
'is_active': is_active, 'sorting_icon': sorting_icon, 'label': label,
'is_wide': is_wide}
+
+
+def page_published(page):
+ today = datetime.date.today()
+ return page.is_visible and \
+ (page.available_on is None or page.available_on <= today)
diff --git a/templates/dashboard/page/detail.html b/templates/dashboard/page/detail.html
index d4498e2981..6242b26f64 100644
--- a/templates/dashboard/page/detail.html
+++ b/templates/dashboard/page/detail.html
@@ -37,15 +37,20 @@
<div class="col s12 l9">
<div class="card">
<div class="card-content">
+ {% page_published page=page as is_published %}
+ {% if is_published %}
+ <span class="right label label-success">PUBLISHED</span>
+ {% else %}
+ <div class="right align label">
+ HIDDEN<br>
+ WILL BE AVAILABLE AT {{ page.available_on }}
+ </div>
+ {% endif %}
<span class="card-title">{{ page }}<br></span>
- <div class="row">
- <div class="col s5 m6">
- <h4>
- {% trans "Page URL" context "Page field" %}
- </h4>
- {{ page.url }}
- </div>
- </div>
+ <h4>
+ {% trans "Page URL" context "Page field" %}
+ </h4>
+ {{ page.url }}
</div>
<div class="card-action">
{% if perms.page.edit_page %}
diff --git a/templates/dashboard/page/list.html b/templates/dashboard/page/list.html
index 1f4ea22df4..aeb1ee68e3 100644
--- a/templates/dashboard/page/list.html
+++ b/templates/dashboard/page/list.html
@@ -40,6 +40,9 @@
{% trans "URL" context "Static pages table header url" as label %}
{% sorting_header 'url' label is_wide=True %}
+ <th>
+ {% trans "Status" context "Pages table header" %}
+ </th>
</tr>
</thead>
<tbody>
@@ -49,7 +52,19 @@
{{ page.title }}
</td>
<td>
- {{ page.get_absolute_url }}
+ {{ page.get_absolute_url }}
+ </td>
+ <td>
+ {% page_published page=page as is_published %}
+ {% if is_published %}
+ <div>
+ PUBLISHED
+ </div>
+ {% else %}
+ <div>
+ HIDDEN
+ </div>
+ {% endif %}
</td>
</tr>
{% endfor %}