mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-24 18:22:24 +00:00
Display details about tournaments
This commit is contained in:
parent
bf6f87ee89
commit
0f65bc4561
@ -101,8 +101,12 @@ class TournamentForm(forms.ModelForm):
|
||||
format=formats.get_format_lazy(format_type="DATETIME_INPUT_FORMATS", use_l10n=True)[0])
|
||||
self.fields["solution_limit"].widget = DateTimePickerInput(
|
||||
format=formats.get_format_lazy(format_type="DATETIME_INPUT_FORMATS", use_l10n=True)[0])
|
||||
self.fields["solutions_draw"].widget = DateTimePickerInput(
|
||||
format=formats.get_format_lazy(format_type="DATETIME_INPUT_FORMATS", use_l10n=True)[0])
|
||||
self.fields["syntheses_first_phase_limit"].widget = DateTimePickerInput(
|
||||
format=formats.get_format_lazy(format_type="DATETIME_INPUT_FORMATS", use_l10n=True)[0])
|
||||
self.fields["solutions_available_second_phase"].widget = DateTimePickerInput(
|
||||
format=formats.get_format_lazy(format_type="DATETIME_INPUT_FORMATS", use_l10n=True)[0])
|
||||
self.fields["syntheses_second_phase_limit"].widget = DateTimePickerInput(
|
||||
format=formats.get_format_lazy(format_type="DATETIME_INPUT_FORMATS", use_l10n=True)[0])
|
||||
|
||||
|
18
apps/participation/migrations/0004_tournament_price.py
Normal file
18
apps/participation/migrations/0004_tournament_price.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.11 on 2021-01-01 10:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('participation', '0003_tournament_max_teams'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='tournament',
|
||||
name='price',
|
||||
field=models.PositiveSmallIntegerField(default=21, verbose_name='price'),
|
||||
),
|
||||
]
|
24
apps/participation/migrations/0005_auto_20210101_1149.py
Normal file
24
apps/participation/migrations/0005_auto_20210101_1149.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Generated by Django 3.0.11 on 2021-01-01 10:49
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('participation', '0004_tournament_price'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='tournament',
|
||||
name='solutions_available_second_phase',
|
||||
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='date when the solutions for the second round become available'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='tournament',
|
||||
name='solutions_draw',
|
||||
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='random draw for solutions'),
|
||||
),
|
||||
]
|
@ -143,6 +143,11 @@ class Tournament(models.Model):
|
||||
default=9,
|
||||
)
|
||||
|
||||
price = models.PositiveSmallIntegerField(
|
||||
verbose_name=_("price"),
|
||||
default=21,
|
||||
)
|
||||
|
||||
inscription_limit = models.DateTimeField(
|
||||
verbose_name=_("limit date for registrations"),
|
||||
default=timezone.now,
|
||||
@ -153,11 +158,21 @@ class Tournament(models.Model):
|
||||
default=timezone.now,
|
||||
)
|
||||
|
||||
solutions_draw = models.DateTimeField(
|
||||
verbose_name=_("random draw for solutions"),
|
||||
default=timezone.now,
|
||||
)
|
||||
|
||||
syntheses_first_phase_limit = models.DateTimeField(
|
||||
verbose_name=_("limit date to upload the syntheses for the first phase"),
|
||||
default=timezone.now,
|
||||
)
|
||||
|
||||
solutions_available_second_phase = models.DateTimeField(
|
||||
verbose_name=_("date when the solutions for the second round become available"),
|
||||
default=timezone.now,
|
||||
)
|
||||
|
||||
syntheses_second_phase_limit = models.DateTimeField(
|
||||
verbose_name=_("limit date to upload the syntheses for the second phase"),
|
||||
default=timezone.now,
|
||||
|
@ -16,17 +16,12 @@ class TeamTable(tables.Table):
|
||||
verbose_name=lambda: _("name").capitalize(),
|
||||
)
|
||||
|
||||
problem = tables.Column(
|
||||
accessor="participation__problem",
|
||||
verbose_name=lambda: _("problem number").capitalize(),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
attrs = {
|
||||
'class': 'table table condensed table-striped',
|
||||
}
|
||||
model = Team
|
||||
fields = ('name', 'trigram', 'problem',)
|
||||
fields = ('name', 'trigram',)
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
|
||||
|
||||
@ -44,16 +39,12 @@ class ParticipationTable(tables.Table):
|
||||
accessor="team__trigram",
|
||||
)
|
||||
|
||||
problem = tables.Column(
|
||||
verbose_name=lambda: _("problem number").capitalize(),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
attrs = {
|
||||
'class': 'table table condensed table-striped',
|
||||
}
|
||||
model = Team
|
||||
fields = ('name', 'trigram', 'problem',)
|
||||
fields = ('name', 'trigram', 'valid',)
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
|
||||
|
||||
|
@ -0,0 +1,63 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% load getconfig i18n django_tables2 %}
|
||||
|
||||
{% block content %}
|
||||
<div class="card bg-light shadow">
|
||||
<div class="card-header text-center">
|
||||
<h4>{{ tournament.name }}</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<dl class="row">
|
||||
<dt class="col-xl-6 text-right">{% trans 'organizers'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ tournament.organizers.all|join:", " }}</dd>
|
||||
|
||||
<dt class="col-xl-6 text-right">{% trans 'size'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ tournament.max_teams }}</dd>
|
||||
|
||||
<dt class="col-xl-6 text-right">{% trans 'place'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ tournament.place }}</dd>
|
||||
|
||||
<dt class="col-xl-6 text-right">{% trans 'price'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{% if tournament.price %}{{ tournament.price }} €{% else %}{% trans "Free" %}{% endif %}</dd>
|
||||
|
||||
<dt class="col-xl-6 text-right">{% trans 'dates'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{% trans "From" %} {{ tournament.date_start }} {% trans "to" %} {{ tournament.date_end }}</dd>
|
||||
|
||||
<dt class="col-xl-6 text-right">{% trans 'date of registration closing'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ tournament.inscription_limit }}</dd>
|
||||
|
||||
<dt class="col-xl-6 text-right">{% trans 'date of maximal solution submission'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ tournament.solution_limit }}</dd>
|
||||
|
||||
<dt class="col-xl-6 text-right">{% trans 'date of the random draw'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ tournament.solutions_draw }}</dd>
|
||||
|
||||
<dt class="col-xl-6 text-right">{% trans 'date of maximal syntheses submission for the first round'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ tournament.syntheses_first_phase_limit }}</dd>
|
||||
|
||||
<dt class="col-xl-6 text-right">{% trans 'date when solutions of round 2 are available'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ tournament.solutions_available_second_phase }}</dd>
|
||||
|
||||
<dt class="col-xl-6 text-right">{% trans 'date of maximal syntheses submission for the second round'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ tournament.syntheses_second_phase_limit }}</dd>
|
||||
|
||||
<dt class="col-xl-6 text-right">{% trans 'description'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ tournament.description }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{% if user.registration.isadmin or user.registration in tournament.organizers.all %}
|
||||
<div class="card-footer text-center">
|
||||
<a href="{% url "participation:tournament_update" pk=tournament.pk %}"><button class="btn btn-secondary">{% trans "Edit tournament" %}</button></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>{% trans "Teams" %}</h3>
|
||||
<div id="teams_table">
|
||||
{% render_table teams %}
|
||||
</div>
|
||||
{% endblock %}
|
@ -8,6 +8,10 @@
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
</div>
|
||||
<button class="btn btn-success" type="submit">{% trans "Create" %}</button>
|
||||
{% if object.pk %}
|
||||
<button class="btn btn-primary" type="submit">{% trans "Update" %}</button>
|
||||
{% else %}
|
||||
<button class="btn btn-success" type="submit">{% trans "Create" %}</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endblock content %}
|
||||
|
@ -26,7 +26,7 @@ from tfjm.views import AdminMixin
|
||||
from .forms import JoinTeamForm, ParticipationForm, RequestValidationForm, TeamForm, ValidateParticipationForm, \
|
||||
TournamentForm
|
||||
from .models import Participation, Team, Tournament
|
||||
from .tables import TeamTable, TournamentTable
|
||||
from .tables import TeamTable, TournamentTable, ParticipationTable
|
||||
|
||||
|
||||
class CreateTeamView(LoginRequiredMixin, CreateView):
|
||||
@ -129,7 +129,7 @@ class TeamListView(AdminMixin, SingleTableView):
|
||||
"""
|
||||
model = Team
|
||||
table_class = TeamTable
|
||||
ordering = ('participation__problem', 'trigram',)
|
||||
ordering = ('trigram',)
|
||||
|
||||
|
||||
class MyTeamDetailView(LoginRequiredMixin, RedirectView):
|
||||
@ -430,3 +430,8 @@ class TournamentDetailView(DetailView):
|
||||
Display tournament detail.
|
||||
"""
|
||||
model = Tournament
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["teams"] = ParticipationTable(self.object.participations.all())
|
||||
return context
|
||||
|
14
apps/registration/templatetags/getconfig.py
Normal file
14
apps/registration/templatetags/getconfig.py
Normal file
@ -0,0 +1,14 @@
|
||||
# Copyright (C) 2020 by Animath
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import os
|
||||
|
||||
from django import template
|
||||
|
||||
|
||||
def get_env(key: str) -> str:
|
||||
return os.getenv(key)
|
||||
|
||||
|
||||
register = template.Library()
|
||||
register.filter("get_env", get_env)
|
Loading…
Reference in New Issue
Block a user