diff --git a/apps/participation/templates/participation/team_list.html b/apps/participation/templates/participation/team_list.html new file mode 100644 index 0000000..71d0b98 --- /dev/null +++ b/apps/participation/templates/participation/team_list.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} + +{% load django_tables2 i18n %} + +{% block contenttitle %} +

{% trans "All teams" %}

+{% endblock %} + +{% block content %} +
+ {% render_table table %} +
+{% endblock %} diff --git a/apps/participation/tests.py b/apps/participation/tests.py index 4a6d119..47d2ad2 100644 --- a/apps/participation/tests.py +++ b/apps/participation/tests.py @@ -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. diff --git a/apps/participation/urls.py b/apps/participation/urls.py index b3233dc..f36d8a5 100644 --- a/apps/participation/urls.py +++ b/apps/participation/urls.py @@ -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//", TeamDetailView.as_view(), name="team_detail"), path("team//update/", TeamUpdateView.as_view(), name="update_team"), diff --git a/apps/participation/views.py b/apps/participation/views.py index de74762..7c03eb4 100644 --- a/apps/participation/views.py +++ b/apps/participation/views.py @@ -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. diff --git a/corres2math/templates/base.html b/corres2math/templates/base.html index 8cd6fc7..33a0211 100644 --- a/corres2math/templates/base.html +++ b/corres2math/templates/base.html @@ -70,7 +70,11 @@ {% trans "Calendar" %} {% endif %} - {% if user.is_authenticated and user.registration.participates %} + {% if user.is_authenticated and user.registration.is_admin %} + + {% elif user.is_authenticated and user.registration.participates %} {% if not user.registration.team %}