Skip to content

Commit 6b1ed99

Browse files
committed
better rendering of headers and payload
1 parent 641d0d6 commit 6b1ed99

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

pyas2/templates/admin/pyas2/mdn/change_form.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "admin/change_form.html" %}
2-
{% load i18n admin_urls static%}
2+
{% load i18n admin_urls static pyas2%}
33

44
{% block title %} View MDN Details{% endblock title %}
55
{% block content %}
@@ -39,15 +39,13 @@ <h1> View MDN Details</h1>
3939
<div class="form-row field-name">
4040
<div>
4141
<label class="required" >Message Headers:</label>
42-
<textarea required="" rows="10" cols="40" class="vLargeTextField"
43-
disabled>{{ original.headers.read }}</textarea>
42+
{{ original.headers|readfilefield|linebreaksbr }}
4443
</div>
4544
</div>
4645
<div class="form-row field-name">
4746
<div>
4847
<label class="required" >Message Headers:</label>
49-
<textarea required="" rows="20" cols="40" class="vLargeTextField"
50-
disabled>{{ original.payload.read }}</textarea>
48+
<p>{{ original.payload|readfilefield|linebreaksbr }}
5149
</div>
5250
</div>
5351
</fieldset>

pyas2/templates/admin/pyas2/message/change_form.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "admin/change_form.html" %}
2-
{% load i18n admin_urls static%}
2+
{% load i18n admin_urls static pyas2%}
33

44
{% block title %} View Message Details{% endblock title %}
55
{% block content %}
@@ -80,8 +80,7 @@ <h1> View Message Details</h1>
8080
<div class="form-row field-name">
8181
<div>
8282
<label class="required" >Message Headers:</label>
83-
<textarea required="" rows="10" cols="40" class="vLargeTextField"
84-
disabled>{{ original.headers.read }}</textarea>
83+
<p>{{ original.headers|readfilefield|linebreaksbr }}</p>
8584
</div>
8685
</div>
8786
{% if original.payload %}

pyas2/templatetags/__init__.py

Whitespace-only changes.

pyas2/templatetags/pyas2.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django import template
2+
from django.utils.html import format_html
3+
4+
register = template.Library()
5+
6+
7+
@register.filter
8+
def readfilefield(field):
9+
""" Template filter for rendering data from a file field """
10+
with field.open('r') as f:
11+
return f.read()

0 commit comments

Comments
 (0)