1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-07-04 13:32:17 +02:00

Add extra access to juries

This commit is contained in:
Yohann D'ANELLO
2020-05-25 18:27:07 +02:00
parent 522ed088ef
commit 3d9e7136ac
8 changed files with 264 additions and 155 deletions

View File

@ -1,4 +1,5 @@
import os
import random
from django.core.mail import send_mail
from django.db import models
@ -338,6 +339,13 @@ class Pool(models.Model):
verbose_name=_("juries"),
)
extra_access_token = models.CharField(
max_length=64,
default="",
verbose_name=_("extra access token"),
help_text=_("Let other users access to the pool data without logging in."),
)
@property
def problems(self):
"""
@ -361,6 +369,13 @@ class Pool(models.Model):
from member.models import Synthesis
return Synthesis.objects.filter(team__in=self.teams.all(), round=self.round, final=self.tournament.final)
def save(self, **kwargs):
if not self.extra_access_token:
alphabet = "0123456789abcdefghijklmnopqrstuvwxyz0123456789"
code = "".join(random.choice(alphabet) for _ in range(64))
self.extra_access_token = code
super().save(**kwargs)
class Meta:
verbose_name = _("pool")
verbose_name_plural = _("pools")