Fix tests
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
1e7bd209a1
commit
6867c2cc2d
|
@ -1,7 +1,6 @@
|
||||||
# Copyright (C) 2020 by Animath
|
# Copyright (C) 2020 by Animath
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from datetime import date
|
from datetime import date
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -16,7 +15,6 @@ from django.utils.crypto import get_random_string
|
||||||
from django.utils.text import format_lazy
|
from django.utils.text import format_lazy
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
import gspread
|
import gspread
|
||||||
from django.views.debug import ExceptionReporter
|
|
||||||
from gspread.utils import a1_range_to_grid_range, MergeType
|
from gspread.utils import a1_range_to_grid_range, MergeType
|
||||||
from registration.models import Payment, VolunteerRegistration
|
from registration.models import Payment, VolunteerRegistration
|
||||||
from tfjm.lists import get_sympa_client
|
from tfjm.lists import get_sympa_client
|
||||||
|
@ -434,7 +432,7 @@ class Tournament(models.Model):
|
||||||
gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT)
|
gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT)
|
||||||
spreadsheet = gc.open_by_key(self.notes_sheet_id)
|
spreadsheet = gc.open_by_key(self.notes_sheet_id)
|
||||||
worksheets = spreadsheet.worksheets()
|
worksheets = spreadsheet.worksheets()
|
||||||
if f"Classement final" not in [ws.title for ws in worksheets]:
|
if "Classement final" not in [ws.title for ws in worksheets]:
|
||||||
worksheet = spreadsheet.add_worksheet("Classement final", 100, 26)
|
worksheet = spreadsheet.add_worksheet("Classement final", 100, 26)
|
||||||
else:
|
else:
|
||||||
worksheet = spreadsheet.worksheet("Classement final")
|
worksheet = spreadsheet.worksheet("Classement final")
|
||||||
|
@ -477,7 +475,6 @@ class Tournament(models.Model):
|
||||||
data = header + lines + final_ranking
|
data = header + lines + final_ranking
|
||||||
worksheet.update(data, f"A1:G{participations.count() + 5}", raw=False)
|
worksheet.update(data, f"A1:G{participations.count() + 5}", raw=False)
|
||||||
|
|
||||||
|
|
||||||
format_requests = []
|
format_requests = []
|
||||||
|
|
||||||
# Set the width of the columns
|
# Set the width of the columns
|
||||||
|
@ -536,7 +533,7 @@ class Tournament(models.Model):
|
||||||
|
|
||||||
# Set background color for headers and footers
|
# Set background color for headers and footers
|
||||||
bg_colors = [("A1:AF", (1, 1, 1)),
|
bg_colors = [("A1:AF", (1, 1, 1)),
|
||||||
(f"A1:G1", (0.8, 0.8, 0.8)),
|
("A1:G1", (0.8, 0.8, 0.8)),
|
||||||
(f"A2:B{participations.count() + 1}", (0.9, 0.9, 0.9)),
|
(f"A2:B{participations.count() + 1}", (0.9, 0.9, 0.9)),
|
||||||
(f"C2:C{participations.count() + 1}", (1, 1, 1)),
|
(f"C2:C{participations.count() + 1}", (1, 1, 1)),
|
||||||
(f"D2:D{participations.count() + 1}", (0.9, 0.9, 0.9)),
|
(f"D2:D{participations.count() + 1}", (0.9, 0.9, 0.9)),
|
||||||
|
@ -581,7 +578,7 @@ class Tournament(models.Model):
|
||||||
})
|
})
|
||||||
|
|
||||||
# Protect the header, the juries list, the footer and the ranking
|
# Protect the header, the juries list, the footer and the ranking
|
||||||
protected_ranges = [f"A1:G1", f"A2:B{participations.count() + 1}",
|
protected_ranges = ["A1:G1", f"A2:B{participations.count() + 1}",
|
||||||
f"D2:D{participations.count() + 1}", f"F2:G{participations.count() + 1}",
|
f"D2:D{participations.count() + 1}", f"F2:G{participations.count() + 1}",
|
||||||
f"A{participations.count() + 4}:C{2 * participations.count() + 4}", ]
|
f"A{participations.count() + 4}:C{2 * participations.count() + 4}", ]
|
||||||
for protected_range in protected_ranges:
|
for protected_range in protected_ranges:
|
||||||
|
@ -1214,7 +1211,8 @@ class Pool(models.Model):
|
||||||
note.save()
|
note.save()
|
||||||
|
|
||||||
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
|
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
|
||||||
self.update_juries_lines_spreadsheet()
|
if os.getenv('GOOGLE_PRIVATE_KEY_ID', None): # Google Sheets support is enabled
|
||||||
|
self.update_juries_lines_spreadsheet()
|
||||||
super().save(force_insert, force_update, using, update_fields)
|
super().save(force_insert, force_update, using, update_fields)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
|
@ -11,7 +11,7 @@ from .views import CreateTeamView, FinalNotationSheetTemplateView, JoinTeamView,
|
||||||
ScaleNotationSheetTemplateView, SolutionsDownloadView, SolutionUploadView, SynthesisUploadView, \
|
ScaleNotationSheetTemplateView, SolutionsDownloadView, SolutionUploadView, SynthesisUploadView, \
|
||||||
TeamAuthorizationsView, TeamDetailView, TeamLeaveView, TeamListView, TeamUpdateView, \
|
TeamAuthorizationsView, TeamDetailView, TeamLeaveView, TeamListView, TeamUpdateView, \
|
||||||
TeamUploadMotivationLetterView, TournamentCreateView, TournamentDetailView, TournamentExportCSVView, \
|
TeamUploadMotivationLetterView, TournamentCreateView, TournamentDetailView, TournamentExportCSVView, \
|
||||||
TournamentHarmonizeView, TournamentHarmonizeNoteView, TournamentListView, TournamentPaymentsView, \
|
TournamentHarmonizeNoteView, TournamentHarmonizeView, TournamentListView, TournamentPaymentsView, \
|
||||||
TournamentPublishNotesView, TournamentUpdateView
|
TournamentPublishNotesView, TournamentUpdateView
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ from tempfile import mkdtemp
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
import gspread
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
@ -29,6 +28,7 @@ from django.views.generic import CreateView, DetailView, FormView, RedirectView,
|
||||||
from django.views.generic.detail import SingleObjectMixin
|
from django.views.generic.detail import SingleObjectMixin
|
||||||
from django.views.generic.edit import FormMixin, ProcessFormView
|
from django.views.generic.edit import FormMixin, ProcessFormView
|
||||||
from django_tables2 import MultiTableMixin, SingleTableMixin, SingleTableView
|
from django_tables2 import MultiTableMixin, SingleTableMixin, SingleTableView
|
||||||
|
import gspread
|
||||||
from magic import Magic
|
from magic import Magic
|
||||||
from odf.opendocument import OpenDocumentSpreadsheet
|
from odf.opendocument import OpenDocumentSpreadsheet
|
||||||
from odf.style import Style, TableCellProperties, TableColumnProperties, TextProperties
|
from odf.style import Style, TableCellProperties, TableColumnProperties, TextProperties
|
||||||
|
|
Loading…
Reference in New Issue