2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 17:27:16 +00:00

fix green block for survex files on table

This commit is contained in:
Philip Sargent
2022-08-31 12:09:07 +03:00
parent 5c667c1826
commit 6452a7beed
5 changed files with 36 additions and 13 deletions

View File

@@ -177,7 +177,7 @@ class Wallet(models.Model):
return urljoin(settings.URL_ROOT, reverse('singlewallet', kwargs={"path":re.sub("#", "%23", self.walletname)})) return urljoin(settings.URL_ROOT, reverse('singlewallet', kwargs={"path":re.sub("#", "%23", self.walletname)}))
def get_json(self): def get_json(self):
jsonfile = Path(self.fpath, 'contents.json') #jsonfile = Path(self.fpath, 'contents.json')
# Get from git repo instead # Get from git repo instead
# :drawings: walletjson/2022/2022#01/contents.json # :drawings: walletjson/2022/2022#01/contents.json
@@ -251,7 +251,14 @@ class Wallet(models.Model):
except FileNotFoundError: except FileNotFoundError:
pass pass
return files 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): def get_ticks(self):
ticks = {} ticks = {}

View File

@@ -42,7 +42,7 @@ def dwgfilesingle(request, path):
webpage /dwgupload/... if the user types the filename into the browser bar. Could be a problem? 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? 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(): if not tfile.is_file():
message = f'Drawing file not found in filesystem at \'{path}\' .' message = f'Drawing file not found in filesystem at \'{path}\' .'
return render(request, 'errors/generic.html', {'message': message}) return render(request, 'errors/generic.html', {'message': message})

View File

@@ -95,8 +95,11 @@ def fillblankothers(w):
c = w.cave() c = w.cave()
if not c: if not c:
caveifywallet(w) caveifywallet(w)
def fixsurvextick(w, ticks):
ticks["S"] = w.fixsurvextick(ticks["S"])
def walletslistperson(request, first_name, last_name): def walletslistperson(request, first_name, last_name):
'''Page which displays a list of all the wallets for a specific person '''Page which displays a list of all the wallets for a specific person
HORRIBLE linear search through everything. Index and do SQL query properly 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) manywallets.append(w)
fillblankothers(w) fillblankothers(w)
w.ticks = w.get_ticks() # the complaints in colour form w.ticks = w.get_ticks() # the complaints in colour form
fixsurvextick(w, w.ticks)
return manywallets return manywallets
try: try:
@@ -143,7 +147,8 @@ def walletslistyear(request, year):
manywallets.append(w) manywallets.append(w)
fillblankpeople(w) fillblankpeople(w)
fillblankothers(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: else:
continue continue
@@ -177,7 +182,8 @@ def cavewallets(request, caveid):
for w in manywallets: for w in manywallets:
fillblankpeople(w) fillblankpeople(w)
fillblankothers(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}) return render(request, 'cavewallets.html', { 'manywallets':manywallets, 'settings': settings, 'cave': cave})

View File

@@ -240,7 +240,7 @@ def scanupload(request, path=None):
git = settings.GIT git = settings.GIT
filesaved = False filesaved = False
actual_saved = [] actual_saved = []
def read_json(): def read_json():
'''Read JSON from the wallet metadata file in the repo '''Read JSON from the wallet metadata file in the repo
or fills with blank data if that files can't be read''' or fills with blank data if that files can't be read'''
@@ -472,7 +472,12 @@ def scanupload(request, path=None):
waldata = read_json() 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 = "" psg = ""
chkplannr = "" chkplannr = ""
chkpland = "" chkpland = ""
@@ -565,14 +570,16 @@ def scanupload(request, path=None):
waldata["name"] = f"several, please edit: {names}" 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.') 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 cave = waldata["cave"] # text string
else:
cave = ""
if waldata["name"]: if waldata["name"]:
psg = waldata["name"] psg = waldata["name"]
if not waldata["description url"]: if not waldata["description url"]:
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) complaints, caveobject = get_complaints([], waldata, svxfiles, files, wallet, wurl)
# print(f' - {caveobject=}') # print(f' - {caveobject=}')
@@ -586,7 +593,7 @@ def scanupload(request, path=None):
context = {'year': year, 'prev': prev, 'next': next, 'prevy': prevy, 'nexty': nexty, context = {'year': year, 'prev': prev, 'next': next, 'prevy': prevy, 'nexty': nexty,
'files': files, 'dirs': dirs, 'waldata': waldata, 'svxfiles': svxfiles, 'files': files, 'dirs': dirs, 'waldata': waldata, 'svxfiles': svxfiles,
'checked': checked, 'checked': checked,
'create': create, 'create': create, 'metadataurl': metadataurl,
'complaints': complaints, 'complaints': complaints,
'caveobject': caveobject, 'caveobject': caveobject,
'people': waldata["people"], 'peoplesize': str(len(str(waldata["people"]))), 'people': waldata["people"], 'peoplesize': str(len(str(waldata["people"]))),

View File

@@ -98,6 +98,7 @@
{% endif %} {% endif %}
<hr /> <hr />
{% if not create %} {% if not create %}
<br> <br>
<span style="font-family: monospace; font-size: 150%; "> <span style="font-family: monospace; font-size: 150%; ">
@@ -112,9 +113,11 @@
{% for svx in svxfiles%} {% for svx in svxfiles%}
<a href="/survexfile/{{svx}}">{{svx}}</a> <a href="/survexfile/{{svx}}">{{svx}}</a>
{% endfor %} {% endfor %}
<br><br> <br>
{% endif %} {% endif %}
{% if metadataurl %}<u>Debug</u>: <a href="{{metadataurl}}">json file</a><br> {% endif %}
</span> </span>
<span style="font-family: monospace; font-size: 130%; "> <span style="font-family: monospace; font-size: 130%; ">
<!-- <!--