1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-02-13 23:41:19 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Yohann D'ANELLO
b0e43959eb
Don't display notes too early 2021-01-18 16:54:57 +01:00
Yohann D'ANELLO
70d2ade6a3
Display pools only when necessary 2021-01-18 16:49:23 +01:00
Yohann D'ANELLO
364025b195
Add Payment model 2021-01-18 16:35:37 +01:00
5 changed files with 155 additions and 32 deletions

View File

@ -61,46 +61,54 @@
{% render_table teams %}
</div>
<hr>
{% if pools.data %}
<hr>
<h3>{% trans "Pools" %}</h3>
<div id="pools_table">
{% render_table pools %}
</div>
<h3>{% trans "Pools" %}</h3>
<div id="pools_table">
{% render_table pools %}
</div>
{% endif %}
{% if user.registration.is_admin %}
<button class="btn btn-block btn-success" data-toggle="modal" data-target="#addPoolModal">{% trans "Add new pool" %}</button>
{% endif %}
<hr>
{% if notes %}
<hr>
<div class="card bg-light shadow">
<div class="card-header text-center">
<h5>{% trans "Ranking" %}</h5>
<div class="card bg-light shadow">
<div class="card-header text-center">
<h5>{% trans "Ranking" %}</h5>
</div>
<div class="card-body">
<ul>
{% for participation, note in notes %}
<li><strong>{{ participation.team }} :</strong> {{ note }}</li>
{% endfor %}
</ul>
</div>
</div>
<div class="card-body">
<ul>
{% for participation, note in notes %}
<li><strong>{{ participation.team }} :</strong> {{ note }}</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% trans "Add pool" as modal_title %}
{% trans "Add" as modal_button %}
{% url "participation:pool_create" as modal_action %}
{% include "base_modal.html" with modal_id="addPool" %}
{% if user.registration.is_admin %}
{% trans "Add pool" as modal_title %}
{% trans "Add" as modal_button %}
{% url "participation:pool_create" as modal_action %}
{% include "base_modal.html" with modal_id="addPool" %}
{% endif %}
{% endblock %}
{% block extrajavascript %}
<script>
$(document).ready(function () {
$('button[data-target="#addPoolModal"]').click(function() {
let modalBody = $("#addPoolModal div.modal-body");
if (!modalBody.html().trim())
modalBody.load("{% url "participation:pool_create" %} #form-content")
});
{% if user.registration.is_admin %}
$('button[data-target="#addPoolModal"]').click(function() {
let modalBody = $("#addPoolModal div.modal-body");
if (!modalBody.html().trim())
modalBody.load("{% url "participation:pool_create" %} #form-content")
});
{% endif %}
});
</script>
{% endblock %}

View File

@ -466,8 +466,10 @@ class TournamentDetailView(DetailView):
notes = dict()
for participation in self.object.participations.all():
notes[participation] = sum(pool.average(participation)
for pool in self.object.pools.filter(participations=participation).all())
note = sum(pool.average(participation)
for pool in self.object.pools.filter(participations=participation).all())
if note:
notes[participation] = note
context["notes"] = sorted(notes.items(), key=lambda x: x[1], reverse=True)
return context
@ -536,7 +538,9 @@ class PoolDetailView(LoginRequiredMixin, DetailView):
notes = dict()
for participation in self.object.participations.all():
notes[participation] = self.object.average(participation)
note = self.object.average(participation)
if note:
notes[participation] = note
context["notes"] = sorted(notes.items(), key=lambda x: x[1], reverse=True)
return context

View File

