From 779aec5e553d8488a8515a2c1fc21f00ec2c7f8e Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sun, 31 Mar 2024 15:30:17 +0200 Subject: [PATCH] Don't use Google Sheets in tests (for now) Signed-off-by: Emmy D'Anello --- draw/consumers.py | 5 ++++- draw/models.py | 6 +++++- participation/models.py | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/draw/consumers.py b/draw/consumers.py index dff31b9..2096c37 100644 --- a/draw/consumers.py +++ b/draw/consumers.py @@ -3,6 +3,7 @@ from collections import OrderedDict import json +import os from random import randint, shuffle from asgiref.sync import sync_to_async @@ -990,7 +991,9 @@ class DrawConsumer(AsyncJsonWebsocketConsumer): if await pool.is_exportable(): await pool.export() - await sync_to_async(self.tournament.update_ranking_spreadsheet)() + # Update Google Sheets final sheet + if os.getenv('GOOGLE_PRIVATE_KEY_ID', None): + await sync_to_async(self.tournament.update_ranking_spreadsheet)() @ensure_orga async def continue_final(self, **kwargs): diff --git a/draw/models.py b/draw/models.py index 5c75456..9a028d7 100644 --- a/draw/models.py +++ b/draw/models.py @@ -1,6 +1,8 @@ # Copyright (C) 2023 by Animath # SPDX-License-Identifier: GPL-3.0-or-later +import os + from asgiref.sync import sync_to_async from django.conf import settings from django.core.validators import MaxValueValidator, MinValueValidator @@ -399,7 +401,9 @@ class Pool(models.Model): passage.observer = tds[line[3]].participation await passage.asave() - await sync_to_async(self.associated_pool.update_spreadsheet)() + # Update Google Sheets + if os.getenv('GOOGLE_PRIVATE_KEY_ID', None): + await sync_to_async(self.associated_pool.update_spreadsheet)() return self.associated_pool diff --git a/participation/models.py b/participation/models.py index 86c30e0..07a0636 100644 --- a/participation/models.py +++ b/participation/models.py @@ -635,7 +635,7 @@ class Tournament(models.Model): else: tweak2_qs.update_or_create(defaults={'diff': tweak2_nb}, create_defaults={'diff': tweak2_nb, 'pool': pool2, - 'participation': participation}) + 'participation': participation}) def get_absolute_url(self): return reverse_lazy("participation:tournament_detail", args=(self.pk,))