Products should be viewable when not logged in.

This commit is contained in:
Víðir Valberg Guðmundsson 2016-05-30 19:25:34 +02:00
parent c214036c51
commit 475f996a02
2 changed files with 13 additions and 1 deletions

View file

@ -5,9 +5,21 @@
<h2>{{ product.name }}</h2> <h2>{{ product.name }}</h2>
<p>
{{ product.description }}
</p>
{% if user.is_authenticated %}
<form method="POST"> <form method="POST">
{% csrf_token %} {% csrf_token %}
{% bootstrap_form form %} {% bootstrap_form form %}
{% bootstrap_button "Add to order" button_type="submit" button_class="btn-primary" %} {% bootstrap_button "Add to order" button_type="submit" button_class="btn-primary" %}
</form> </form>
{% else %}
<a href="{% url 'account_signup' %}?next={% url 'shop:product_detail' slug=product.slug %}">
Signup</a> or
<a href="{% url 'account_login' %}?next={% url 'shop:product_detail' slug=product.slug %}">
login</a>
to order this product
{% endif %}
{% endblock %} {% endblock %}

View file

@ -120,7 +120,7 @@ class ShopIndexView(ListView):
return context return context
class ProductDetailView(LoginRequiredMixin, FormView, DetailView): class ProductDetailView(FormView, DetailView):
model = Product model = Product
template_name = 'product_detail.html' template_name = 'product_detail.html'
form_class = AddToOrderForm form_class = AddToOrderForm