wscall: use a django template for detail page

This commit is contained in:
Lauréline Guérin 2020-09-03 11:42:23 +02:00
parent d1557f0473
commit 682665288b
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 38 additions and 48 deletions

View File

@ -92,57 +92,12 @@ class NamedWsCallPage(Directory):
def _q_index(self):
html_top('wscalls', title=self.wscall.name)
r = TemplateIO(html=True)
if self.wscall.is_readonly():
get_response().filter['sidebar'] = htmltext(
'<div class="infonotice"><p>%s</p></div>') % _('This webservice call is readonly.')
r += htmltext('<div id="appbar">')
r += htmltext('<h2>%s - ') % _('Webservice Call')
r += self.wscall.name
r += htmltext('</h2>')
r += htmltext('<span class="actions">')
if not self.wscall.is_readonly():
r += htmltext('<a href="delete" rel="popup">%s</a>') % _('Delete')
r += htmltext('<a href="edit">%s</a>') % _('Edit')
r += htmltext('</span>')
r += htmltext('</div>')
if self.wscall.description:
r += htmltext('<div class="bo-block">')
r += self.wscall.description
r += htmltext('</div>')
if self.wscall.request:
r += htmltext('<div class="bo-block">')
r += htmltext('<h3>%s</h3>') % _('Parameters')
r += htmltext('<ul>')
if self.wscall.request.get('url'):
r += htmltext('<li>%s %s</li>') % (
_('URL:'),
self.wscall.request.get('url'))
if self.wscall.request.get('request_signature_key'):
r += htmltext('<li>%s %s</li>') % (
_('Request Signature Key:'),
self.wscall.request.get('request_signature_key'))
if self.wscall.request.get('qs_data'):
r += htmltext('<li>%s<ul>') % _('Query string data:')
for k, v in self.wscall.request.get('qs_data').items():
r += htmltext('<li>%s %s</li>') % (_('%s:') % k, v)
r += htmltext('</ul></li>')
r += htmltext('<li>%s %s</li>') % (
_('Method:'),
'POST' if self.wscall.request.get('method') == 'POST' else 'GET')
if self.wscall.request.get('post_data'):
r += htmltext('<li>%s<ul>') % _('POST data:')
for k, v in self.wscall.request.get('post_data').items():
r += htmltext('<li>%s %s</li>') % (_('%s:') % k, v)
r += htmltext('</ul></li>')
r += htmltext('</ul>')
r += htmltext('</div>')
return r.getvalue()
return template.QommonTemplateResponse(
templates=['wcs/backoffice/wscall.html'],
context={'view': self, 'wscall': self.wscall})
def edit(self):
form = self.wscall_ui.get_form()

View File

@ -0,0 +1,35 @@
{% load i18n %}
{% block body %}
<div id="appbar">
<h2>{% trans "Webservice Call" %} - {{ wscall.name }}</h2>
{% if not wscall.is_readonly %}
<span class="actions">
<a href="delete" rel="popup">{% trans "Delete" %}</a>
<a href="edit">{% trans "Edit" %}</a>
</span>
{% endif %}
</div>
{% if wscall.description %}
<div class="bo-block">{{ wscall.description }}</div>
{% endif %}
<div class="bo-block">
<h3>{% trans "Parameters" %}</h3>
<ul>
{% if wscall.request.url %}<li>{% trans "URL:" %} {{ wscall.request.url }}</li>{% endif %}
{% if wscall.request.request_signature_key %}<li>{% trans "Request Signature Key:" %} {{ wscall.request.request_signature_key }}</li>{% endif %}
{% if wscall.request.qs_data %}
<li>{% trans "Query string data:" %}
<ul>
{% for k, v in wscall.request.qs_data.items %}
<li>{% blocktrans %}{{ k }}:{% endblocktrans %} {{ v }}</li>
{% endfor %}
</ul>
</li>
{% endif %}
<li>{% trans "Method:" %} {% if wscall.request.method == 'POST' %}POST{% else %}GET{% endif %}</li>
</ul>
</div>
{% endblock %}