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>
<p>
{{ product.description }}
</p>
{% if user.is_authenticated %}
<form method="POST">
{% csrf_token %}
{% bootstrap_form form %}
{% bootstrap_button "Add to order" button_type="submit" button_class="btn-primary" %}
</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 %}

View file

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