Commits

Luke Plant committed 857aacb

Display content-type.

  • Participants
  • Parent commits 960c4e5

Comments (0)

Files changed (3)

File output_validator/templates/output_validator/validationfailure_detail.html

 {% extends "output_validator/base.html" %}
+{% load output_validator %}
 {% block content %}
 <a href="../">[up]</a>
 <h2>Validation failure details</h2>
 		<td><div><pre>{{ object.errors }}</pre></div></td>
 	</tr>
 	<tr>
-		<th scope="row">Response content</th>
+		<th scope="row">Content-type</th>
+		<td><div><pre>{{ object.get_response|key:"content-type" }}</pre></div></td>
+	</tr>
+	<tr>
+		<th scope="row">Content</th>
 		<td><div><pre>{{ object.get_response.content|linenumbers }}</pre></div></td>
 	</tr>
 	<tr>
 		<td><div><pre>{{ object.request }}</pre></div></td>
 	</tr>
 </table>
+<br/>
 {% endblock %}

File output_validator/templatetags/__init__.py

Empty file added.

File output_validator/templatetags/output_validator.py

+from django import template
+
+register = template.Library()
+
+def key(d, key_name):
+    try:
+        value = d[key_name]
+    except:
+        from django.conf import settings
+        value = settings.TEMPLATE_STRING_IF_INVALID
+
+    return value
+
+register.filter(key)