summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/utils.py7
-rw-r--r--core/views/scans.py11
2 files changed, 16 insertions, 2 deletions
diff --git a/core/utils.py b/core/utils.py
index 39233d3..f49ef26 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -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:
diff --git a/core/views/scans.py b/core/views/scans.py
index f24b972..1d86d18 100644
--- a/core/views/scans.py
+++ b/core/views/scans.py
@@ -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