summaryrefslogtreecommitdiffstats
path: root/core/models
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-10-23 02:32:44 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2023-10-23 02:32:44 +0300
commit54ffab3e93a8d3f0b3d253037eb57a7fb78012d5 (patch)
tree61b76c536bd61024ef46ea45a7ed73af1cc5972c /core/models
parent8f87e4f77a1128cb89826827bf5b9ae9dea901dc (diff)
downloadtroggle-54ffab3e93a8d3f0b3d253037eb57a7fb78012d5.tar.gz
troggle-54ffab3e93a8d3f0b3d253037eb57a7fb78012d5.tar.bz2
troggle-54ffab3e93a8d3f0b3d253037eb57a7fb78012d5.zip
checking wallets earlier int he process
Diffstat (limited to 'core/models')
-rw-r--r--core/models/wallets.py31
1 files changed, 23 insertions, 8 deletions
diff --git a/core/models/wallets.py b/core/models/wallets.py
index 3f59da0..1cc42e8 100644
--- a/core/models/wallets.py
+++ b/core/models/wallets.py
@@ -10,6 +10,7 @@ from django.conf import settings
from django.db import models
from django.urls import reverse
+from troggle.core.models.troggle import DataIssue
from troggle.core.views.caves import get_cave_leniently
# from troggle.core.models.survex import SurvexBlock
@@ -143,8 +144,26 @@ class Wallet(models.Model):
message = f"! {str(self.walletname)} Date format not ISO {waldata['date']}. Failed to load from {jsonfile} JSON file"
from troggle.core.models.troggle import DataIssue
DataIssue.objects.update_or_create(parser="wallets", message=message, url=wurl)
+
+
return waldata
-
+
+ def check_survexlist(self):
+ wurl = f"/walletedit/{self.walletname}".replace('#', ':')
+ if not (waldata := self.get_json()): # WALRUS
+ return None
+ if waldata["survex file"]:
+ if not type(waldata["survex file"]) == list: # a string also is a sequence type, so do it this way
+ waldata["survex file"] = [waldata["survex file"]]
+ for sx in waldata["survex file"]:
+ # this logic appears in several places, inc get_ticks(). and wallets_edit.py Refactor.
+ if sx != "":
+ if Path(sx).suffix.lower() != ".svx":
+ sx = sx + ".svx"
+ if not (Path(settings.SURVEX_DATA) / sx).is_file():
+ message=f"{self} Survex file {sx} was not found in LOSER repo"
+ DataIssue.objects.update_or_create(parser="wallets", message=message, url=wurl)
+
def allcaves(self):
"""Reads all the JSON data just to get the JSON date."""
if not (jsondata := self.get_json()): # WALRUS
@@ -209,23 +228,19 @@ class Wallet(models.Model):
self.save()
return self.walletdate
- # for gods sake redo this, it parse JSON twice every time..
def people(self):
- if not self.get_json():
+ if not (jsondata := self.get_json()): # WALRUS
return None
- jsondata = self.get_json()
return jsondata["people"]
def cave(self):
- if not self.get_json():
+ if not (jsondata := self.get_json()): # WALRUS
return None
- jsondata = self.get_json()
return jsondata["cave"]
def name(self):
- if not self.get_json():
+ if not (jsondata := self.get_json()): # WALRUS
return None
- jsondata = self.get_json()
return jsondata["name"]
def get_fnames(self):