mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-02-13 23:41:19 +00:00
Compare commits
6 Commits
ef4d74545a
...
cb5f597547
Author | SHA1 | Date | |
---|---|---|---|
|
cb5f597547 | ||
|
96adb01edb | ||
|
40fd5a56c1 | ||
|
00c936f909 | ||
|
0346df11c2 | ||
|
d02db9b858 |
54
apps/participation/management/commands/check_hello_asso.py
Normal file
54
apps/participation/management/commands/check_hello_asso.py
Normal file
@ -0,0 +1,54 @@
|
||||
# Copyright (C) 2020 by Animath
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import os
|
||||
|
||||
import requests
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.management import BaseCommand
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
def handle(self, *args, **options): # noqa: C901
|
||||
organization = "animath"
|
||||
form_slug = "tfjmm-2018"
|
||||
from_date = "2000-01-01"
|
||||
url = f"https://api.helloasso.com/v5/organizations/{organization}/forms/Event/{form_slug}/payments" \
|
||||
f"?from={from_date}&pageIndex=1&pageSize=10000&retrieveOfflineDonations=false"
|
||||
headers = {
|
||||
"Accept": "application/json",
|
||||
"Authorization": f"Bearer {os.getenv('HELLO_ASSO_TOKEN', '')}",
|
||||
}
|
||||
http_response = requests.get(url, headers=headers)
|
||||
response = http_response.json()
|
||||
|
||||
if http_response.status_code != 200:
|
||||
message = response["message"]
|
||||
self.stderr.write(f"Error while querying Hello Asso: {message}")
|
||||
return
|
||||
|
||||
for payment in response:
|
||||
if payment["state"] != "Authorized":
|
||||
continue
|
||||
|
||||
payer = payment["payer"]
|
||||
email = payer["email"]
|
||||
qs = User.objects.filter(email=email)
|
||||
if not qs.exists():
|
||||
self.stderr.write(f"Warning: a payment was found by the email address {email}, "
|
||||
"but this user is unknown.")
|
||||
continue
|
||||
user = qs.get()
|
||||
if not user.registration.participates:
|
||||
self.stderr.write(f"Warning: a payment was found by the email address {email}, "
|
||||
"but this user is not a participant.")
|
||||
continue
|
||||
payment_obj = user.registration.payment
|
||||
payment_obj.valid = True
|
||||
payment_obj.type = "helloasso"
|
||||
payment_obj.additional_information = f"Identifiant de transation : {payment['id']}\n" \
|
||||
f"Date : {payment['date']}\n" \
|
||||
f"Reçu : {payment['paymentReceiptUrl']}\n" \
|
||||
f"Montant : {payment['amount'] / 100:.2f} €"
|
||||
payment_obj.save()
|
||||
self.stdout.write(f"{payment_obj} is validated")
|
@ -3,7 +3,7 @@
|
||||
|
||||
from haystack import indexes
|
||||
|
||||
from .models import Participation, Team
|
||||
from .models import Participation, Team, Tournament
|
||||
|
||||
|
||||
class TeamIndex(indexes.ModelSearchIndex, indexes.Indexable):
|
||||
@ -24,3 +24,13 @@ class ParticipationIndex(indexes.ModelSearchIndex, indexes.Indexable):
|
||||
|
||||
class Meta:
|
||||
model = Participation
|
||||
|
||||
|
||||
class TournamentIndex(indexes.ModelSearchIndex, indexes.Indexable):
|
||||
"""
|
||||
Index all tournaments by their name.
|
||||
"""
|
||||
text = indexes.NgramField(document=True, use_template=True)
|
||||
|
||||
class Meta:
|
||||
model = Tournament
|
||||
|
@ -1,4 +1,3 @@
|
||||
{{ object.team.name }}
|
||||
{{ object.team.trigram }}
|
||||
{{ object.problem }}
|
||||
{{ object.get_problem_display }}
|
||||
{{ object.tournament.name }}
|
||||
|
@ -0,0 +1,3 @@
|
||||
{{ object.name }}
|
||||
{{ object.place }}
|
||||
{{ object.description }}
|
@ -5,6 +5,44 @@
|
||||
{% block content %}
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<div id="form-content">
|
||||
<div class="alert alert-info text-justify">
|
||||
<p>
|
||||
{% blocktrans trimmed with price=payment.registration.team.participation.tournament.price %}
|
||||
The price of the tournament is {{ price }} €. The participation fee is offered for coaches
|
||||
and for students who have a scholarship. If so, please send us your scholarship attestation.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
You can pay with a credit card through
|
||||
<a class="alert-link" href="https://www.helloasso.com/associations/animath/evenements/tfjmm-2018">our Hello Asso page</a>.
|
||||
To make the validation of the payment easier, <span class="text-danger">please use the same e-mail
|
||||
address that you use on this platform.</span> The payment verification will be checked automatically
|
||||
under 10 minutes, you don't necessary need to fill this form.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
You can also send a bank transfer to the bank account of Animath. You must put in the reference of the
|
||||
transfer the mention "TFJMpu" followed by the last name and the first name of the student.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
IBAN : FR76 1027 8065 0000 0206 4290 127<br>
|
||||
BIC : CMCIFR2A
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
If any payment mean is available to you, please contact us at <a class="alert-link" href="mailto:contact@tfjm.org">contact@tfjm.org</a>
|
||||
to find a solution to your difficulties.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
</div>
|
||||
|
@ -98,12 +98,12 @@
|
||||
{% with user_object.registration.responsible_email as email %}
|
||||
<dd class="col-sm-6"><a href="mailto:{{ email }}">{{ email }}</a></dd>
|
||||
{% endwith %}
|
||||
{% elif user_object.registration.coachregistration %}
|
||||
<dt class="col-sm-6 text-right">{% trans "Profesional activity:" %}</dt>
|
||||
<dd class="col-sm-6">{{ user_object.registration.professional_activity }}</dd>
|
||||
{% elif user_object.registration.adminregistration %}
|
||||
{% elif user_object.registration.is_admin %}
|
||||
<dt class="col-sm-6 text-right">{% trans "Role:" %}</dt>
|
||||
<dd class="col-sm-6">{{ user_object.registration.role }}</dd>
|
||||
{% elif user_object.registration.coachregistration or user_object.registration.is_volunteer %}
|
||||
<dt class="col-sm-6 text-right">{% trans "Profesional activity:" %}</dt>
|
||||
<dd class="col-sm-6">{{ user_object.registration.professional_activity }}</dd>
|
||||
{% endif %}
|
||||
|
||||
<dt class="col-sm-6 text-right">{% trans "Grant Animath to contact me in the future about other actions:" %}</dt>
|
||||
@ -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>
|
||||
|
@ -3,5 +3,8 @@
|
||||
{{ object.user.email }}
|
||||
{{ object.type }}
|
||||
{{ object.professional_activity }}
|
||||
{{ object.birth_date }}
|
||||
{{ object.address }}
|
||||
{{ object.phone_number }}
|
||||
{{ object.team.name }}
|
||||
{{ object.team.trigram }}
|
||||
|
@ -4,5 +4,11 @@
|
||||
{{ object.type }}
|
||||
{{ object.get_student_class_display }}
|
||||
{{ object.school }}
|
||||
{{ object.birth_date }}
|
||||
{{ object.address }}
|
||||
{{ object.phone_number }}
|
||||
{{ object.responsible_name }}
|
||||
{{ object.reponsible_phone }}
|
||||
{{ object.reponsible_email }}
|
||||
{{ object.team.name }}
|
||||
{{ object.team.trigram }}
|
||||
|
@ -0,0 +1,5 @@
|
||||
{{ object.user.last_name }}
|
||||
{{ object.user.first_name }}
|
||||
{{ object.user.email }}
|
||||
{{ object.type }}
|
||||
{{ object.professional_activity }}
|
@ -3,8 +3,8 @@
|
||||
|
||||
from django import template
|
||||
from django_tables2 import Table
|
||||
from participation.models import Participation, Team
|
||||
from participation.tables import ParticipationTable, TeamTable
|
||||
from participation.models import Participation, Team, Tournament
|
||||
from participation.tables import ParticipationTable, TeamTable, TournamentTable
|
||||
|
||||
from ..models import Registration
|
||||
from ..tables import RegistrationTable
|
||||
@ -19,6 +19,8 @@ def search_table(results):
|
||||
table_class = TeamTable
|
||||
elif issubclass(model_class, Participation):
|
||||
table_class = ParticipationTable
|
||||
elif issubclass(model_class, Tournament):
|
||||
table_class = TournamentTable
|
||||
return table_class([result.object for result in results], prefix=model_class._meta.model_name)
|
||||
|
||||
|
||||
|
@ -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.
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: TFJM\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-01-18 22:27+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"
|
||||
@ -485,11 +485,11 @@ msgstr "Rejoindre"
|
||||
#: apps/participation/templates/participation/team_detail.html:148
|
||||
#: apps/participation/templates/participation/tournament_form.html:12
|
||||
#: apps/participation/templates/participation/update_team.html:12
|
||||
#: apps/registration/templates/registration/payment_form.html:11
|
||||
#: 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"
|
||||
|
||||
@ -1337,6 +1337,55 @@ msgstr ""
|
||||
msgid "Reset my password"
|
||||
msgstr "Réinitialiser mon mot de passe"
|
||||
|
||||
#: apps/registration/templates/registration/payment_form.html:10
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The price of the tournament is %(price)s €. The participation fee is offered "
|
||||
"for coaches and for students who have a scholarship. If so, please send us "
|
||||
"your scholarship attestation."
|
||||
msgstr ""
|
||||
"Le prix du tournoi est de %(price)s €. Les frais de participation sont "
|
||||
"offerts pour les encadrants et les étudiants boursiers. Si c'est le cas, "
|
||||
"merci de nous transmettre votre notification de bourse."
|
||||
|
||||
#: apps/registration/templates/registration/payment_form.html:17
|
||||
msgid ""
|
||||
"You can pay with a credit card through <a class=\"alert-link\" href="
|
||||
"\"https://www.helloasso.com/associations/animath/evenements/tfjmm-2018\">our "
|
||||
"Hello Asso page</a>. To make the validation of the payment easier, <span "
|
||||
"class=\"text-danger\">please use the same e-mail address that you use on "
|
||||
"this platform.</span> The payment verification will be checked automatically "
|
||||
"under 10 minutes, you don't necessary need to fill this form."
|
||||
msgstr ""
|
||||
"Vous pouvez payer par carte bancaire sur <a class=\"alert-link\" href="
|
||||
"\"https://www.helloasso.com/associations/animath/evenements/"
|
||||
"tfjmm-2018\">notre page Hello Asso</a>. Pour rendre la validation du "
|
||||
"paiement plus facile, <span class=\"text-danger\">merci d'utiliser la même "
|
||||
"adresse e-mail que vous utilisez sur cette plateforme.</span> La "
|
||||
"vérification du paiement sera faite automatiquement sous 10 minutes, vous "
|
||||
"n'avez pas nécessairement besoin de remplir ce formulaire."
|
||||
|
||||
#: apps/registration/templates/registration/payment_form.html:27
|
||||
msgid ""
|
||||
"You can also send a bank transfer to the bank account of Animath. You must "
|
||||
"put in the reference of the transfer the mention \"TFJMpu\" followed by the "
|
||||
"last name and the first name of the student."
|
||||
msgstr ""
|
||||
"Vous pouvez également faire un virement bancaire sur le compte d'Animath. "
|
||||
"Vous devez alors mettre dans la référence du transfert la mention \"TFJMpu\" "
|
||||
"suivie du nom et du prénom de l'élève."
|
||||
|
||||
#: apps/registration/templates/registration/payment_form.html:39
|
||||
msgid ""
|
||||
"If any payment mean is available to you, please contact us at <a class="
|
||||
"\"alert-link\" href=\"mailto:contact@tfjm.org\">contact@tfjm.org</a> to find "
|
||||
"a solution to your difficulties."
|
||||
msgstr ""
|
||||
"Si aucun moyen de paiement ne vous convient, merci de nous contecter à "
|
||||
"l'adresse <a class=\"alert-link\" href=\"mailto:contact@tfjm.org"
|
||||
"\">contact@tfjm.org</a> pour que nous puissions trouver une solution à vos "
|
||||
"difficultés."
|
||||
|
||||
#: apps/registration/templates/registration/signup.html:5
|
||||
#: apps/registration/templates/registration/signup.html:12
|
||||
#: apps/registration/templates/registration/signup.html:19
|
||||
@ -1478,32 +1527,34 @@ msgid "valid:"
|
||||
msgstr "valide :"
|
||||
|
||||
#: apps/registration/templates/registration/user_detail.html:130
|
||||
#: apps/registration/templates/registration/user_detail.html:176
|
||||
#, fuzzy
|
||||
#| msgid "Update team"
|
||||
#: apps/registration/templates/registration/user_detail.html:183
|
||||
msgid "Update payment"
|
||||
msgstr "Modifier l'équipe"
|
||||
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"
|
||||
@ -1557,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"
|
||||
|
@ -1,3 +1,4 @@
|
||||
asgiref~=3.3.1
|
||||
Django~=3.0
|
||||
django-address~=0.2
|
||||
django-bootstrap-datepicker-plus~=3.0
|
||||
@ -18,5 +19,6 @@ phonenumbers~=8.9.10
|
||||
psycopg2-binary~=2.8
|
||||
ipython~=7.19.0
|
||||
python-magic==0.4.18
|
||||
requests~=2.25.0
|
||||
sympasoap~=1.0
|
||||
whoosh~=2.7
|
||||
whoosh~=2.7
|
11
tfjm.cron
11
tfjm.cron
@ -1,8 +1,17 @@
|
||||
# min hour day month weekday command
|
||||
# Envoyer les mails en attente
|
||||
# Send pending mails
|
||||
* * * * * cd /code && python manage.py send_mail -c 1
|
||||
* * * * * cd /code && python manage.py retry_deferred -c 1
|
||||
0 0 * * * cd /code && python manage.py purge_mail_log 7 -c 1
|
||||
|
||||
# Rebuild search index
|
||||
0 * * * * cd /code && python manage.py update_index -v 0
|
||||
|
||||
# Recreate sympa lists
|
||||
*/6 * * * * cd /code && python manage.py fix_sympa_lists &> /dev/null
|
||||
|
||||
# Update matrix channels
|
||||
*/6 * * * * cd /code && python manage.py fix_matrix_channels &> /dev/null
|
||||
|
||||
# Check payments from Hello Asso
|
||||
*/6 * * * * cd /code && python manage.py check_hello_asso &> /dev/null
|
||||
|
@ -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'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user