diff --git a/apps/registration/templates/registration/user_detail.html b/apps/registration/templates/registration/user_detail.html
index d7310b8..e29baf4 100644
--- a/apps/registration/templates/registration/user_detail.html
+++ b/apps/registration/templates/registration/user_detail.html
@@ -130,6 +130,13 @@
{% trans "Update payment" %}
{% endif %}
+ {% if user_object.registration.payment.type == "scholarship" %}
+ {% if user.registration.is_admin or user == user_object %}
+
+ {% trans "Download scholarship attestation" %}
+
+ {% endif %}
+ {% endif %}
{% endwith %}
diff --git a/apps/registration/views.py b/apps/registration/views.py
index 5b89d56..53d890d 100644
--- a/apps/registration/views.py
+++ b/apps/registration/views.py
@@ -474,6 +474,28 @@ class ParentalAuthorizationView(LoginRequiredMixin, View):
return FileResponse(open(path, "rb"), content_type=mime_type, filename=true_file_name)
+class ScholarshipView(LoginRequiredMixin, View):
+ """
+ Display the sent scholarship paper.
+ """
+ def get(self, request, *args, **kwargs):
+ filename = kwargs["filename"]
+ path = f"media/authorization/scholarship/{filename}"
+ if not os.path.exists(path):
+ raise Http404
+ payment = Payment.objects.get(scholarship_file__endswith=filename)
+ user = request.user
+ if not (payment.registration.user == user or user.registration.is_admin):
+ raise PermissionDenied
+ # Guess mime type of the file
+ mime = Magic(mime=True)
+ mime_type = mime.from_file(path)
+ ext = mime_type.split("/")[1].replace("jpeg", "jpg")
+ # Replace file name
+ true_file_name = _("Scholarship attestation of {user}.{ext}").format(user=str(user.registration), ext=ext)
+ return FileResponse(open(path, "rb"), content_type=mime_type, filename=true_file_name)
+
+
class SolutionView(LoginRequiredMixin, View):
"""
Display the sent solution.
diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po
index 8554e38..7b48edd 100644
--- a/locale/fr/LC_MESSAGES/django.po
+++ b/locale/fr/LC_MESSAGES/django.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: TFJM\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-01-18 23:25+0100\n"
+"POT-Creation-Date: 2021-01-18 23:37+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Yohann D'ANELLO \n"
"Language-Team: LANGUAGE \n"
@@ -487,9 +487,9 @@ msgstr "Rejoindre"
#: apps/participation/templates/participation/update_team.html:12
#: apps/registration/templates/registration/payment_form.html:49
#: apps/registration/templates/registration/update_user.html:16
-#: apps/registration/templates/registration/user_detail.html:140
-#: apps/registration/templates/registration/user_detail.html:149
-#: apps/registration/templates/registration/user_detail.html:177
+#: apps/registration/templates/registration/user_detail.html:147
+#: apps/registration/templates/registration/user_detail.html:156
+#: apps/registration/templates/registration/user_detail.html:184
msgid "Update"
msgstr "Modifier"
@@ -543,10 +543,10 @@ msgstr "Envoyer une solution"
#: apps/registration/templates/registration/upload_health_sheet.html:17
#: apps/registration/templates/registration/upload_parental_authorization.html:17
#: apps/registration/templates/registration/upload_photo_authorization.html:18
-#: apps/registration/templates/registration/user_detail.html:155
-#: apps/registration/templates/registration/user_detail.html:160
-#: apps/registration/templates/registration/user_detail.html:165
-#: apps/registration/templates/registration/user_detail.html:170
+#: apps/registration/templates/registration/user_detail.html:162
+#: apps/registration/templates/registration/user_detail.html:167
+#: apps/registration/templates/registration/user_detail.html:172
+#: apps/registration/templates/registration/user_detail.html:177
msgid "Upload"
msgstr "Téléverser"
@@ -1527,30 +1527,34 @@ msgid "valid:"
msgstr "valide :"
#: apps/registration/templates/registration/user_detail.html:130
-#: apps/registration/templates/registration/user_detail.html:176
+#: apps/registration/templates/registration/user_detail.html:183
msgid "Update payment"
msgstr "Modifier le paiement"
-#: apps/registration/templates/registration/user_detail.html:142
+#: apps/registration/templates/registration/user_detail.html:136
+msgid "Download scholarship attestation"
+msgstr "Télécharger l'attestation de bourse"
+
+#: apps/registration/templates/registration/user_detail.html:149
msgid "Impersonate"
msgstr "Impersonifier"
-#: apps/registration/templates/registration/user_detail.html:148
+#: apps/registration/templates/registration/user_detail.html:155
msgid "Update user"
msgstr "Modifier l'utilisateur"
-#: apps/registration/templates/registration/user_detail.html:154
+#: apps/registration/templates/registration/user_detail.html:161
#: apps/registration/views.py:312
msgid "Upload photo authorization"
msgstr "Téléverser l'autorisation de droit à l'image"
-#: apps/registration/templates/registration/user_detail.html:159
+#: apps/registration/templates/registration/user_detail.html:166
#: apps/registration/views.py:338
msgid "Upload health sheet"
msgstr "Téléverser la fiche sanitaire"
-#: apps/registration/templates/registration/user_detail.html:164
-#: apps/registration/templates/registration/user_detail.html:169
+#: apps/registration/templates/registration/user_detail.html:171
+#: apps/registration/templates/registration/user_detail.html:176
#: apps/registration/views.py:364
msgid "Upload parental authorization"
msgstr "Téléverser l'autorisation parentale"
@@ -1604,6 +1608,11 @@ msgstr "Fiche sanitaire de {student}.{ext}"
msgid "Parental authorization of {student}.{ext}"
msgstr "Autorisation parentale de {student}.{ext}"
+#: apps/registration/views.py:495
+#, python-brace-format
+msgid "Scholarship attestation of {user}.{ext}"
+msgstr "Notification de bourse de {user}.{ext}"
+
#: tfjm/settings.py:162
msgid "English"
msgstr "Anglais"
diff --git a/tfjm/urls.py b/tfjm/urls.py
index 42aa854..00e1559 100644
--- a/tfjm/urls.py
+++ b/tfjm/urls.py
@@ -22,7 +22,7 @@ from django.urls import include, path
from django.views.defaults import bad_request, page_not_found, permission_denied, server_error
from django.views.generic import TemplateView
from registration.views import HealthSheetView, ParentalAuthorizationView, PhotoAuthorizationView, \
- SolutionView, SynthesisView
+ ScholarshipView, SolutionView, SynthesisView
from .views import AdminSearchView
@@ -45,6 +45,8 @@ urlpatterns = [
name='health_sheet'),
path('media/authorization/parental//', ParentalAuthorizationView.as_view(),
name='parental_authorization'),
+ path('media/authorization/scholarship//', ScholarshipView.as_view(),
+ name='scholarship'),
path('media/solutions//', SolutionView.as_view(),
name='solution'),