Project

General

Profile

0001-views-show-oauth2-client-in-confirm-and-authorizatio.patch

Benjamin Dauvergne, 30 Mar 2018 08:33 PM

Download (7.11 KB)

View differences:

Subject: [PATCH] views: show oauth2 client in confirm and authorization form
 (fixes #22934)

 fargo/locale/fr/LC_MESSAGES/django.po       | 48 +++++++++++++++++++----------
 fargo/oauth2/views.py                       | 10 ++++--
 fargo/templates/fargo/oauth2/authorize.html |  3 ++
 fargo/templates/fargo/oauth2/confirm.html   | 19 ++++++++----
 4 files changed, 55 insertions(+), 25 deletions(-)
fargo/locale/fr/LC_MESSAGES/django.po
7 7
msgstr ""
8 8
"Project-Id-Version: fargo 0\n"
9 9
"Report-Msgid-Bugs-To: \n"
10
"POT-Creation-Date: 2018-03-30 16:45+0000\n"
10
"POT-Creation-Date: 2018-03-30 18:31+0000\n"
11 11
"PO-Revision-Date: 2018-03-17 17:31+0100\n"
12 12
"Last-Translator: Frederic Peters <fpeters@entrouvert.com>\n"
13 13
"Language: French\n"
......
182 182
msgid "redirect URIs"
183 183
msgstr "URIs de redirection"
184 184

  
185
#: fargo/oauth2/views.py:219
185
#: fargo/oauth2/views.py:225
186 186
msgid "This document is already in your portfolio"
187 187
msgstr "Ce document est déjà enregistré."
188 188

  
189
#: fargo/oauth2/views.py:222
189
#: fargo/oauth2/views.py:228
190 190
msgid "The document has not been uploaded"
191 191
msgstr "Aucun document n'a été déposé."
192 192

  
......
213 213
msgid "Upload a new document"
214 214
msgstr "Transférer un nouveau document"
215 215

  
216
#: fargo/templates/fargo/oauth2/authorize.html:13
216
#: fargo/templates/fargo/oauth2/authorize.html:7
217
#, python-format
218
msgid ""
219
"\n"
220
"      <p>The service %(oauth2_client)s want to get one of your documents.</"
221
"p>\n"
222
"    "
223
msgstr ""
224
"\n"
225
"        <p>Le site %(oauth2_client)s souhaite récupérer un de vos documents."
226
"</p>\n"
227
"      "
228

  
229
#: fargo/templates/fargo/oauth2/authorize.html:16
217 230
msgid "Choose"
218 231
msgstr "Sélectionner"
219 232

  
220
#: fargo/templates/fargo/oauth2/authorize.html:14
221
#: fargo/templates/fargo/oauth2/confirm.html:22
233
#: fargo/templates/fargo/oauth2/authorize.html:17
234
#: fargo/templates/fargo/oauth2/confirm.html:29
222 235
#: fargo/templates/fargo/upload.html:10
223 236
#: fargo/templates/fargo/userdocument_confirm_delete.html:12
224 237
#: fargo/templates/fargo/userdocument_form.html:14
......
227 240
msgstr "Annuler"
228 241

  
229 242
#: fargo/templates/fargo/oauth2/confirm.html:9
230
msgid "Continue to your client url"
231
msgstr "Continuer avec votre URL client"
232

  
233
#: fargo/templates/fargo/oauth2/confirm.html:13
234 243
#, python-format
235 244
msgid ""
236 245
"\n"
237
"        Do you accept to add <em class=\"filename\">%(filename)s</em> to "
238
"your portfolio?\n"
239
"      "
246
"         The service %(oauth2_client)s want to add the document \"<em class="
247
"\"filename\">%(filename)s</em>\" to your portfolio.\n"
248
"         "
240 249
msgstr ""
241 250
"\n"
242
"        Acceptez-vous d'ajouter <em class\"filename\">%(filename)s</em> à vos "
243
"documents ?\n"
251
"        Le site %(oauth2_client)s souhaite ajouter le document «&nbsp;<em "
252
"class=\"filename\">%(filename)s</em>&nbsp;» à vos documents.\n"
244 253
"      "
245 254

  
246
#: fargo/templates/fargo/oauth2/confirm.html:21
255
#: fargo/templates/fargo/oauth2/confirm.html:20
256
msgid "Return"
257
msgstr "Revenir"
258

  
259
#: fargo/templates/fargo/oauth2/confirm.html:28
247 260
msgid "Allow"
248 261
msgstr "Autoriser"
249 262

  
......
262 275
#: fargo/templates/fargo/userdocument_confirm_delete.html:8
263 276
#, python-format
264 277
msgid "Are you sure you want to delete \"%(object)s\"?"
265
msgstr "Êtes-vous sûr de vouloir supprimer « %(object)s » ?"
278
msgstr ""
279
"Êtes-vous sûr de vouloir supprimer le document «&nbsp;%(object)s&nbsp;» ?"
266 280

  
267 281
#: fargo/templates/fargo/userdocument_confirm_delete.html:11
268 282
msgid "Delete"
fargo/oauth2/views.py
107 107
                    authorization.code)
