mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-25 07:42:22 +00:00
Display team solutions
This commit is contained in:
parent
3fdda5a030
commit
f08f52c129
@ -210,7 +210,11 @@ class Command(BaseCommand):
|
|||||||
obj_dict["user"] = TFJMUser.objects.get(args[1]),
|
obj_dict["user"] = TFJMUser.objects.get(args[1]),
|
||||||
obj_dict["type"] = args[4].lower()
|
obj_dict["type"] = args[4].lower()
|
||||||
else:
|
else:
|
||||||
obj_dict["team"] = Team.objects.get(pk=args[2])
|
try:
|
||||||
|
obj_dict["team"] = Team.objects.get(pk=args[2])
|
||||||
|
except Team.DoesNotExist:
|
||||||
|
print("Team with pk {} does not exist, ignoring".format(args[2]))
|
||||||
|
continue
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
if args[4] != "MOTIVATION_LETTER":
|
if args[4] != "MOTIVATION_LETTER":
|
||||||
Authorization.objects.create(**obj_dict)
|
Authorization.objects.create(**obj_dict)
|
||||||
|
@ -241,6 +241,7 @@ class Solution(Document):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("solution")
|
verbose_name = _("solution")
|
||||||
verbose_name_plural = _("solutions")
|
verbose_name_plural = _("solutions")
|
||||||
|
unique_together = ('team', 'problem',)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return _("Solution of team {trigram} for problem {problem}")\
|
return _("Solution of team {trigram} for problem {problem}")\
|
||||||
@ -265,6 +266,14 @@ class Synthesis(Document):
|
|||||||
verbose_name=_("dest"),
|
verbose_name=_("dest"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
round = models.PositiveSmallIntegerField(
|
||||||
|
choices=[
|
||||||
|
(1, _("Round 1")),
|
||||||
|
(2, _("Round 2")),
|
||||||
|
],
|
||||||
|
verbose_name=_("round"),
|
||||||
|
)
|
||||||
|
|
||||||
def save(self, **kwargs):
|
def save(self, **kwargs):
|
||||||
self.type = "synthesis"
|
self.type = "synthesis"
|
||||||
super().save(**kwargs)
|
super().save(**kwargs)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from .views import CreateUserView
|
from .views import CreateUserView, DocumentView
|
||||||
|
|
||||||
|
|
||||||
app_name = "member"
|
app_name = "member"
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('signup/', CreateUserView.as_view(), name="signup"),
|
path('signup/', CreateUserView.as_view(), name="signup"),
|
||||||
|
path("file/<str:file>/", DocumentView.as_view(), name="document"),
|
||||||
]
|
]
|
||||||
|
@ -1,10 +1,24 @@
|
|||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.core.exceptions import PermissionDenied
|
||||||
|
from django.http import FileResponse
|
||||||
|
from django.views import View
|
||||||
from django.views.generic import CreateView
|
from django.views.generic import CreateView
|
||||||
|
|
||||||
from .forms import SignUpForm
|
from .forms import SignUpForm
|
||||||
from .models import TFJMUser
|
from .models import TFJMUser, Document
|
||||||
|
|
||||||
|
|
||||||
class CreateUserView(CreateView):
|
class CreateUserView(CreateView):
|
||||||
model = TFJMUser
|
model = TFJMUser
|
||||||
form_class = SignUpForm
|
form_class = SignUpForm
|
||||||
template_name = "registration/signup.html"
|
template_name = "registration/signup.html"
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentView(LoginRequiredMixin, View):
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
doc = Document.objects.get(file=self.kwargs["file"])
|
||||||
|
|
||||||
|
if not request.user.admin:
|
||||||
|
raise PermissionDenied
|
||||||
|
|
||||||
|
return FileResponse(doc.file, content_type="application/pdf")
|
||||||
|
@ -40,10 +40,20 @@
|
|||||||
|
|
||||||
<h4>{% trans "Documents" %}</h4>
|
<h4>{% trans "Documents" %}</h4>
|
||||||
|
|
||||||
{% if team.motivation_letters %}
|
{% if team.motivation_letters.count %}
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
{% blocktrans with version=team.motivation_letters.count %}Motivation letter (version {{ version }}):{% endblocktrans %}
|
<strong>{% blocktrans with version=team.motivation_letters.count %}Motivation letter (version {{ version }}):{% endblocktrans %}</strong>
|
||||||
<a href="{{ team.motivation_letters.last.file.url }}">{% trans "Download" %}</a>
|
<a data-turbolinks="false" href="{% url "member:document" file=team.motivation_letters.last.file %}">{% trans "Download" %}</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if team.solutions.count %}
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<ul>
|
||||||
|
{% for solution in team.solutions.all %}
|
||||||
|
<li><strong>{{ solution }} :</strong> <a data-turbolinks="false" href="{% url "member:document" file=solution.file %}">{% trans "Download" %}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user