mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-25 18:22:23 +00:00
Better tree
This commit is contained in:
parent
5ec2cf5acd
commit
3f83fd6ef3
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
from urllib.request import urlretrieve
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
|
||||||
from django.core.management import BaseCommand
|
from django.core.management import BaseCommand
|
||||||
@ -35,21 +36,23 @@ class Command(BaseCommand):
|
|||||||
Copy solutions elsewhere.
|
Copy solutions elsewhere.
|
||||||
"""
|
"""
|
||||||
d = options['dir']
|
d = options['dir']
|
||||||
|
teams_dir = d + '/Par équipe'
|
||||||
|
os.makedirs(teams_dir, exist_ok=True)
|
||||||
|
|
||||||
translation.activate(options['language'])
|
translation.activate(options['language'])
|
||||||
|
|
||||||
copied = 0
|
copied = 0
|
||||||
|
|
||||||
for tournament in Tournament.objects.all():
|
for tournament in Tournament.objects.all():
|
||||||
os.mkdir(d + '/' + tournament.name)
|
os.mkdir(teams_dir + '/' + tournament.name)
|
||||||
for team in tournament.teams.filter(validation_status='2valid'):
|
for team in tournament.teams.filter(validation_status='2valid'):
|
||||||
os.mkdir(d + '/' + tournament.name + '/' + str(team))
|
os.mkdir(teams_dir + '/' + tournament.name + '/' + str(team))
|
||||||
for sol in tournament.solutions:
|
for sol in tournament.solutions:
|
||||||
if not os.path.isfile('media/' + sol.file.name):
|
if not os.path.isfile('media/' + sol.file.name):
|
||||||
self.stdout.write(self.style.WARNING(("Warning: solution '{sol}' is not found. Maybe the file"
|
self.stdout.write(self.style.WARNING(("Warning: solution '{sol}' is not found. Maybe the file"
|
||||||
"was deleted?").format(sol=str(sol))))
|
"was deleted?").format(sol=str(sol))))
|
||||||
continue
|
continue
|
||||||
copyfile('media/' + sol.file.name, d + '/' + tournament.name
|
copyfile('media/' + sol.file.name, teams_dir + '/' + tournament.name
|
||||||
+ '/' + str(sol.team) + '/' + str(sol) + '.pdf')
|
+ '/' + str(sol.team) + '/' + str(sol) + '.pdf')
|
||||||
copied += 1
|
copied += 1
|
||||||
|
|
||||||
@ -62,7 +65,11 @@ class Command(BaseCommand):
|
|||||||
pbdir = d + '/Par problème/Problème n°{number} — {problem}'.format(number=pb, problem=self.PROBLEMS[pb - 1])
|
pbdir = d + '/Par problème/Problème n°{number} — {problem}'.format(number=pb, problem=self.PROBLEMS[pb - 1])
|
||||||
os.mkdir(pbdir)
|
os.mkdir(pbdir)
|
||||||
for sol in sols:
|
for sol in sols:
|
||||||
os.symlink('../../' + sol.tournament.name + '/' + str(sol.team) + '/' + str(sol) + '.pdf',
|
os.symlink('../../Par équipe/' + sol.tournament.name + '/' + str(sol.team) + '/' + str(sol) + '.pdf',
|
||||||
pbdir + '/' + str(sol) + '.pdf')
|
pbdir + '/' + str(sol) + '.pdf')
|
||||||
|
|
||||||
self.stdout.write(self.style.SUCCESS("Symlinks by problem created!"))
|
self.stdout.write(self.style.SUCCESS("Symlinks by problem created!"))
|
||||||
|
|
||||||
|
urlretrieve('https://tfjm.org/wp-content/uploads/2020/01/Problemes2020_23_01_v1_1.pdf', d + '/Énoncés.pdf')
|
||||||
|
|
||||||
|
self.stdout.write(self.style.SUCCESS("Questions retrieved!"))
|
||||||
|
Loading…
Reference in New Issue
Block a user