1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-06-21 07:58:22 +02:00

Add team table

This commit is contained in:
Yohann D'ANELLO
2020-11-16 11:58:05 +01:00
parent b0a3a22f83
commit ace1dbdc75
6 changed files with 171 additions and 108 deletions

View File

@ -0,0 +1,13 @@
{% extends "base.html" %}
{% load django_tables2 i18n %}
{% block contenttitle %}
<h1>{% trans "All teams" %}</h1>
{% endblock %}
{% block content %}
<div id="form-content">
{% render_table table %}
</div>
{% endblock %}

View File

@ -185,6 +185,13 @@ class TestStudentParticipation(TestCase):
))
self.assertEqual(response.status_code, 403)
def test_team_list(self):
"""
Test to display the list of teams.
"""
response = self.client.get(reverse("participation:team_list"))
self.assertTrue(response.status_code, 200)
def test_no_myteam_redirect_noteam(self):
"""
Test redirection.

View File

@ -4,7 +4,7 @@ from django.views.generic import TemplateView
from .views import CalendarView, CreateQuestionView, CreateTeamView, DeleteQuestionView, JoinTeamView, \
MyParticipationDetailView, MyTeamDetailView, ParticipationDetailView, PhaseUpdateView, \
SetParticipationReceiveParticipationView, SetParticipationSendParticipationView, TeamAuthorizationsView, \
TeamDetailView, TeamLeaveView, TeamUpdateView, UpdateQuestionView, UploadVideoView
TeamDetailView, TeamLeaveView, TeamListView, TeamUpdateView, UpdateQuestionView, UploadVideoView
app_name = "participation"
@ -12,6 +12,7 @@ app_name = "participation"
urlpatterns = [
path("create_team/", CreateTeamView.as_view(), name="create_team"),
path("join_team/", JoinTeamView.as_view(), name="join_team"),
path("teams/", TeamListView.as_view(), name="team_list"),
path("team/", MyTeamDetailView.as_view(), name="my_team_detail"),
path("team/<int:pk>/", TeamDetailView.as_view(), name="team_detail"),
path("team/<int:pk>/update/", TeamUpdateView.as_view(), name="update_team"),

View File

@ -23,7 +23,7 @@ from .forms import JoinTeamForm, ParticipationForm, PhaseForm, QuestionForm, \
ReceiveParticipationForm, RequestValidationForm, SendParticipationForm, TeamForm, \
UploadVideoForm, ValidateParticipationForm
from .models import Participation, Phase, Question, Team, Video
from .tables import CalendarTable
from .tables import CalendarTable, TeamTable
class CreateTeamView(LoginRequiredMixin, CreateView):
@ -119,6 +119,15 @@ class JoinTeamView(LoginRequiredMixin, FormView):
return reverse_lazy("participation:team_detail", args=(self.object.pk,))
class TeamListView(AdminMixin, SingleTableView):
"""
Display the whole list of teams
"""
model = Team
table_class = TeamTable
ordering = ('participation__problem', 'trigram',)
class MyTeamDetailView(LoginRequiredMixin, RedirectView):
"""
Redirect to the detail of the team in which the user is.