@ -0,0 +1,26 @@
# Generated by Django 3.0.11 on 2021-01-18 15:35
from django.db import migrations, models
import django.db.models.deletion
import registration.models
class Migration(migrations.Migration):
dependencies = [
('registration', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Payment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('type', models.CharField(blank=True, choices=[('', 'No payment'), ('helloasso', 'Hello Asso'), ('scholarship', 'Scholarship'), ('bank_transfer', 'Bank transfer'), ('free', 'The tournament is free')], default='', max_length=16, verbose_name='type')),
('scholarship_file', models.FileField(blank=True, default='', help_text='only if you have a scholarship.', unique=True, upload_to=registration.models.get_scholarship_filename, verbose_name='scholarship file')),
('additional_information', models.TextField(blank=True, default='', help_text='To help us to find your payment.', verbose_name='additional information')),
('valid', models.BooleanField(default=False, null=True, verbose_name='valid')),
('registration', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='registration', to='registration.ParticipantRegistration', verbose_name='registration')),
],
),
]

View File

@ -288,3 +288,52 @@ class AdminRegistration(VolunteerRegistration):
class Meta:
verbose_name = _("admin registration")
verbose_name_plural = _("admin registrations")
def get_scholarship_filename(instance, filename):
return f"authorization/scholarship/scholarship_{instance.registration.pk}"
class Payment(models.Model):
registration = models.OneToOneField(
ParticipantRegistration,
on_delete=models.CASCADE,
related_name="registration",
verbose_name=_("registration"),
)
type = models.CharField(
verbose_name=_("type"),
max_length=16,
choices=[
('', _("No payment")),
('helloasso', "Hello Asso"),
('scholarship', _("Scholarship")),
('bank_transfer', _("Bank transfer")),
('free', _("The tournament is free")),
],
blank=True,
default="",
)
scholarship_file = models.FileField(
verbose_name=_("scholarship file"),
help_text=_("only if you have a scholarship."),
upload_to=get_scholarship_filename,
unique=True,
blank=True,
default="",
)
additional_information = models.TextField(
verbose_name=_("additional information"),
help_text=_("To help us to find your payment."),
blank=True,
default="",
)
valid = models.BooleanField(
verbose_name=_("valid"),
null=True,
default=False,
)

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: TFJM\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-18 16:13+0100\n"
"POT-Creation-Date: 2021-01-18 16:33+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"
@ -100,7 +100,7 @@ msgid "Changelog of type \"{action}\" for model {model} at {timestamp}"
msgstr "Changelog de type \"{action}\" pour le modèle {model} le {timestamp}"
#: apps/participation/admin.py:19 apps/participation/models.py:297
#: apps/participation/tables.py:44
#: apps/participation/tables.py:44 apps/registration/models.py:336
msgid "valid"
msgstr "valide"
@ -1017,7 +1017,7 @@ msgstr "email confirmé"
msgid "Activate your TFJM² account"
msgstr "Activez votre compte du TFJM²"
#: apps/registration/models.py:99
#: apps/registration/models.py:99 apps/registration/models.py:302
msgid "registration"
msgstr "inscription"
@ -1117,6 +1117,42 @@ msgstr "inscription d'administrateur"
msgid "admin registrations"
msgstr "inscriptions d'administrateur"
#: apps/registration/models.py:306
msgid "type"
msgstr "type"
#: apps/registration/models.py:309
msgid "No payment"
msgstr "Pas de paiement"
#: apps/registration/models.py:311
msgid "Scholarship"
msgstr "Notification de bourse"
#: apps/registration/models.py:312
msgid "Bank transfer"
msgstr "Virement bancaire"
#: apps/registration/models.py:313
msgid "The tournament is free"
msgstr "Le tournoi est gratuit"
#: apps/registration/models.py:320
msgid "scholarship file"
msgstr "Notification de bourse"
#: apps/registration/models.py:321
msgid "only if you have a scholarship."
msgstr "Nécessaire seulement si vous déclarez être boursier."
#: apps/registration/models.py:329
msgid "additional information"
msgstr "informations additionnelles"
#: apps/registration/models.py:330
msgid "To help us to find your payment."
msgstr "Pour nous aider à retrouver votre paiement, si nécessaire."
#: apps/registration/tables.py:17
msgid "last name"
msgstr "nom de famille"