diff options
Diffstat (limited to 'core/views/scans.py')
-rw-r--r-- | core/views/scans.py | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/core/views/scans.py b/core/views/scans.py index 63b477d..aed38ee 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -11,9 +11,9 @@ from troggle.core.models.survex import SingleScan, SurvexBlock from troggle.core.models.wallets import Wallet from troggle.core.models.troggle import DataIssue, Expedition, Person from troggle.core.views.expo import getmimetype +from troggle.parsers.survex import set_walletdate # from troggle.parsers.people import GetPersonExpeditionNameLookup - # import parsers.surveys """one of these views serves files as binary blobs, and simply set the mime type based on the file extension, @@ -23,7 +23,7 @@ by looking inside the file before being served. need to check if inavlid query string is invalid, or produces multiple replies and render a user-friendly error page. -Note that datewallet(), caveifywallet() etc do NOT save the object to the db. They are ephemeral, just for the page rendering of the +Note that caveifywallet() etc do NOT save the object to the db. They are ephemeral, just for the page rendering of the manywallets dict. TODO @@ -47,24 +47,7 @@ def populatewallet(w): w.persons = list(set(survexpeople)) -def datewallet(w, earliest): - """Gets the date of the youngest survexblock associated with the wallet - REFACTOR this to do the whole date-getting task - """ - first = earliest - blocks = SurvexBlock.objects.filter(scanswallet=w) - for b in blocks: - if b.date: - if b.date < first: - first = b.date - if first == earliest: - # no date found - w.date = None - else: - w.date = first.isoformat() - return w.date - - + def caveifywallet(w): """Gets the cave from the list of survex files, only selects one of them though. Only used for display. @@ -105,11 +88,7 @@ def fillblankpeople(w): def fillblankothers(w): if not w.walletdate: - earliest = datetime.datetime.now().date() - if not w.date(): # sets .walletdate as a side-effect, gets it from JSON - d = datewallet(w, earliest) # if nothing in JASON, it looks at the survex blocks - w.walletdate = d - w.save() + set_walletdate(w) Gcavelookup = GetCaveLookup() @@ -180,6 +159,8 @@ def walletslistperson(request, first_name, last_name): def setwalletsdates(): + """This sets all the undated wallets, but they should already all be dated on + import or on edit""" wallets = Wallet.objects.filter(walletdate=None) print(f"undated wallets: {len(wallets)}") for w in wallets: |