1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-29 20:31:11 +02:00

Update scaling sheets for ETEAM

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2024-07-06 23:30:17 +02:00
parent 620bbe7817
commit 18f3ce4023
8 changed files with 317 additions and 127 deletions

View File

@ -1838,11 +1838,14 @@ class NotationSheetTemplateView(VolunteerMixin, DetailView):
context['esp'] = passages.count() * '&'
if self.request.user.registration in self.object.juries.all() and 'blank' not in self.request.GET:
context['jury'] = self.request.user.registration
context['tfjm_number'] = timezone.now().year - 2010
context['tfjm_number'] = timezone.now().year - settings.FIRST_EDITION + 1
return context
def render_to_response(self, context, **response_kwargs):
tex = render_to_string(self.template_name, context=context, request=self.request)
translation.activate(settings.PREFERRED_LANGUAGE_CODE)
template_name = self.get_template_names()[0]
tex = render_to_string(template_name, context=context, request=self.request)
temp_dir = mkdtemp()
with open(os.path.join(temp_dir, "texput.tex"), "w") as f:
f.write(tex)
@ -1851,15 +1854,16 @@ class NotationSheetTemplateView(VolunteerMixin, DetailView):
process.wait()
return FileResponse(streaming_content=open(os.path.join(temp_dir, "texput.pdf"), "rb"),
content_type="application/pdf",
filename=self.template_name.split("/")[-1][:-3] + "pdf")
filename=template_name.split("/")[-1][:-3] + "pdf")
class ScaleNotationSheetTemplateView(NotationSheetTemplateView):
template_name = 'participation/tex/bareme.tex'
def get_template_names(self):
return [f"participation/tex/scale_{settings.TFJM_APP.lower()}.tex"]
class FinalNotationSheetTemplateView(NotationSheetTemplateView):
template_name = 'participation/tex/finale.tex'
template_name = "participation/tex/final_sheet.tex"
class NotationSheetsArchiveView(VolunteerMixin, DetailView):
@ -1891,6 +1895,8 @@ class NotationSheetsArchiveView(VolunteerMixin, DetailView):
return self.handle_no_permission()
def get(self, request, *args, **kwargs):
translation.activate(settings.PREFERRED_LANGUAGE_CODE)
if 'pool_id' in kwargs:
pool = self.get_object()
tournament = pool.tournament
@ -1906,15 +1912,15 @@ class NotationSheetsArchiveView(VolunteerMixin, DetailView):
with ZipFile(output, "w") as zf:
for pool in pools:
prefix = f"{pool.short_name}/" if len(pools) > 1 else ""
for template_name in ['bareme', 'finale']:
for template_name in [f"scale_{settings.TFJM_APP.lower()}", "final_sheet"]:
juries = list(pool.juries.all()) + [None]
for jury in juries:
if jury is not None and template_name == "bareme":
if jury is not None and template_name.startswith("scale"):
continue
context = {'jury': jury, 'pool': pool,
'tfjm_number': timezone.now().year - 2010}
'tfjm_number': timezone.now().year - settings.FIRST_EDITION + 1}
passages = pool.passages.all()
context['passages'] = passages
@ -1931,7 +1937,7 @@ class NotationSheetsArchiveView(VolunteerMixin, DetailView):
os.path.join(temp_dir, "texput.tex"), ])
process.wait()
sheet_name = f"Barème pour la poule {pool.short_name}" if template_name == "bareme" \
sheet_name = f"Barème pour la poule {pool.short_name}" if template_name.startswith("scale") \
else (f"Feuille de notation pour la poule {pool.short_name}"
f" - {str(jury) if jury else 'Vierge'}")