108 108
        return self.redirect(code=authorization.code, state=self.state)
109 109

  
110
    def get_context_data(self, **kwargs):
111
        kwargs['oauth2_client'] = self.client
112
        return super(OAuth2AuthorizeView , self).get_context_data(**kwargs)
113

  
110 114

  
111 115
authorize_get_document = login_required(OAuth2AuthorizeView.as_view())
112 116

  
......
207 211
        return super(OAuth2AuthorizePutView, self).dispatch(request)
208 212

  
209 213
    def get_context_data(self, **kwargs):
210

  
211 214
        if self.oauth2_document:
215
            kwargs['oauth2_document'] = self.oauth2_document
216
            kwargs['filename'] = self.oauth2_document.filename
217
            kwargs['thumbnail'] = self.oauth2_document.document.thumbnail_data_url
218
            kwargs['oauth2_client'] = self.oauth2_document.client
212 219
            # verify if document already exists
213 220
            if not UserDocument.objects.filter(
214 221
                    user=self.request.user,
215 222
                    document=self.oauth2_document.document).exists():
216
                kwargs['filename'] = self.oauth2_document.filename
217 223
                kwargs['error_message'] = ''
218 224
            else:
219 225
                kwargs['error_message'] = _('This document is already in your portfolio')
fargo/templates/fargo/oauth2/authorize.html
4 4
{% block content %}
5 5
<div id="fargo-oauth2-authorize">
6 6
  {% block form-intro %}
7
    {% blocktrans %}
8
      <p>The service {{ oauth2_client }} want to get one of your documents.</p>
9
    {% endblocktrans %}
7 10
  {% endblock %}
8 11
  {% block form %}
9 12
  <form method="post" enctype="multipart/form-data">
fargo/templates/fargo/oauth2/confirm.html
3 3

  
4 4
{% block content %}
5 5
<div id="fargo-oauth2-confirm">
6
  {% if oauth2_document %}
7
    {% block form-intro %}
8
      <p>
9
         {% blocktrans %}
10
         The service {{ oauth2_client }} want to add the document "<em class="filename">{{ filename }}</em>" to your portfolio.
11
         {% endblocktrans %}
12
      </p>
13
      {% if thumbnail %}<p><img src="{{ thumbnail }}"/></p>{% endif %}
14
    {% endblock %}
15
  {% endif %}
6 16
  {% if error_message %}
7 17
    {% block error-message %}
8 18
    <p>{% trans error_message %}</p>
9
    <a href="{{ redirect_uri }}">{% trans "Continue to your client url" %}</a>
19
    <form id="send-file" method="post">
20
      <button name="cancel">{% trans "Return" %}</button>
21
    </form>
10 22
    {% endblock %}
11 23
  {% else %}
12
    {% block form-intro %}
13
      <p>{% blocktrans %}
14
        Do you accept to add <em class="filename">{{ filename }}</em> to your portfolio?
15
      {% endblocktrans %}</p>
16
    {% endblock %}
17 24
    {% block form %}
18 25
    <form id="send-file" method="post" enctype="multipart/form-data">
19 26
      {% csrf_token %}
20
-