From b0a3a22f83dec4d69cf5a234ebe2b7b82531b2af Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 4 Nov 2020 13:51:41 +0100 Subject: [PATCH 1/2] Migrate in the entrypoint, not in the docker build --- Dockerfile | 4 +--- entrypoint.sh | 5 ++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index cce2279..ef04fb3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,7 @@ RUN pip install -r requirements.txt --no-cache-dir COPY . /code/ RUN python manage.py collectstatic --noinput && \ - python manage.py compilemessages && \ - python manage.py migrate && \ - python manage.py loaddata initial + python manage.py compilemessages # Configure nginx RUN mkdir /run/nginx diff --git a/entrypoint.sh b/entrypoint.sh index 044f92e..0b67ca4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,10 +2,13 @@ crond -l 0 +python manage.py migrate +python manage.py loaddata initial + nginx if [ "$CORRES2MATH_STAGE" = "prod" ]; then gunicorn -b 0.0.0.0:8000 --workers=2 --threads=4 --worker-class=gthread corres2math.wsgi --access-logfile '-' --error-logfile '-'; else - ./manage.py runserver 0.0.0.0:8000; + python manage.py runserver 0.0.0.0:8000; fi From ace1dbdc75620e4b07cf20058d72df5c8798c2a2 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 16 Nov 2020 11:58:05 +0100 Subject: [PATCH 2/2] Add team table --- .../templates/participation/team_list.html | 13 ++ apps/participation/tests.py | 7 + apps/participation/urls.py | 3 +- apps/participation/views.py | 11 +- corres2math/templates/base.html | 76 +++++--- locale/fr/LC_MESSAGES/django.po | 169 +++++++++--------- 6 files changed, 171 insertions(+), 108 deletions(-) create mode 100644 apps/participation/templates/participation/team_list.html 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 %}