From 8cea6bbc17553ac83dde81c3a477c1361ce74653 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 30 Mar 2018 18:59:29 +0200 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(-) diff --git a/fargo/locale/fr/LC_MESSAGES/django.po b/fargo/locale/fr/LC_MESSAGES/django.po index a98f145..f15b3a7 100644 --- a/fargo/locale/fr/LC_MESSAGES/django.po +++ b/fargo/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: fargo 0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-03-30 16:45+0000\n" +"POT-Creation-Date: 2018-03-30 18:31+0000\n" "PO-Revision-Date: 2018-03-17 17:31+0100\n" "Last-Translator: Frederic Peters \n" "Language: French\n" @@ -182,11 +182,11 @@ msgstr "Document" msgid "redirect URIs" msgstr "URIs de redirection" -#: fargo/oauth2/views.py:219 +#: fargo/oauth2/views.py:225 msgid "This document is already in your portfolio" msgstr "Ce document est déjà enregistré." -#: fargo/oauth2/views.py:222 +#: fargo/oauth2/views.py:228 msgid "The document has not been uploaded" msgstr "Aucun document n'a été déposé." @@ -213,12 +213,25 @@ msgstr "S'il vous plaît veuillez réessayer avec un document moins volumineux." msgid "Upload a new document" msgstr "Transférer un nouveau document" -#: fargo/templates/fargo/oauth2/authorize.html:13 +#: fargo/templates/fargo/oauth2/authorize.html:7 +#, python-format +msgid "" +"\n" +"

The service %(oauth2_client)s want to get one of your documents.\n" +" " +msgstr "" +"\n" +"

Le site %(oauth2_client)s souhaite récupérer un de vos documents." +"

\n" +" " + +#: fargo/templates/fargo/oauth2/authorize.html:16 msgid "Choose" msgstr "Sélectionner" -#: fargo/templates/fargo/oauth2/authorize.html:14 -#: fargo/templates/fargo/oauth2/confirm.html:22 +#: fargo/templates/fargo/oauth2/authorize.html:17 +#: fargo/templates/fargo/oauth2/confirm.html:29 #: fargo/templates/fargo/upload.html:10 #: fargo/templates/fargo/userdocument_confirm_delete.html:12 #: fargo/templates/fargo/userdocument_form.html:14 @@ -227,23 +240,23 @@ msgid "Cancel" msgstr "Annuler" #: fargo/templates/fargo/oauth2/confirm.html:9 -msgid "Continue to your client url" -msgstr "Continuer avec votre URL client" - -#: fargo/templates/fargo/oauth2/confirm.html:13 #, python-format msgid "" "\n" -" Do you accept to add %(filename)s to " -"your portfolio?\n" -" " +" The service %(oauth2_client)s want to add the document \"%(filename)s\" to your portfolio.\n" +" " msgstr "" "\n" -" Acceptez-vous d'ajouter %(filename)s à vos " -"documents ?\n" +" Le site %(oauth2_client)s souhaite ajouter le document « %(filename)s » à vos documents.\n" " " -#: fargo/templates/fargo/oauth2/confirm.html:21 +#: fargo/templates/fargo/oauth2/confirm.html:20 +msgid "Return" +msgstr "Revenir" + +#: fargo/templates/fargo/oauth2/confirm.html:28 msgid "Allow" msgstr "Autoriser" @@ -262,7 +275,8 @@ msgstr "Transférer" #: fargo/templates/fargo/userdocument_confirm_delete.html:8 #, python-format msgid "Are you sure you want to delete \"%(object)s\"?" -msgstr "Êtes-vous sûr de vouloir supprimer « %(object)s » ?" +msgstr "" +"Êtes-vous sûr de vouloir supprimer le document « %(object)s » ?" #: fargo/templates/fargo/userdocument_confirm_delete.html:11 msgid "Delete" diff --git a/fargo/oauth2/views.py b/fargo/oauth2/views.py index d2b9428..a0dc471 100644 --- a/fargo/oauth2/views.py +++ b/fargo/oauth2/views.py @@ -107,6 +107,10 @@ class OAuth2AuthorizeView(FormView): authorization.code) return self.redirect(code=authorization.code, state=self.state) + def get_context_data(self, **kwargs): + kwargs['oauth2_client'] = self.client + return super(OAuth2AuthorizeView , self).get_context_data(**kwargs) + authorize_get_document = login_required(OAuth2AuthorizeView.as_view()) @@ -207,13 +211,15 @@ class OAuth2AuthorizePutView(TemplateView): return super(OAuth2AuthorizePutView, self).dispatch(request) def get_context_data(self, **kwargs): - if self.oauth2_document: + kwargs['oauth2_document'] = self.oauth2_document + kwargs['filename'] = self.oauth2_document.filename + kwargs['thumbnail'] = self.oauth2_document.document.thumbnail_data_url + kwargs['oauth2_client'] = self.oauth2_document.client # verify if document already exists if not UserDocument.objects.filter( user=self.request.user, document=self.oauth2_document.document).exists(): - kwargs['filename'] = self.oauth2_document.filename kwargs['error_message'] = '' else: kwargs['error_message'] = _('This document is already in your portfolio') diff --git a/fargo/templates/fargo/oauth2/authorize.html b/fargo/templates/fargo/oauth2/authorize.html index 319ca02..2a92317 100644 --- a/fargo/templates/fargo/oauth2/authorize.html +++ b/fargo/templates/fargo/oauth2/authorize.html @@ -4,6 +4,9 @@ {% block content %}
{% block form-intro %} + {% blocktrans %} +

The service {{ oauth2_client }} want to get one of your documents.

+ {% endblocktrans %} {% endblock %} {% block form %}
diff --git a/fargo/templates/fargo/oauth2/confirm.html b/fargo/templates/fargo/oauth2/confirm.html index 0156acd..744ccc0 100644 --- a/fargo/templates/fargo/oauth2/confirm.html +++ b/fargo/templates/fargo/oauth2/confirm.html @@ -3,17 +3,24 @@ {% block content %}
+ {% if oauth2_document %} + {% block form-intro %} +

+ {% blocktrans %} + The service {{ oauth2_client }} want to add the document "{{ filename }}" to your portfolio. + {% endblocktrans %} +

+ {% if thumbnail %}

{% endif %} + {% endblock %} + {% endif %} {% if error_message %} {% block error-message %}

{% trans error_message %}

- {% trans "Continue to your client url" %} + + + {% endblock %} {% else %} - {% block form-intro %} -

{% blocktrans %} - Do you accept to add {{ filename }} to your portfolio? - {% endblocktrans %}

- {% endblock %} {% block form %}
{% csrf_token %} -- 2.16.3