mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
fix bug for wallet with empty fpath
This commit is contained in:
parent
4495be2083
commit
c8163ab0cd
@ -277,15 +277,23 @@ class Wallet(models.Model):
|
|||||||
def get_fnames(self):
|
def get_fnames(self):
|
||||||
'''Filenames without the suffix, i.e. without the ".jpg"
|
'''Filenames without the suffix, i.e. without the ".jpg"
|
||||||
'''
|
'''
|
||||||
dirpath = Path(settings.SCANS_ROOT, self.fpath)
|
dirpath = Path(settings.SCANS_ROOT, self.fpath) # does nowt as fpath is a rooted path already
|
||||||
files = []
|
files = []
|
||||||
if dirpath.is_dir():
|
if not self.fpath:
|
||||||
|
files.append(f"Incorrect path to wallet contents: '{self.fpath}'")
|
||||||
|
return files
|
||||||
|
if not dirpath.is_dir():
|
||||||
|
files.append(f"Incorrect path to wallet contents: '{self.fpath}'")
|
||||||
|
return files
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
for f in dirpath.iterdir():
|
for f in dirpath.iterdir():
|
||||||
if f.is_file():
|
if f.is_file():
|
||||||
if f.name != 'contents.json' and f.name != 'walletindex.html':
|
files.append(Path(f.name).stem)
|
||||||
files.append(Path(f.name).stem)
|
else:
|
||||||
|
files.append(f"-{Path(f.name).stem}-")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
files.append("FileNotFoundError")
|
||||||
pass
|
pass
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
@ -126,7 +126,8 @@ def load_all_scans():
|
|||||||
print("\n ", end='')
|
print("\n ", end='')
|
||||||
|
|
||||||
print(f"{walletname} ", end='')
|
print(f"{walletname} ", end='')
|
||||||
wallet, created = Wallet.objects.update_or_create(walletname=walletname)
|
fpath = Path(settings.SCANS_ROOT, str(yeardir.stem), walletname)
|
||||||
|
wallet, created = Wallet.objects.update_or_create(walletname=walletname, fpath=fpath)
|
||||||
wallets[walletname] = wallet
|
wallets[walletname] = wallet
|
||||||
# could now also load the json and use it. check &ref is correct or missing too..
|
# could now also load the json and use it. check &ref is correct or missing too..
|
||||||
if not created:
|
if not created:
|
||||||
|
@ -85,15 +85,15 @@
|
|||||||
{% if wallets %}<u>Wallets</u> on this date:<br>
|
{% if wallets %}<u>Wallets</u> on this date:<br>
|
||||||
<span style="font-size: 70%; ">
|
<span style="font-size: 70%; ">
|
||||||
{% for item in wallets %}
|
{% for item in wallets %}
|
||||||
<a href="/survey_scans/{{item.walletname|urlencode}}/">{{item.walletname|safe}}</a>
|
<a href="/survey_scans/{{item.walletname|urlencode}}/">{{item.walletname|safe}}</a>
|
||||||
{% if item.name %}
|
{% if item.name %}
|
||||||
{{item.name|safe}} <br/>
|
{{item.name|safe}} <br/>
|
||||||
{% else %}
|
{% else %}
|
||||||
{{item.get_fnames|safe}}
|
{{item.get_fnames|safe}}
|
||||||
<br/>
|
<br/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<em>None found for this date.</em><br>
|
<em>None found for this date.</em><br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</span>
|
</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
Loading…
Reference in New Issue
Block a user