url(r'^manage_orders/$', manage_orders, name='manage_orders'),
url(r'^order_details/(?P<pk>\d+)$', order_details, name='order_details'),
try:
accept = self.request.GET.get('accept')
except:
accept = False
if accept:
Orders.objects.filter(id=self.kwargs['pk'], organization=self.request.user.organization).update(is_order=True, status='accepted')
#return HttpResponseRedirect('/manage_orders')
<a href="{% url 'order_details' order.id %}?accept=True"><button>Accept</button></a>
Reverse for 'order_details' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['order_details/(?P\\d+)$']
{% extends "header.html" %}
{% load staticfiles %}
{% load custom_tag %}
{% block body_block %}
<ul>
<li><b>Title: </b>{{ order.title }}</li>
<li><b>Profile: </b>{{ order.profile }}</li>
<li><b>Create date: </b>{{ order.created }}</li>
<li><b>Update date: </b>{{ order.updated }}</li>
<li><b>Status: </b>{{ order.status }}</li>
<li><b>Products: </b>
<table border='1'>
<tr>
<th>Group name</th>
<th>Art</th>
<th>Product name</th>
<th>Image</th>
<th>Packing</th>
<th>Cost</th>
<th>Discount price</th>
<th>Count</th>
<th>Sum</th>
</tr>
{% for product in orders.orderproducts_set.all %}
<tr>
<td>{{ product.product.group }}</td>
<td>{{ product.product.art }}</td>
<td>{{ product.product.product_name }}</td>
<td><img src="{{ MEDIA_URL }}{{product.product.photo}}" height="50" width="50"></td>
<td>{{product.product.get_packing_display}}</td>
<td>{{product.product.cost}}</td>
<td>{{product.price}}</td>
<td>{{product.count}}</td>
<td>{{product.price|divide:product.count}}</td>
</tr>
{% endfor %}
</table>
</li>
</ul>
{% if order.status != "accepted" %}
<a href="{% url 'order_details' pk=order.id %}?accept=True"><button>Accept</button></a>
{% endif %}
<a href="{% url 'order_details' pk=order.id %}?decline=True"><button>Decline</button></a>
{% endblock %}
class OrderDetailsView(DetailView):
model = Orders
template_name = 'orders/order_details.html'
def get_context_data(self, *args, **kwargs):
try:
accept = self.request.GET.get('accept')
except:
accept = False
try:
decline = self.request.GET.get('decline')
except:
decline = False
context = super(OrderDetailsView, self).get_context_data(*args, **kwargs)
context['order'] = Orders.objects.get(id=self.kwargs['pk'], organization=self.request.user.organization)
if accept:
Orders.objects.filter(id=self.kwargs['pk'], organization=self.request.user.organization).update(is_order=True, status='accepted')
return reverse('manage_orders')
if decline:
Orders.objects.filter(id=self.kwargs['pk'], organization=self.request.user.organization).update(is_order=False, status='declined')
return reverse('manage_orders')
return context