diff --git a/apps/participation/forms.py b/apps/participation/forms.py index ee7ef08..8f7f649 100644 --- a/apps/participation/forms.py +++ b/apps/participation/forms.py @@ -9,7 +9,7 @@ from django.core.exceptions import ValidationError from django.utils import formats from django.utils.translation import gettext_lazy as _ -from .models import Participation, Team, Tournament +from .models import Participation, Team, Tournament, Solution class TeamForm(forms.ModelForm): @@ -112,3 +112,14 @@ class TournamentForm(forms.ModelForm): class Meta: model = Tournament fields = '__all__' + + +class SolutionForm(forms.ModelForm): + def save(self, commit=True): + """ + Don't save a solution with this way. Use a view instead + """ + + class Meta: + model = Solution + fields = ('problem', 'file',) diff --git a/apps/participation/migrations/0006_participation_final.py b/apps/participation/migrations/0006_participation_final.py new file mode 100644 index 0000000..85d01f4 --- /dev/null +++ b/apps/participation/migrations/0006_participation_final.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.11 on 2021-01-12 16:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('participation', '0005_auto_20210101_1149'), + ] + + operations = [ + migrations.AddField( + model_name='participation', + name='final', + field=models.BooleanField(default=False, help_text='The team is selected for the final tournament.', verbose_name='selected for final'), + ), + ] diff --git a/apps/participation/models.py b/apps/participation/models.py index 7aaeb07..f5b92b2 100644 --- a/apps/participation/models.py +++ b/apps/participation/models.py @@ -259,6 +259,12 @@ class Participation(models.Model): help_text=_("The participation got the validation of the organizers."), ) + final = models.BooleanField( + default=False, + verbose_name=_("selected for final"), + help_text=_("The team is selected for the final tournament."), + ) + def get_absolute_url(self): return reverse_lazy("participation:participation_detail", args=(self.pk,)) diff --git a/apps/participation/templates/participation/participation_detail.html b/apps/participation/templates/participation/participation_detail.html index 4f47d47..eafd4a5 100644 --- a/apps/participation/templates/participation/participation_detail.html +++ b/apps/participation/templates/participation/participation_detail.html @@ -28,5 +28,26 @@ +
+ + {% trans "Upload solution" as modal_title %} + {% trans "Upload" as modal_button %} + {% url "participation:upload_solution" pk=participation.pk as modal_action %} + {% include "base_modal.html" with modal_id="uploadSolution" %} +{% endblock %} + +{% block extrajavascript %} + {% endblock %} diff --git a/apps/participation/templates/participation/upload_solution.html b/apps/participation/templates/participation/upload_solution.html new file mode 100644 index 0000000..8acce11 --- /dev/null +++ b/apps/participation/templates/participation/upload_solution.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} + +{% load crispy_forms_filters i18n %} + +{% block content %} + +{% endblock content %} diff --git a/apps/participation/urls.py b/apps/participation/urls.py index ae45494..f67deec 100644 --- a/apps/participation/urls.py +++ b/apps/participation/urls.py @@ -7,7 +7,7 @@ from django.views.generic import TemplateView from .views import CreateTeamView, JoinTeamView, \ MyParticipationDetailView, MyTeamDetailView, ParticipationDetailView, TeamAuthorizationsView, \ TeamDetailView, TeamLeaveView, TeamListView, TeamUpdateView, TournamentCreateView, TournamentDetailView, \ - TournamentListView, TournamentUpdateView + TournamentListView, TournamentUpdateView, SolutionUploadView app_name = "participation" @@ -23,6 +23,7 @@ urlpatterns = [ path("team/leave/", TeamLeaveView.as_view(), name="team_leave"), path("detail/", MyParticipationDetailView.as_view(), name="my_participation_detail"), path("detail/