Projet

Général

Profil

0002-wscall-use-a-django-template-for-detail-page.patch

Lauréline Guérin, 07 septembre 2020 14:57

Télécharger (4,36 ko)

Voir les différences:

Subject: [PATCH 2/3] wscall: use a django template for detail page

 wcs/admin/wscalls.py                     | 49 ++----------------------
 wcs/templates/wcs/backoffice/wscall.html | 33 ++++++++++++++++
 2 files changed, 36 insertions(+), 46 deletions(-)
 create mode 100644 wcs/templates/wcs/backoffice/wscall.html
wcs/admin/wscalls.py
91 91

  
92 92
    def _q_index(self):
93 93
        html_top('wscalls', title=self.wscall.name)
94
        r = TemplateIO(html=True)
95

  
96
        r += htmltext('<div id="appbar">')
97
        r += htmltext('<h2>%s - ') % _('Webservice Call')
98
        r += self.wscall.name
99
        r += htmltext('</h2>')
100
        r += htmltext('<span class="actions">')
101
        r += htmltext('<a href="delete" rel="popup">%s</a>') % _('Delete')
102
        r += htmltext('<a href="edit">%s</a>') % _('Edit')
103
        r += htmltext('</span>')
104
        r += htmltext('</div>')
105

  
106
        if self.wscall.description:
107
            r += htmltext('<div class="bo-block">')
108
            r += self.wscall.description
109
            r += htmltext('</div>')
110

  
111
        if self.wscall.request:
112
            r += htmltext('<div class="bo-block">')
113
            r += htmltext('<h3>%s</h3>') % _('Parameters')
114
            r += htmltext('<ul>')
115
            if self.wscall.request.get('url'):
116
                r += htmltext('<li>%s %s</li>') % (
117
                        _('URL:'),
118
                        self.wscall.request.get('url'))
119
            if self.wscall.request.get('request_signature_key'):
120
                r += htmltext('<li>%s %s</li>') % (
121
                        _('Request Signature Key:'),
122
                        self.wscall.request.get('request_signature_key'))
123
            if self.wscall.request.get('qs_data'):
124
                r += htmltext('<li>%s<ul>') % _('Query string data:')
125
                for k, v in self.wscall.request.get('qs_data').items():
126
                    r += htmltext('<li>%s %s</li>') % (_('%s:') % k, v)
127
                r += htmltext('</ul></li>')
128
            r += htmltext('<li>%s %s</li>') % (
129
                    _('Method:'),
130
                    'POST' if self.wscall.request.get('method') == 'POST' else 'GET')
131
            if self.wscall.request.get('post_data'):
132
                r += htmltext('<li>%s<ul>') % _('POST data:')
133
                for k, v in self.wscall.request.get('post_data').items():
134
                    r += htmltext('<li>%s %s</li>') % (_('%s:') % k, v)
135
                r += htmltext('</ul></li>')
136
            r += htmltext('</ul>')
137
            r += htmltext('</div>')
138

  
139
        return r.getvalue()
94
        return template.QommonTemplateResponse(
95
            templates=['wcs/backoffice/wscall.html'],
96
            context={'view': self, 'wscall': self.wscall})
140 97

  
141 98
    def edit(self):
142 99
        form = self.wscall_ui.get_form()
wcs/templates/wcs/backoffice/wscall.html
1
{% load i18n %}
2

  
3
{% block body %}
4
<div id="appbar">
5
<h2>{% trans "Webservice Call" %} - {{ wscall.name }}</h2>
6
<span class="actions">
7
  <a href="delete" rel="popup">{% trans "Delete" %}</a>
8
  <a href="edit">{% trans "Edit" %}</a>
9
</span>
10
</div>
11

  
12
{% if wscall.description %}
13
<div class="bo-block">{{ wscall.description }}</div>
14
{% endif %}
15

  
16
<div class="bo-block">
17
<h3>{% trans "Parameters" %}</h3>
18
<ul>
19
  {% if wscall.request.url %}<li>{% trans "URL:" %} {{ wscall.request.url }}</li>{% endif %}
20
  {% if wscall.request.request_signature_key %}<li>{% trans "Request Signature Key:" %} {{ wscall.request.request_signature_key }}</li>{% endif %}
21
  {% if wscall.request.qs_data %}
22
  <li>{% trans "Query string data:" %}
23
      <ul>
24
        {% for k, v in wscall.request.qs_data.items %}
25
          <li>{% blocktrans %}{{ k }}:{% endblocktrans %} {{ v }}</li>
26
        {% endfor %}
27
      </ul>
28
    </li>
29
  {% endif %}
30
  <li>{% trans "Method:" %} {% if wscall.request.method == 'POST' %}POST{% else %}GET{% endif %}</li>
31
</ul>
32
</div>
33
{% endblock %}
0
-