Commits

Luke Plant committed f4ed937

Used URL reversing throughout.

Comments (0)

Files changed (4)

output_validator/templates/output_validator/validationfailure_detail.html

 {% extends "output_validator/base.html" %}
 {% load output_validator %}
+{% load url from future %}
 {% block content %}
-<a href="../">[up]</a>
+<a href="{% url 'output_validator.list' %}">[up]</a>
 <h2>Validation failure details</h2>
 
-<form method="post" action="delete/">{% csrf_token %}<div>
+<form method="post" action="{% url 'output_validator.delete' pk=object.id %}">{% csrf_token %}<div>
 <input type="submit" name="delete" value="Delete" />
 </div>
 </form>

output_validator/templates/output_validator/validationfailure_list.html

 {% extends "output_validator/base.html" %}
+{% load url from future %}
 {% block content %}
 
 {% if object_list %}
-	<form method="post" action="delete/">{% csrf_token %}
+	<form method="post" action="{% url 'output_validator.bulkdelete' %}">{% csrf_token %}
 	<div class="errorsfound"><p>{{ object_list|length }} page(s) with errors</p></div>
 	<div>
 	<table>
 		<tr {% if forloop.counter|divisibleby:"2" %}class="alt"{% endif %}>
 			<td>{{ failure.timestamp|date:"d M Y h:i" }}</td>
 			<td><span class="method">{{ failure.method }}</span> <span class="path">{{ failure.path|escape }}</span></td>
-			<td><a href="{{ failure.id }}/">Details</a></td>
+			<td><a href="{% url 'output_validator.detail' pk=failure.id %}">Details</a></td>
 			<td><input type="checkbox" name="deleteitem{{ failure.id }}" /></td>
 		</tr>
 		{% endfor %}

output_validator/urls.py

              url(r'^(?P<pk>\d+)/$',
                  DetailView.as_view(queryset=ValidationFailure.objects.all()),
                  name='output_validator.detail'),
-             url(r'^(?P<object_id>\d+)/delete/$',
+             url(r'^(?P<pk>\d+)/delete/$',
                  'output_validator.views.delete',
                  name='output_validator.delete'),
              url(r'^delete/$',

output_validator/views.py

+from django.core.urlresolvers import reverse
 from django.http import HttpResponseRedirect
 
 from output_validator.models import ValidationFailure
                     except ValidationFailure.DoesNotExist:
                         pass
 
-    return HttpResponseRedirect("../")
+    return HttpResponseRedirect(reverse('output_validator.list'))
 
 
-def delete(request, object_id):
+def delete(request, pk):
     if request.POST:
         try:
-            vf = ValidationFailure.objects.get(id=object_id)
+            vf = ValidationFailure.objects.get(pk=pk)
             vf.delete()
         except ValidationFailure.DoesNotExist:
             pass
-    return HttpResponseRedirect("../../")
+    return HttpResponseRedirect(reverse('output_validator.list'))