Add symlinks per problem

This commit is contained in:
Yohann D'ANELLO 2020-06-02 22:07:54 +02:00
parent dd4171b0e8
commit 5ec2cf5acd
4 changed files with 27 additions and 4 deletions

View File

@ -3,11 +3,22 @@ from shutil import copyfile
from django.core.management import BaseCommand from django.core.management import BaseCommand
from django.utils import translation from django.utils import translation
from member.models import Solution
from tournament.models import Tournament from tournament.models import Tournament
class Command(BaseCommand): class Command(BaseCommand):
PROBLEMS = [
'Création de puzzles',
'Départ en vacances',
'Un festin stratégique',
'Sauver les meubles',
'Prêt à décoller !',
'Ils nous espionnent !',
'De joyeux bûcherons',
'Robots auto-réplicateurs',
]
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument('dir', parser.add_argument('dir',
type=str, type=str,
@ -43,3 +54,15 @@ class Command(BaseCommand):
copied += 1 copied += 1
self.stdout.write(self.style.SUCCESS("Successfully copied {copied} solutions!".format(copied=copied))) self.stdout.write(self.style.SUCCESS("Successfully copied {copied} solutions!".format(copied=copied)))
os.mkdir(d + '/Par problème')
for pb in range(1, 9):
sols = Solution.objects.filter(problem=pb).all()
pbdir = d + '/Par problème/Problème n°{number}{problem}'.format(number=pb, problem=self.PROBLEMS[pb - 1])
os.mkdir(pbdir)
for sol in sols:
os.symlink('../../' + sol.tournament.name + '/' + str(sol.team) + '/' + str(sol) + '.pdf',
pbdir + '/' + str(sol) + '.pdf')
self.stdout.write(self.style.SUCCESS("Symlinks by problem created!"))

View File

@ -303,7 +303,7 @@ class Team(models.Model):
send_mail(subject, message, "contact@tfjm.org", [user.email], html_message=message_html) send_mail(subject, message, "contact@tfjm.org", [user.email], html_message=message_html)
def __str__(self): def __str__(self):
return self.trigram + " -- " + self.name return self.trigram + " " + self.name
class Pool(models.Model): class Pool(models.Model):

View File

@ -59,7 +59,7 @@
<div class="card-body"> <div class="card-body">
<div class="alert alert-warning"> <div class="alert alert-warning">
{% trans "Templates for syntheses are available here:" %} {% trans "Templates for syntheses are available here:" %}
<a data-turbolinks="false" href="{% static "Fiche synthèse.pdf" %}">PDF</a> -- <a data-turbolinks="false" href="{% static "Fiche synthèse.tex" %}">TEX</a> <a data-turbolinks="false" href="{% static "Fiche synthèse.pdf" %}">PDF</a> <a data-turbolinks="false" href="{% static "Fiche synthèse.tex" %}">TEX</a>
</div> </div>
{% if user.organizes or not user.is_authenticated %} {% if user.organizes or not user.is_authenticated %}
<ul> <ul>

View File

@ -5,7 +5,7 @@
{% block content %} {% block content %}
<div class="alert alert-warning"> <div class="alert alert-warning">
{% trans "Templates for syntheses are available here:" %} {% trans "Templates for syntheses are available here:" %}
<a data-turbolinks="false" href="{% static "Fiche synthèse.pdf" %}">PDF</a> -- <a data-turbolinks="false" href="{% static "Fiche synthèse.tex" %}">TEX</a> <a data-turbolinks="false" href="{% static "Fiche synthèse.pdf" %}">PDF</a> <a data-turbolinks="false" href="{% static "Fiche synthèse.tex" %}">TEX</a>
</div> </div>
{% if form %} {% if form %}