Skip to content

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

Add attribute detail view

Mira Szewczyk7e96581a8830
diff --git a/saleor/dashboard/product/urls.py b/saleor/dashboard/product/urls.py
index 75b532d043..bce28162f3 100644
--- a/saleor/dashboard/product/urls.py
+++ b/saleor/dashboard/product/urls.py
@@ -55,6 +55,8 @@ urlpatterns = [
url(r'attributes/$',
views.attribute_list, name='product-attributes'),
url(r'attributes/(?P<pk>[0-9]+)/$',
+ views.attribute_detail, name='product-attribute-detail'),
+ url(r'attributes/(?P<pk>[0-9]+)/update/$',
views.attribute_edit, name='product-attribute-update'),
url(r'attributes/add/$',
views.attribute_edit, name='product-attribute-add'),
diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.py
index 7dfcfb3c9e..f1038cef14 100644
--- a/saleor/dashboard/product/views.py
+++ b/saleor/dashboard/product/views.py
@@ -372,6 +372,15 @@ def attribute_list(request):
ctx)
+@staff_member_required
+def attribute_detail(request, pk):
+ attributes = ProductAttribute.objects.prefetch_related('values').all()
+ attribute = get_object_or_404(attributes, pk=pk)
+ ctx = {'attribute': attribute}
+ return TemplateResponse(
+ request, 'dashboard/product/attributes/detail.html', ctx)
+
+
@staff_member_required
def attribute_edit(request, pk=None):
if pk:
@@ -389,7 +398,7 @@ def attribute_edit(request, pk=None):
'Dashboard message', 'Updated attribute') if pk else pgettext_lazy(
'Dashboard message', 'Added attribute')
messages.success(request, msg)
- return redirect('dashboard:product-attribute-update', pk=attribute.pk)
+ return redirect('dashboard:product-attribute-detail', pk=attribute.pk)
ctx = {'attribute': attribute, 'form': form, 'formset': formset}
return TemplateResponse(request, 'dashboard/product/attributes/form.html',
ctx)
diff --git a/templates/dashboard/product/attributes/detail.html b/templates/dashboard/product/attributes/detail.html
new file mode 100644
index 0000000000..2dd743248b
--- /dev/null
+++ b/templates/dashboard/product/attributes/detail.html
@@ -0,0 +1,112 @@
+{% extends 'dashboard/base.html' %}
+
+{% load i18n %}
+
+{% block title %}
+ {{ attribute }} - {% trans "Attributes" context "Attribute detail page title" %} - {{ block.super }}
+{% endblock %}
+
+{% block body_class %}body-attribute{% endblock %}
+
+{% block menu_attributes_class %}active{% endblock %}
+
+{% block header_extra %}
+ <a class="dropdown-button right" href="#" data-activates="attribute-delete" data-constrainwidth="false">
+ <i class="material-icons">more_vert</i>
+ </a>
+ <ul id="attribute-delete" class="dropdown-content">
+ <li>
+ <a href="{% url "dashboard:product-attribute-update" attribute.pk %}">
+ {% trans "Edit attribute" context "Attribute detail action" %}
+ </a>
+ </li>
+ <li>
+ <a class="modal-trigger-custom" href="#base-modal"
+ data-href="{% url 'dashboard:product-attribute-delete' pk=attribute.pk %}">
+ {% trans "Remove attribute" context "Attribute detail action" %}
+ </a>
+ </li>
+ </ul>
+{% endblock %}
+
+
+{% block breadcrumbs %}
+ <ul class="breadcrumbs breadcrumbs--history">
+ <li>
+ <a href="{% url 'dashboard:product-attributes' %}" class="breadcrumbs--ellipsed-item">
+ {% trans "Attributes" context "Attribute detail breadcrumbs" %}
+ </a>
+ </li>
+ <li class="back-mobile">
+ <a href="{% url 'dashboard:product-attributes' %}">
+ <i class="material-icons">arrow_back</i>
+ </a>
+ </li>
+ <li>
+ <span class="breadcrumbs--ellipsed-item">
+ {{ attribute }}
+ </span>
+ </li>
+ </ul>
+{% endblock %}
+
+{% block menu_catalogue_class %} active{% endblock %}
+
+{% block content %}
+ <div class="row">
+ <div class="col m12 l9">
+ <div class="card">
+ <div class="card-content">
+ <span class="card-title">
+ {% trans "Attribute detail" context "Attribute detail title" %}
+ </span>
+ <div class="row">
+ <div class="col s12 l9">
+ <h5>
+ {% trans "Display name" context "Attribute field" %}
+ </h5>
+ <p>
+ {{ attribute.display }}
+ </p>
+ </div>
+ <div class="col s12 l9">
+ <h5>
+ {% trans "Internal name" context "Attribute field" %}
+ </h5>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="col m12 l9">
+ <div class="card">
+ <div class="data-table-header">
+ <h5 class="data-table-title">{% trans "Attribute values" %}</h5>
+ </div>
+ <div class="data-table-container">
+ <table class="bordered highlight responsive data-table">
+ <thead>
+ <tr>
+ <th>{% trans "Display name" %}</th>
+ <th>{% trans "Color" %}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for value in attribute.values.all %}
+ <tr>
+ <td>
+ {{ value.display }}
+ </td>
+ <td>
+ {{ value.color }}
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+ </div>
+{% endblock %}
\ No newline at end of file
diff --git a/templates/dashboard/product/attributes/form.html b/templates/dashboard/product/attributes/form.html
index 3a440a069c..0c6a6c840a 100644
--- a/templates/dashboard/product/attributes/form.html
+++ b/templates/dashboard/product/attributes/form.html
@@ -21,21 +21,6 @@
{% include "dashboard/includes/_back-link.html" with url=url %}
{% endblock %}
-{% block header_extra %}
- {% if attribute.pk %}
- <a class="dropdown-button right" href="#" data-activates="attribute-delete" data-constrainwidth="false">
- <svg data-src="{% static "dashboard/images/more_vert.svg" %}" height="24" width="24" />
- </a>
- <ul id="attribute-delete" class="dropdown-content">
- <li>
- <a class="modal-trigger-custom" href="#base-modal"
- data-href="{% url 'dashboard:product-attribute-delete' pk=attribute.pk %}">
- {% trans "Remove attribute" context "Attribute detail action" %}
- </a>
- </li>
- </ul>
- {% endif %}
-{% endblock %}
{% block breadcrumbs %}
<ul class="breadcrumbs breadcrumbs--history">
@@ -111,7 +96,7 @@
</div>
<div class="card-action right-align">
{% if attribute.pk %}
- <a href="{% url 'dashboard:product-attributes' %}" class="btn btn-flat">
+ <a href="{% url 'dashboard:product-attribute-detail' attribute.pk %}" class="btn btn-flat">
{% trans "Cancel" context "Dashboard cancel action" %}
</a>
<button type="submit" class="btn waves-effect waves-light">
diff --git a/templates/dashboard/product/attributes/list.html b/templates/dashboard/product/attributes/list.html
index c576b24805..73719ed502 100644
--- a/templates/dashboard/product/attributes/list.html
+++ b/templates/dashboard/product/attributes/list.html
@@ -34,7 +34,7 @@
<ul class="collection list">
{% for pk, name, values in attributes %}
<li class="collection-item list-item">
- <a class="list-item-name" href="{% url 'dashboard:product-attribute-update' pk=pk %}">
+ <a class="list-item-name" href="{% url 'dashboard:product-attribute-detail' pk=pk %}">
{{ name }}
<p class="list-item-desc">
{% for value in values %}