mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-21 12:38:26 +02:00
Send solutions
This commit is contained in:
@ -10,7 +10,6 @@ class SignUpForm(UserCreationForm):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["first_name"].required = True
|
||||
self.fields["last_name"].required = True
|
||||
print(self.fields["role"].choices)
|
||||
self.fields["role"].choices = [
|
||||
('', _("Choose a role...")),
|
||||
('participant', _("Participant")),
|
||||
|
@ -178,6 +178,10 @@ class Document(PolymorphicModel):
|
||||
verbose_name = _("document")
|
||||
verbose_name_plural = _("documents")
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
self.file.delete(True)
|
||||
return super().delete(*args, **kwargs)
|
||||
|
||||
|
||||
class Authorization(Document):
|
||||
user = models.ForeignKey(
|
||||
@ -234,14 +238,15 @@ class Solution(Document):
|
||||
verbose_name=_("problem"),
|
||||
)
|
||||
|
||||
def save(self, **kwargs):
|
||||
self.type = "solution"
|
||||
super().save(**kwargs)
|
||||
final = models.BooleanField(
|
||||
default=False,
|
||||
verbose_name=_("final solution"),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("solution")
|
||||
verbose_name_plural = _("solutions")
|
||||
unique_together = ('team', 'problem',)
|
||||
unique_together = ('team', 'problem', 'final',)
|
||||
|
||||
def __str__(self):
|
||||
return _("Solution of team {trigram} for problem {problem}")\
|
||||
@ -274,13 +279,15 @@ class Synthesis(Document):
|
||||
verbose_name=_("round"),
|
||||
)
|
||||
|
||||
def save(self, **kwargs):
|
||||
self.type = "synthesis"
|
||||
super().save(**kwargs)
|
||||
final = models.BooleanField(
|
||||
default=False,
|
||||
verbose_name=_("final synthesis"),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("synthesis")
|
||||
verbose_name_plural = _("syntheses")
|
||||
unique_together = ('team', 'dest', 'round', 'final',)
|
||||
|
||||
def __str__(self):
|
||||
return _("Synthesis of team {trigram} that is {dest} for problem {problem}")\
|
||||
|
@ -12,7 +12,7 @@ from django_tables2 import SingleTableView
|
||||
from tournament.models import Team
|
||||
from tournament.views import AdminMixin, TeamMixin
|
||||
from .forms import SignUpForm, TFJMUserForm
|
||||
from .models import TFJMUser, Document
|
||||
from .models import TFJMUser, Document, Solution, MotivationLetter, Synthesis
|
||||
from .tables import UserTable
|
||||
|
||||
|
||||
@ -93,7 +93,12 @@ class DocumentView(LoginRequiredMixin, View):
|
||||
def get(self, request, *args, **kwargs):
|
||||
doc = Document.objects.get(file=self.kwargs["file"])
|
||||
|
||||
if not request.user.admin:
|
||||
grant = request.user.admin
|
||||
|
||||
if isinstance(doc, Solution) or isinstance(doc, Synthesis) or isinstance(doc, MotivationLetter):
|
||||
grant = grant or doc.team == request.user.team or request.user in doc.team.tournament.organizers.all()
|
||||
|
||||
if not grant:
|
||||
raise PermissionDenied
|
||||
|
||||
return FileResponse(doc.file, content_type="application/pdf")
|
||||
|
Reference in New Issue
Block a user