From 5ec2cf5acdf5214394282f610a749b2d2f0a420b Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 2 Jun 2020 22:07:54 +0200 Subject: [PATCH] Add symlinks per problem --- .../management/commands/extract_solutions.py | 25 ++++++++++++++++++- apps/tournament/models.py | 2 +- templates/tournament/pool_detail.html | 2 +- templates/tournament/syntheses_list.html | 2 +- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/apps/member/management/commands/extract_solutions.py b/apps/member/management/commands/extract_solutions.py index 176a2bf..713c420 100644 --- a/apps/member/management/commands/extract_solutions.py +++ b/apps/member/management/commands/extract_solutions.py @@ -3,11 +3,22 @@ from shutil import copyfile from django.core.management import BaseCommand from django.utils import translation - +from member.models import Solution from tournament.models import Tournament 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): parser.add_argument('dir', type=str, @@ -43,3 +54,15 @@ class Command(BaseCommand): copied += 1 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!")) diff --git a/apps/tournament/models.py b/apps/tournament/models.py index ed4a0fb..11d5886 100644 --- a/apps/tournament/models.py +++ b/apps/tournament/models.py @@ -303,7 +303,7 @@ class Team(models.Model): send_mail(subject, message, "contact@tfjm.org", [user.email], html_message=message_html) def __str__(self): - return self.trigram + " -- " + self.name + return self.trigram + " — " + self.name class Pool(models.Model): diff --git a/templates/tournament/pool_detail.html b/templates/tournament/pool_detail.html index f2ee357..d20c2b8 100644 --- a/templates/tournament/pool_detail.html +++ b/templates/tournament/pool_detail.html @@ -59,7 +59,7 @@
{% trans "Templates for syntheses are available here:" %} - PDF -- TEX + PDFTEX
{% if user.organizes or not user.is_authenticated %}