Projet

Général

Profil

0001-backoffice-render-data-sources-index-using-a-templat.patch

Frédéric Péters, 23 août 2020 20:59

Télécharger (3,15 ko)

Voir les différences:

Subject: [PATCH] backoffice: render data sources index using a template
 (#46011)

 wcs/admin/data_sources.py                     | 25 +++----------------
 .../wcs/backoffice/data-sources.html          | 23 +++++++++++++++++
 2 files changed, 27 insertions(+), 21 deletions(-)
 create mode 100644 wcs/templates/wcs/backoffice/data-sources.html
wcs/admin/data_sources.py
273 273
        return super(NamedDataSourcesDirectory, self)._q_traverse(path)
274 274

  
275 275
    def _q_index(self):
276
        get_response().add_javascript(['jquery.js', 'jquery-ui.js', 'biglist.js',
277
            'qommon.wysiwyg.js'])
278
        html_top('datasources', title = _('Data Sources'))
279
        r = TemplateIO(html=True)
280

  
281
        r += htmltext('<div id="appbar">')
282
        r += htmltext('<h2>%s</h2>') % _('Data Sources')
283
        r += htmltext('<span class="actions">')
284
        r += htmltext('<a href="import" rel="popup">%s</a>') % _('Import')
285
        r += htmltext('<a class="new-item" href="new">%s</a>') % _('New Data Source')
286
        r += htmltext('</span>')
287
        r += htmltext('</div>')
288
        r += htmltext('<ul class="biglist" id="datasource-list">')
289
        datasources = NamedDataSource.select(order_by='name')
290
        for datasource in datasources:
291
            r += htmltext('<li class="biglistitem" id="itemId_%s">') % datasource.id
292
            r += htmltext('<strong class="label"><a href="%s/">%s (%s)</a></strong>') % (
293
                            datasource.id, datasource.name, datasource.slug)
294
            r += htmltext('</li>')
295
        r += htmltext('</ul>')
296
        return r.getvalue()
276
        html_top('datasources', title=_('Data Sources'))
277
        return template.QommonTemplateResponse(
278
                templates=['wcs/backoffice/data-sources.html'],
279
                context={'data_sources': NamedDataSource.select(order_by='name')})
297 280

  
298 281
    def new(self):
299 282
        get_response().breadcrumb.append( ('new', _('New')) )
wcs/templates/wcs/backoffice/data-sources.html
1
{% extends "wcs/backoffice/base.html" %}
2
{% load i18n %}
3

  
4
{% block appbar-title %}{% trans "Data Sources" %}{% endblock %}
5

  
6
{% block appbar-actions %}
7
<a data-popup href="import">{% trans "Import" %}</a>
8
<a href="new">{% trans "New Data Source" %}</a>
9
{% endblock %}
10

  
11
{% block content %}
12
{% if data_sources %}
13
<ul class="objects-list single-links">
14
  {% for data_source in data_sources %}
15
  <li><a href="{{ data_source.id }}/">{{ data_source.name }} ({{ data_source.slug }})</a></li>
16
  {% endfor %}
17
</ul>
18
{% else %}
19
<div class="infonotice">
20
{% trans "There are no data sources defined." %}
21
</div>
22
{% endif %}
23
{% endblock %}
0
-