Display scholarship attestation

This commit is contained in:
Yohann D'ANELLO 2021-01-18 23:39:02 +01:00
parent 40fd5a56c1
commit 96adb01edb
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
4 changed files with 56 additions and 16 deletions

View File

@ -130,6 +130,13 @@
<i class="fas fa-money-bill-wave"></i> {% trans "Update payment" %}
</button>
{% endif %}
{% if user_object.registration.payment.type == "scholarship" %}
{% if user.registration.is_admin or user == user_object %}
<a href="{{ user_object.registration.payment.scholarship_file.url }}" class="btn btn-info" data-turbolinks="false">
<i class="fas fa-file-pdf"></i> {% trans "Download scholarship attestation" %}
</a>
{% endif %}
{% endif %}
{% endwith %}
</dd>
</dl>

View File

@ -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.

View File

@ -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 <yohann.danello@animath.fr>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"

View File

@ -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/<str:filename>/', ParentalAuthorizationView.as_view(),
name='parental_authorization'),
path('media/authorization/scholarship/<str:filename>/', ScholarshipView.as_view(),
name='scholarship'),
path('media/solutions/<str:filename>/', SolutionView.as_view(),
name='solution'),