Update the teams of a pool
This commit is contained in:
parent
7a6aaa3f58
commit
f3f862c1ab
|
@ -129,3 +129,19 @@ class PoolForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Pool
|
model = Pool
|
||||||
fields = ('tournament', 'round', 'juries',)
|
fields = ('tournament', 'round', 'juries',)
|
||||||
|
widgets = {
|
||||||
|
"juries": forms.CheckboxSelectMultiple,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class PoolTeamsForm(forms.ModelForm):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields["participations"].queryset = self.instance.tournament.participations.all()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Pool
|
||||||
|
fields = ('participations',)
|
||||||
|
widgets = {
|
||||||
|
"participations": forms.CheckboxSelectMultiple,
|
||||||
|
}
|
||||||
|
|
|
@ -1 +1,64 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="card bg-light shadow">
|
||||||
|
<div class="card-header text-center">
|
||||||
|
<h4>{{ pool }}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-sm-2">{% trans "Tournament:" %}</dt>
|
||||||
|
<dd class="col-sm-10">{{ pool.tournament }}</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-2">{% trans "Round:" %}</dt>
|
||||||
|
<dd class="col-sm-10">{{ pool.get_round_display }}</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-2">{% trans "Teams:" %}</dt>
|
||||||
|
<dd class="col-sm-10">
|
||||||
|
{% for participation in pool.participations.all %}
|
||||||
|
<a href="{{ participation.get_absolute_url }}" data-turbolinks="false">{{ participation.team }}{% if not forloop.last %}, {% endif %}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-2">{% trans "Juries:" %}</dt>
|
||||||
|
<dd class="col-sm-10">{{ pool.juries.all|join:", " }}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
{% if user.registration.is_admin %}
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
<button class="btn btn-primary" data-toggle="modal" data-target="#updatePoolModal">{% trans "Update" %}</button>
|
||||||
|
<button class="btn btn-primary" data-toggle="modal" data-target="#updateTeamsModal">{% trans "Update teams" %}</button>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% trans "Update pool" as modal_title %}
|
||||||
|
{% trans "Update" as modal_button %}
|
||||||
|
{% url "participation:pool_update" pk=pool.pk as modal_action %}
|
||||||
|
{% include "base_modal.html" with modal_id="updatePool" %}
|
||||||
|
|
||||||
|
{% trans "Update teams" as modal_title %}
|
||||||
|
{% trans "Update" as modal_button %}
|
||||||
|
{% url "participation:pool_update_teams" pk=pool.pk as modal_action %}
|
||||||
|
{% include "base_modal.html" with modal_id="updateTeams" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extrajavascript %}
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('button[data-target="#updatePoolModal"]').click(function() {
|
||||||
|
let modalBody = $("#updatePoolModal div.modal-body");
|
||||||
|
if (!modalBody.html().trim())
|
||||||
|
modalBody.load("{% url "participation:pool_update" pk=pool.pk %} #form-content")
|
||||||
|
});
|
||||||
|
|
||||||
|
$('button[data-target="#updateTeamsModal"]').click(function() {
|
||||||
|
let modalBody = $("#updateTeamsModal div.modal-body");
|
||||||
|
if (!modalBody.html().trim())
|
||||||
|
modalBody.load("{% url "participation:pool_update_teams" pk=pool.pk %} #form-content")
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -6,8 +6,9 @@ from django.views.generic import TemplateView
|
||||||
|
|
||||||
from .views import CreateTeamView, JoinTeamView, \
|
from .views import CreateTeamView, JoinTeamView, \
|
||||||
MyParticipationDetailView, MyTeamDetailView, ParticipationDetailView, PoolCreateView, PoolDetailView, \
|
MyParticipationDetailView, MyTeamDetailView, ParticipationDetailView, PoolCreateView, PoolDetailView, \
|
||||||
PoolUpdateView, TeamAuthorizationsView, TeamDetailView, TeamLeaveView, TeamListView, TeamUpdateView, \
|
PoolUpdateView, PoolUpdateTeamsView, TeamAuthorizationsView, TeamDetailView, TeamLeaveView, TeamListView, \
|
||||||
TournamentCreateView, TournamentDetailView, TournamentListView, TournamentUpdateView, SolutionUploadView
|
TeamUpdateView, TournamentCreateView, TournamentDetailView, TournamentListView, TournamentUpdateView, \
|
||||||
|
SolutionUploadView
|
||||||
|
|
||||||
|
|
||||||
app_name = "participation"
|
app_name = "participation"
|
||||||
|
@ -31,5 +32,6 @@ urlpatterns = [
|
||||||
path("pools/create/", PoolCreateView.as_view(), name="pool_create"),
|
path("pools/create/", PoolCreateView.as_view(), name="pool_create"),
|
||||||
path("pools/<int:pk>/", PoolDetailView.as_view(), name="pool_detail"),
|
path("pools/<int:pk>/", PoolDetailView.as_view(), name="pool_detail"),
|
||||||
path("pools/<int:pk>/update/", PoolUpdateView.as_view(), name="pool_update"),
|
path("pools/<int:pk>/update/", PoolUpdateView.as_view(), name="pool_update"),
|
||||||
|
path("pools/<int:pk>/update-teams/", PoolUpdateTeamsView.as_view(), name="pool_update_teams"),
|
||||||
path("chat/", TemplateView.as_view(template_name="participation/chat.html"), name="chat")
|
path("chat/", TemplateView.as_view(template_name="participation/chat.html"), name="chat")
|
||||||
]
|
]
|
||||||
|
|
|
@ -23,8 +23,8 @@ from tfjm.lists import get_sympa_client
|
||||||
from tfjm.matrix import Matrix
|
from tfjm.matrix import Matrix
|
||||||
from tfjm.views import AdminMixin
|
from tfjm.views import AdminMixin
|
||||||
|
|
||||||
from .forms import JoinTeamForm, ParticipationForm, PoolForm, RequestValidationForm, SolutionForm, TeamForm,\
|
from .forms import JoinTeamForm, ParticipationForm, PoolForm, PoolTeamsForm, RequestValidationForm, SolutionForm, \
|
||||||
TournamentForm, ValidateParticipationForm
|
TeamForm, TournamentForm, ValidateParticipationForm
|
||||||
from .models import Participation, Team, Tournament, Solution, Pool
|
from .models import Participation, Team, Tournament, Solution, Pool
|
||||||
from .tables import TeamTable, TournamentTable, ParticipationTable, PoolTable
|
from .tables import TeamTable, TournamentTable, ParticipationTable, PoolTable
|
||||||
|
|
||||||
|
@ -482,3 +482,8 @@ class PoolDetailView(AdminMixin, DetailView):
|
||||||
class PoolUpdateView(AdminMixin, UpdateView):
|
class PoolUpdateView(AdminMixin, UpdateView):
|
||||||
model = Pool
|
model = Pool
|
||||||
form_class = PoolForm
|
form_class = PoolForm
|
||||||
|
|
||||||
|
|
||||||
|
class PoolUpdateTeamsView(AdminMixin, UpdateView):
|
||||||
|
model = Pool
|
||||||
|
form_class = PoolTeamsForm
|
||||||
|
|
Loading…
Reference in New Issue