Skip to content

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

Use template style similar to the rest fo the site

akjanikf7bee39f2a04
diff --git a/saleor/dashboard/page/urls.py b/saleor/dashboard/page/urls.py
index 9f518427d8..21716cbab3 100644
--- a/saleor/dashboard/page/urls.py
+++ b/saleor/dashboard/page/urls.py
@@ -6,5 +6,6 @@ from . import views
urlpatterns = [
url(r'^$', views.page_list, name='page-list'),
url(r'^add/$', views.page_add, name='page-add'),
+ url(r'^(?P<pk>[0-9]+)/detail/$', views.page_detail, name='page-detail'),
url(r'^(?P<pk>[0-9]+)/edit/$', views.page_edit, name='page-edit'),
url(r'^(?P<pk>[0-9]+)/delete/$', views.page_delete, name='page-delete')]
diff --git a/saleor/dashboard/page/views.py b/saleor/dashboard/page/views.py
index 44a00ef8cc..506b25d4f5 100644
--- a/saleor/dashboard/page/views.py
+++ b/saleor/dashboard/page/views.py
@@ -1,29 +1,35 @@
+from django.conf import settings
from django.contrib import messages
+from django.contrib.auth.decorators import permission_required
from django.shortcuts import get_object_or_404, redirect
from django.template.response import TemplateResponse
from django.utils.translation import pgettext_lazy
-from ...core.utils import (get_paginator_items)
+from ...core.utils import get_paginator_items
from ...page.models import Page
from ..views import staff_member_required
from .forms import PageForm
@staff_member_required
+@permission_required('site.view_settings')
def page_list(request):
pages = Page.objects.all()
- pages = get_paginator_items(pages, 30, request.GET.get('page'))
+ pages = get_paginator_items(
+ pages, settings.DASHBOARD_PAGINATE_BY, request.GET.get('page'))
ctx = {'pages': pages}
return TemplateResponse(request, 'dashboard/page/list.html', ctx)
@staff_member_required
+@permission_required('site.edit_settings')
def page_edit(request, pk):
page = get_object_or_404(Page, pk=pk)
return _page_edit(request, page)
@staff_member_required
+@permission_required('site.edit_settings')
def page_add(request):
page = Page()
return _page_edit(request, page)
@@ -43,6 +49,7 @@ def _page_edit(request, page):
@staff_member_required
+@permission_required('site.edit_settings')
def page_delete(request, pk):
page = get_object_or_404(Page, pk=pk)
if request.POST:
@@ -53,3 +60,11 @@ def page_delete(request, pk):
return redirect('dashboard:page-list')
ctx = {'page': page}
return TemplateResponse(request, 'dashboard/page/modal-delete.html', ctx)
+
+
+@staff_member_required
+@permission_required('site.view_settings')
+def page_detail(request, pk):
+ page = get_object_or_404(Page, pk=pk)
+ ctx = {'page': page}
+ return TemplateResponse(request, 'dashboard/page/detail.html', ctx)
diff --git a/saleor/page/models.py b/saleor/page/models.py
index 11cca12c22..507f84782f 100644
--- a/saleor/page/models.py
+++ b/saleor/page/models.py
@@ -1,9 +1,9 @@
import datetime
+from django.core.validators import validate_slug
from django.db import models
from django.db.models import Q
from django.urls import reverse
-from django.core.validators import validate_slug
class PageManager(models.QuerySet):
diff --git a/templates/dashboard/base.html b/templates/dashboard/base.html
index 342a5e9690..5da1b44c68 100644
--- a/templates/dashboard/base.html
+++ b/templates/dashboard/base.html
@@ -236,7 +236,7 @@
</a>
</li>
{% endif %}
- {% if perms.site.edit_settings %}
+ {% if perms.site.view_settings %}
<li class="{% block menu_pages_class %}{% endblock %}">
<a href="{% url 'dashboard:page-list' %}">
{% trans "Pages" context "Dashboard static pages" %}
diff --git a/templates/dashboard/page/detail.html b/templates/dashboard/page/detail.html
new file mode 100644
index 0000000000..ebb0124452
--- /dev/null
+++ b/templates/dashboard/page/detail.html
@@ -0,0 +1,74 @@
+{% extends "dashboard/base.html" %}
+{% load i18n %}
+{% load mptt_tags %}
+{% load materializecss %}
+{% load staticfiles %}
+{% load utils %}
+
+{% block title %}{% trans "Pages" context "Pages list page title" %} -
+ {{ block.super }}{% endblock %}
+
+{% block body_class %}body-pages{% endblock %}
+
+{% block breadcrumbs %}
+ <ul class="breadcrumbs breadcrumbs--history">
+ <li>
+ <a href="{% url "dashboard:page-list" %}" class="breadcrumb">
+ {% trans "Pages" context "Pages form breadcrumbs" %}
+ </a>
+ </li>
+ <li class="back-mobile">
+ <a href="{% url "dashboard:page-list" %}">
+ <svg data-src="{% static "dashboard/images/arrow-left.svg" %}" fill="#fff" width="20px" height="20px" />
+ </a>
+ </li>
+ <li>
+ <span class="breadcrumbs--ellipsed-item">
+ {{ page }}
+ </span>
+ </li>
+ </ul>
+{% endblock %}
+
+{% block menu_pages_class %}active{% endblock %}
+
+{% block content %}
+ <div class="row">
+ <div class="col s12 l9">
+ <div class="card">
+ <div class="card-content">
+ <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>
+ </div>
+ <div class="card-action">
+ {% if perms.site.edit_settings %}
+ <a href="{% url "dashboard:page-edit" page.pk %}" class="btn-flat waves-effect">
+ {% trans "Edit page" context "Page action" %}
+ </a>
+ <a href="#base-modal" data-href="{% url 'dashboard:page-delete' pk=page.pk %}" class="modal-trigger-custom btn-flat waves-effect">
+ {% trans "Remove page" context "Page action" %}
+ </a>
+ {% endif %}
+ <a href="{{ page.get_absolute_url }}" target="_blank" class="btn-flat waves-effect">
+ {% trans "View on site" context "Page action" %}
+ </a>
+ </div>
+ </div>
+ <div class="card page-content" id="page-content">
+ <div class="card-content">
+ <span class="card-title black-text">
+ {% trans "Page preview" context "Page content card title" %}
+ </span>
+ <p>{{ page.content|safe }}</p>
+ </div>
+ </div>
+ </div>
+ </div>
+{% endblock %}
diff --git a/templates/dashboard/page/form.html b/templates/dashboard/page/form.html
index 70ddf59fd3..7cc59c5202 100644
--- a/templates/dashboard/page/form.html
+++ b/templates/dashboard/page/form.html
@@ -10,63 +10,66 @@
{% block body_class %}body-page{% endblock %}
{% block header_menu %}
- {% url "dashboard:page-list" as url %}
- {% include "dashboard/includes/_back-link.html" with url=url %}
+ {% url "dashboard:page-list" as url %}
+ {% include "dashboard/includes/_back-link.html" with url=url %}
{% endblock %}
{% block breadcrumbs %}
- <ul class="breadcrumbs breadcrumbs--with-menu">
- <li><a href="{% url 'dashboard:page-list' %}" class="breadcrumbs--ellipsed-item">{% trans "Pages" %}</a></li>
- <li><span class="breadcrumbs--ellipsed-item">{% if page.pk %}{{ page }}{% else %}{% trans 'Add new page' %}{% endif %}</span></li>
- </ul>
+ <ul class="breadcrumbs breadcrumbs--history">
+ <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>
+ </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" />
- </a>
- <ul id="page-delete" class="dropdown-content">
- <li>
- <a class="modal-trigger-custom" href="#base-modal" data-href="{% url 'dashboard:page-delete' pk=page.pk %}">
- {% trans "Delete page" context "Page action" %}
- </a>
- </li>
- </ul>
- {% endif %}
+ {% 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" />
+ </a>
+ <ul id="page-delete" class="dropdown-content">
+ <li>
+ <a class="modal-trigger-custom" href="#base-modal" data-href="{% url 'dashboard:page-delete' pk=page.pk %}">
+ {% trans "Delete page" context "Page action" %}
+ </a>
+ </li>
+</ul>
+ {% endif %}
{% endblock %}
-{% block menu_cms_class %} active{% endblock %}
+{% block menu_pages_class %}active{% endblock %}
{% block content %}
- <form method="post" enctype="multipart/form-data">
- {% csrf_token %}
- <div class="row">
- <div class="col s12 l8">
- {{ form.title|materializecss }}
- {{ form.content|materializecss }}
- </div>
- <div class="col s12 l4">
- {{ form.visible|materializecss }}
- {{ form.url|materializecss }}
- {{ form.available_on|materializecss }}
- </div>
- </div>
- <div class="row">
- <div class="col s12">
- <div class="left">
- <button type="button" class="btn green small-padding" value="Add More" id="add_more">
- {% trans "Add more files" %}</button>
- </div>
- <div class="right">
- {% if page.pk %}
- <a href="{% url 'dashboard:page-list' %}" class="btn-flat">{% trans "Cancel" %}</a>
- <button type="submit" class="btn">{% trans "Save" %}</button>
- {% else %}
- <a href="{% url 'dashboard:page-list' %}" class="btn-flat">{% trans "Cancel" %}</a>
- <button type="submit" class="btn submit-stay">{% trans "Create" %}</button>
- {% endif %}
- </div>
- </div>
- </form>
+ <form method="post" enctype="multipart/form-data">
+ {% csrf_token %}
+ <div class="row">
+ <div class="col s12 l8">
+ {{ form.title|materializecss }}
+ {{ form.content|materializecss }}
+ </div>
+ <div class="col s12 l4">
+ {{ form.url|materializecss }}
+ {{ form.available_on|materializecss }}
+ {{ form.visible|materializecss }}
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <div class="right">
+ {% if page.pk %}
+ <a href="{% url 'dashboard:page-list' %}" class="btn-flat">{% trans "Cancel" %}</a>
+ <button type="submit" class="btn">{% trans "Save" %}</button>
+ {% else %}
+ <a href="{% url 'dashboard:page-list' %}" class="btn-flat">{% trans "Cancel" %}</a>
+ <button type="submit" class="btn submit-stay">{% trans "Create" %}</button>
+ {% endif %}
+ </div>
+ </div>
+ </form>
{% endblock %}
diff --git a/templates/dashboard/page/list.html b/templates/dashboard/page/list.html
index f408f7fa01..2f4a066701 100644
--- a/templates/dashboard/page/list.html
+++ b/templates/dashboard/page/list.html
@@ -1,6 +1,7 @@
{% extends "dashboard/base.html" %}
{% load i18n %}
{% load staticfiles %}
+{% load utils %}
{% block page_title %}{% trans "Pages" %} - {{ block.super }}{% endblock %}
@@ -9,13 +10,14 @@
{% block body_class %}body-page{% endblock %}
{% block header_extra %}
- <div class="fixed-action-btn">
- <a class="btn-fab btn-floating btn-large waves-effect waves-light teal modal-trigger"
- href="{% url 'dashboard:page-add' %}"
- title="{% trans "Add page page" %}">
- <svg data-src="{% static "dashboard/images/add.svg" %}" />
- </a>
+ {% if perms.product.edit_settings %}
+ <div class="btn-fab-fixed">
+ <a class="btn-fab-default waves-effect waves-light"
+ href="{% url 'dashboard:page-add' %}"
+ title="{% trans "Add page page" %}"><svg data-src="{% static "dashboard/images/add.svg" %}" />
+ </a>
</div>
+ {% endif %}
{% endblock %}
{% block breadcrumbs %}
@@ -24,44 +26,51 @@
</ul>
{% endblock %}
-{% block menu_cms_class %} active{% endblock %}
-
{% block content %}
- <div class="row">
+ <div class="row">
+ <div class="col s12 l9">
+ {% if pages %}
+ <div class="card">
+ <div class="data-table-container">
+ <table class="bordered highlight responsive data-table data-table-description">
+ <thead>
+ <tr>
+ {% trans "Title" context "Static pages table header name" as label %}
+ {% sorting_header 'title' label %}
+
+ {% trans "URL" context "Static pages table header url" as label %}
+ {% sorting_header 'url' label is_wide=True %}
+ </tr>
+ </thead>
+ <tbody>
+ {% for page in pages %}
+ <tr data-action-go="{% url 'dashboard:page-detail' pk=page.pk %}">
+ <td>
+ {{ page.title }}
+ </td>
+ <td>
+ {{ page.get_absolute_url }}
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ </div>
+ {% paginate pages %}
+ {% else %}
+ {% if is_empty %}
+ {% include 'dashboard/page/zero_page.html' %}
+ {% else %}
<div class="col s12">
- {% if pages %}
- <div class="card">
- <div class="data-table-container">
- <table class="bordered hoverable responsive data-table">
- <thead>
- <tr>
- <th>{% trans "Title" %}</th>
- <th>{% trans "Url" %}</th>
- <th>{% trans "Created at" %}</th>
- </tr>
- </thead>
- <tbody>
- {% for page in pages %}
- <tr>
- <td>
- <a href="{% url 'dashboard:page-edit' pk=page.pk %}">{{ page }}</a>
- </td>
- <td>
- <a href="{{ page.get_absolute_url }}">{{ page.get_absolute_url }}</a>
- </td>
- <td>
- {{ page.created }}
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </div>
- </div>
- {% include "dashboard/includes/_pagination.html" with page_obj=pages %}
- {% else %}
- <p>{% trans "No pages found." %}</p>
- {% endif %}
+ <div class="not-found">
+ <p class="grey-text">
+ {% trans "No pages found." context "Empty pages list message" %}
+ </p>
+ </div>
</div>
- </div>
+ {% endif %}
+ {% endif %}
+ </div>
+ </div>
{% endblock %}
diff --git a/templates/dashboard/page/zero_page.html b/templates/dashboard/page/zero_page.html
new file mode 100644
index 0000000000..9cf595558a
--- /dev/null
+++ b/templates/dashboard/page/zero_page.html
@@ -0,0 +1,12 @@
+{% extends 'dashboard/base_zero_page.html' %}
+{% load i18n %}
+{% load static %}
+
+{% block title %}{% trans "No pages found." %}{% endblock %}
+{% block content %}
+ {% static "dashboard/images/add.svg" as img_path %}
+ {% blocktrans %}
+ Pages allows to create custom static pages such as "About us" that will be displayed at particular url.<br>
+ You can create pages by using the <span class="btn-fab-presentation"><svg data-src="{{ img_path }}" /></span> button.
+ {% endblocktrans %}
+{% endblock %}
diff --git a/templates/page/details.html b/templates/page/details.html
index ae33ac8a17..e17817f865 100644
--- a/templates/page/details.html
+++ b/templates/page/details.html
@@ -1,7 +1,6 @@
{% extends "base.html" %}
-
-
{% load i18n %}
+{% load materializecss %}
{% block breadcrumb %}
@@ -20,5 +19,5 @@
{% endblock breadcrumb %}
{% block content %}
-<p>{{ page.content|safe }}</p>
+<div class="">{{ page.content|safe }}</div>
{% endblock %}