2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-03-31 09:46:04 +01:00

Message while database reset ongoing.. untested

This commit is contained in:
2024-08-11 15:43:41 +03:00
parent 74ce8894d2
commit aaabcafcfe
2 changed files with 16 additions and 2 deletions

View File

@@ -47,7 +47,14 @@ sha = hashlib.new('sha256')
throw = 35.0
class DatabaseResetOngoing(Exception):
"""Exception class for errors while the server is reimporting everything"""
def __init__(self, message):
self.message = message
def __str__(self):
return f"DatabaseResetOngoing: {self.message}"
# This is module-level executable. This is a Bad Thing. Especially when it touches the file system.
try:

View File

@@ -6,6 +6,7 @@ from django.conf import settings
from django.http import HttpResponse
from django.shortcuts import render
from troggle.core.models.caves import GetCaveLookup
from troggle.core.models.survex import SingleScan, SurvexBlock, SurvexPersonRole
from troggle.core.models.wallets import Wallet
@@ -14,7 +15,7 @@ from troggle.core.views.expo import getmimetype
from troggle.parsers.caves import add_cave_to_pending_list
from troggle.parsers.people import GetPersonExpeditionNameLookup
from troggle.parsers.survex import set_walletdate
from troggle.core.utils import current_expo
from troggle.core.utils import current_expo, DatabaseResetOngoing
"""
@@ -277,7 +278,13 @@ def walletslistyear(request, year):
def ticksyearwallet(year):
manywallets = []
manywallets = Wallet.objects.filter(walletyear__year=year)
try:
manywallets = Wallet.objects.filter(walletyear__year=year)
except OperationalError:
# Reset is ongoing on server
raise DatabaseResetOngoing(
f"Expo Database re-import ongoing on server.\nPlease wait 6 minutes.\n If still not working, contact a nerd."
)
fix_manywallets(manywallets)
return manywallets