mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 05:17:34 +00:00
checking wallets earlier int he process
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user