backoffice: render webservice calls index using a template (#46010)

This commit is contained in:
Frédéric Péters 2020-08-23 20:37:13 +02:00 committed by Thomas NOEL
parent d471561b47
commit 4b00a84393
2 changed files with 26 additions and 23 deletions

View File

@ -18,8 +18,7 @@ from quixote import redirect
from quixote.directory import Directory
from quixote.html import TemplateIO, htmltext
from wcs.qommon import _
from wcs.qommon import errors
from wcs.qommon import _, errors, template
from wcs.qommon.form import *
from wcs.qommon.backoffice.menu import html_top
from wcs.wscalls import NamedWsCall, WsCallRequestWidget
@ -187,28 +186,10 @@ class NamedWsCallsDirectory(Directory):
return super(NamedWsCallsDirectory, self)._q_traverse(path)
def _q_index(self):
get_response().add_javascript(['jquery.js', 'jquery-ui.js', 'biglist.js',
'qommon.wysiwyg.js'])
html_top('wscalls', title=_('Webservice Calls'))
r = TemplateIO(html=True)
r += htmltext('<div id="appbar">')
r += htmltext('<h2>%s</h2>') % _('Webservice Calls')
r += htmltext('<span class="actions">')
r += htmltext('<a class="new-item" href="new">%s</a>') % _('New webservice call')
r += htmltext('</span>')
r += htmltext('</div>')
r += htmltext('<ul class="biglist" id="wscall-list">')
wscalls = NamedWsCall.select(order_by='name')
for wscall in wscalls:
r += htmltext('<li class="biglistitem" id="itemId_%s">') % wscall.id
r += htmltext('<strong class="label"><a href="%s/">%s (%s)</a></strong>') % (
wscall.id, wscall.name, wscall.slug)
r += htmltext('</li>')
r += htmltext('</ul>')
r += htmltext('</div>')
return r.getvalue()
return template.QommonTemplateResponse(
templates=['wcs/backoffice/wscalls.html'],
context={'view': self, 'wscalls': NamedWsCall.select(order_by='name')})
def new(self):
get_response().breadcrumb.append( ('new', _('New')) )

View File

@ -0,0 +1,22 @@
{% extends "wcs/backoffice/base.html" %}
{% load i18n %}
{% block appbar-title %}{% trans "Webservice Calls" %}{% endblock %}
{% block appbar-actions %}
<a rel="popup" href="new">{% trans "New webservice call" %}</a>
{% endblock %}
{% block content %}
{% if wscalls %}
<ul class="objects-list single-links">
{% for wscall in wscalls %}
<li><a href="{{ wscall.id }}/">{{ wscall.name }} ({{ wscall.slug }})</a></li>
{% endfor %}
</ul>
{% else %}
<div class="infonotice">
{% trans "There are no webservice calls defined." %}
</div>
{% endif %}
{% endblock %}