Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Display warning for pages availables in the future
akjanik242e2062f5d5
diff --git a/saleor/page/views.py b/saleor/page/views.pyindex 4877bc3e62..8771950fd9 100644--- a/saleor/page/views.py+++ b/saleor/page/views.py@@ -1,11 +1,17 @@+import datetime+from django.shortcuts import get_object_or_404from django.template.response import TemplateResponse-from .models import Pagefrom .utils import pages_visible_to_userdef page_detail(request, url):page = get_object_or_404(pages_visible_to_user(user=request.user).filter(url=url))- return TemplateResponse(request, 'page/details.html', {'page': page})+ today = datetime.date.today()+ is_visible = (+ page.available_on is None or page.available_on <= today)+ return TemplateResponse(+ request, 'page/details.html', {+ 'page': page, 'is_visible': is_visible})diff --git a/templates/dashboard/page/form.html b/templates/dashboard/page/form.htmlindex 4c916ce8f4..55db13e35a 100644--- a/templates/dashboard/page/form.html+++ b/templates/dashboard/page/form.html@@ -16,22 +16,22 @@{% block breadcrumbs %}<ul class="breadcrumbs breadcrumbs--history">- <li>- <a href="{% url 'dashboard:page-list' %}" class="breadcrumbs">{% trans "Pages" %}</a>- </li>+ <li>+ <a href="{% url 'dashboard:page-list' %}" class="breadcrumbs">{% trans "Pages" %}</a>+ </li><li class="back-mobile">- <a href="{% url "dashboard:page-list" %}" class="breadcrumb"><i class="material-icons">arrow_back</i></a>+ <a href="{% url 'dashboard:page-list' %}" class="breadcrumb"><i class="material-icons">arrow_back</i></a>+ </li>+ <li><span class="breadcrumbs--ellipsed-item">+ {% if page.pk %}{{ page }}{% else %}{% trans 'Add new page' %}{% endif %}</span></li>- <li><span class="breadcrumbs--ellipsed-item">- {% if page.pk %}{{ page }}{% else %}{% trans 'Add new page' %}{% endif %}</span>- </li></ul>{% endblock %}{% block header_extra %}{% if page.pk %}<a class="dropdown-button right" href="#" data-activates="page-delete" data-constrainwidth="false">- <svg data-src="{% static "dashboard/images/more-vert.svg" %}" height="24" width="24" />+ <svg data-src="{% static 'dashboard/images/more-vert.svg' %}" height="24" width="24" /></a><ul id="page-delete" class="dropdown-content"><li>@@ -39,7 +39,7 @@{% trans "Delete page" context "Page action" %}</a></li>-</ul>+ </ul>{% endif %}{% endblock %}diff --git a/templates/page/details.html b/templates/page/details.htmlindex e17817f865..e8c03ace9a 100644--- a/templates/page/details.html+++ b/templates/page/details.html@@ -19,5 +19,15 @@{% endblock breadcrumb %}{% block content %}-<div class="">{{ page.content|safe }}</div>+ {% if not is_visible %}+ <div class="alert alert-warning" role="alert">+ {% blocktrans trimmed with date=page.available_on|date context "Page details text" %}+ <strong>Warning!</strong>+ You are previewing a page that will become visible on <strong>{{ date }}</strong>.+ {% endblocktrans %}+ </div>+ {% endif %}+ <div class="">+ {{ page.content|safe }}+ </div>{% endblock %}