mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
fix green block for survex files on table
This commit is contained in:
parent
5c667c1826
commit
6452a7beed
@ -177,7 +177,7 @@ class Wallet(models.Model):
|
||||
return urljoin(settings.URL_ROOT, reverse('singlewallet', kwargs={"path":re.sub("#", "%23", self.walletname)}))
|
||||
|
||||
def get_json(self):
|
||||
jsonfile = Path(self.fpath, 'contents.json')
|
||||
#jsonfile = Path(self.fpath, 'contents.json')
|
||||
|
||||
# Get from git repo instead
|
||||
# :drawings: walletjson/2022/2022#01/contents.json
|
||||
@ -251,7 +251,14 @@ class Wallet(models.Model):
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
return files
|
||||
|
||||
|
||||
def fixsurvextick(self, tick):
|
||||
blocks = SurvexBlock.objects.filter(scanswallet = self)
|
||||
result = tick
|
||||
for b in blocks:
|
||||
if b.survexfile: # if any exist in db, no check for validity or a real file. Refactor.
|
||||
result = "seagreen" # slightly different shade of green
|
||||
return result
|
||||
|
||||
def get_ticks(self):
|
||||
ticks = {}
|
||||
|
@ -42,7 +42,7 @@ def dwgfilesingle(request, path):
|
||||
webpage /dwgupload/... if the user types the filename into the browser bar. Could be a problem?
|
||||
Should we validate using uploads.py dwgvaliddisp() here too?
|
||||
'''
|
||||
tfile = Path(settings.DRAWINGS_DATA, path)
|
||||
tfile = Path(settings.DRAWINGS_DATA, path.replace(":","#"))
|
||||
if not tfile.is_file():
|
||||
message = f'Drawing file not found in filesystem at \'{path}\' .'
|
||||
return render(request, 'errors/generic.html', {'message': message})
|
||||
|
@ -95,8 +95,11 @@ def fillblankothers(w):
|
||||
c = w.cave()
|
||||
if not c:
|
||||
caveifywallet(w)
|
||||
|
||||
|
||||
def fixsurvextick(w, ticks):
|
||||
ticks["S"] = w.fixsurvextick(ticks["S"])
|
||||
|
||||
|
||||
def walletslistperson(request, first_name, last_name):
|
||||
'''Page which displays a list of all the wallets for a specific person
|
||||
HORRIBLE linear search through everything. Index and do SQL query properly
|
||||
@ -114,6 +117,7 @@ def walletslistperson(request, first_name, last_name):
|
||||
manywallets.append(w)
|
||||
fillblankothers(w)
|
||||
w.ticks = w.get_ticks() # the complaints in colour form
|
||||
fixsurvextick(w, w.ticks)
|
||||
return manywallets
|
||||
|
||||
try:
|
||||
@ -143,7 +147,8 @@ def walletslistyear(request, year):
|
||||
manywallets.append(w)
|
||||
fillblankpeople(w)
|
||||
fillblankothers(w)
|
||||
w.ticks = w.get_ticks() # the complaints in colour form
|
||||
w.ticks = w.get_ticks() # the complaints in colour form, from the json file on disc
|
||||
fixsurvextick(w, w.ticks)
|
||||
else:
|
||||
continue
|
||||
|
||||
@ -177,7 +182,8 @@ def cavewallets(request, caveid):
|
||||
for w in manywallets:
|
||||
fillblankpeople(w)
|
||||
fillblankothers(w)
|
||||
w.ticks = w.get_ticks() # the complaints in colour form
|
||||
w.ticks = w.get_ticks() # the complaints in colour form, from the json file on disc
|
||||
fixsurvextick(w, w.ticks)
|
||||
return render(request, 'cavewallets.html', { 'manywallets':manywallets, 'settings': settings, 'cave': cave})
|
||||
|
||||
|
||||
|
@ -240,7 +240,7 @@ def scanupload(request, path=None):
|
||||
git = settings.GIT
|
||||
filesaved = False
|
||||
actual_saved = []
|
||||
|
||||
|
||||
def read_json():
|
||||
'''Read JSON from the wallet metadata file in the repo
|
||||
or fills with blank data if that files can't be read'''
|
||||
@ -472,7 +472,12 @@ def scanupload(request, path=None):
|
||||
|
||||
waldata = read_json()
|
||||
|
||||
cave =""
|
||||
jsonfile = Path(settings.DRAWINGS_DATA, "walletjson") / wallet[0:4] / wallet / "contents.json"
|
||||
print(f'! - FORM scanupload - jsonfile {jsonfile}')
|
||||
if not Path(jsonfile).is_file():
|
||||
metadataurl = ""
|
||||
else:
|
||||
metadataurl = Path("/dwgdataraw", "walletjson") / wallet[0:4] / wallet.replace("#",":") / "contents.json"
|
||||
psg = ""
|
||||
chkplannr = ""
|
||||
chkpland = ""
|
||||
@ -565,14 +570,16 @@ def scanupload(request, path=None):
|
||||
waldata["name"] = f"several, please edit: {names}"
|
||||
print(f' - More than one block name is relevant {names} in this wallet {wallet}. Not managed in this troggle release.')
|
||||
|
||||
if waldata["cave"]:
|
||||
if "cave" in waldata:
|
||||
cave = waldata["cave"] # text string
|
||||
else:
|
||||
cave = ""
|
||||
if waldata["name"]:
|
||||
psg = waldata["name"]
|
||||
if not waldata["description url"]:
|
||||
waldata["description url"]=""
|
||||
|
||||
#Survex and survex complaints
|
||||
#Survex and survex complaints, comes from json file on disc, not as pre-populated as above
|
||||
complaints, caveobject = get_complaints([], waldata, svxfiles, files, wallet, wurl)
|
||||
# print(f' - {caveobject=}')
|
||||
|
||||
@ -586,7 +593,7 @@ def scanupload(request, path=None):
|
||||
context = {'year': year, 'prev': prev, 'next': next, 'prevy': prevy, 'nexty': nexty,
|
||||
'files': files, 'dirs': dirs, 'waldata': waldata, 'svxfiles': svxfiles,
|
||||
'checked': checked,
|
||||
'create': create,
|
||||
'create': create, 'metadataurl': metadataurl,
|
||||
'complaints': complaints,
|
||||
'caveobject': caveobject,
|
||||
'people': waldata["people"], 'peoplesize': str(len(str(waldata["people"]))),
|
||||
|
@ -98,6 +98,7 @@
|
||||
|
||||
{% endif %}
|
||||
<hr />
|
||||
|
||||
{% if not create %}
|
||||
<br>
|
||||
<span style="font-family: monospace; font-size: 150%; ">
|
||||
@ -112,9 +113,11 @@
|
||||
{% for svx in svxfiles%}
|
||||
<a href="/survexfile/{{svx}}">{{svx}}</a>
|
||||
{% endfor %}
|
||||
|
||||
<br><br>
|
||||
|
||||
<br>
|
||||
{% endif %}
|
||||
{% if metadataurl %}<u>Debug</u>: <a href="{{metadataurl}}">json file</a><br> {% endif %}
|
||||
|
||||
</span>
|
||||
<span style="font-family: monospace; font-size: 130%; ">
|
||||
<!--
|
||||
|
Loading…
Reference in New Issue
Block a user