mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-14 21:37:13 +00:00
detect non-ISO dates in JSON and from user and fix
This commit is contained in:
@@ -18,7 +18,7 @@ from troggle.core.models.caves import Cave
|
||||
from troggle.core.models.logbooks import LogbookEntry # , PersonLogEntry
|
||||
from troggle.core.models.survex import SurvexBlock, SurvexFile, SurvexPersonRole
|
||||
from troggle.core.models.troggle import DataIssue, Expedition
|
||||
from troggle.core.models.wallets import Wallet, YEAR_RANGE
|
||||
from troggle.core.models.wallets import Wallet, YEAR_RANGE, make_valid_date
|
||||
|
||||
from troggle.core.views.auth import login_required_if_public
|
||||
from troggle.core.views.caves import getCave
|
||||
@@ -32,7 +32,7 @@ from troggle.parsers.scans import contentsjson
|
||||
"""
|
||||
|
||||
todo = """
|
||||
- Nasty bug in navingating to 'previous wallet' when we have a 2-year gap in expos
|
||||
- Nasty bug in navigating to 'previous wallet' when we have a 2-year gap in expos
|
||||
The xxxx#00 wallet is not getting edited correctly. Something is off by one somewhere..
|
||||
|
||||
- Register uploaded filenames in the Django db without needing to wait for a reset & bulk file import
|
||||
@@ -496,25 +496,7 @@ def walletedit(request, path=None):
|
||||
or thing == "[]"
|
||||
or thing is None)
|
||||
|
||||
def make_valid_date(date):
|
||||
datestr = date.replace(".", "-")
|
||||
try:
|
||||
samedate = datetime.date.fromisoformat(datestr)
|
||||
except ValueError:
|
||||
# probably a single digit day number. HACKUS MAXIMUS.
|
||||
# clearly we need to fix this when we first import date strings..
|
||||
datestr = datestr[:-1] + "0" + datestr[-1]
|
||||
# datestr = f"{datestr:02d}"
|
||||
print(f"! - ValueError, trying.. {datestr=} ")
|
||||
try:
|
||||
samedate = datetime.date.fromisoformat(datestr)
|
||||
except:
|
||||
try:
|
||||
samedate = datetime.date.fromisoformat(datestr[:10])
|
||||
except:
|
||||
print(f"! - ValueError, FAILED {datestr=} ")
|
||||
samedate = None
|
||||
return samedate
|
||||
|
||||
|
||||
def scan_survexblocks(svxfile):
|
||||
"""Scans for *team people attached to all the survex blocks in this svxfile
|
||||
|
||||
Reference in New Issue
Block a user