mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 16:51:54 +00:00
Ongoing work to remove SurvexDirectory as a concept
This commit is contained in:
parent
8c721e905a
commit
cc9f425fb5
@ -17,7 +17,7 @@ class SurvexDirectory(models.Model):
|
|||||||
all relate to the same Cave
|
all relate to the same Cave
|
||||||
"""
|
"""
|
||||||
path = models.CharField(max_length=200)
|
path = models.CharField(max_length=200)
|
||||||
cave = models.ForeignKey("Cave", blank=True, null=True, on_delete=models.SET_NULL)
|
# cave = models.ForeignKey("Cave", blank=True, null=True, on_delete=models.SET_NULL) # apparently NEVER USED
|
||||||
primarysurvexfile = models.ForeignKey(
|
primarysurvexfile = models.ForeignKey(
|
||||||
"SurvexFile", related_name="primarysurvexfile", blank=True, null=True, on_delete=models.SET_NULL
|
"SurvexFile", related_name="primarysurvexfile", blank=True, null=True, on_delete=models.SET_NULL
|
||||||
)
|
)
|
||||||
|
@ -645,23 +645,30 @@ def survexcaveslist(request):
|
|||||||
def survexdir(request):
|
def survexdir(request):
|
||||||
"""report on all the SurvexDirectory objects
|
"""report on all the SurvexDirectory objects
|
||||||
We are trying to find out how mismatches have crept in.
|
We are trying to find out how mismatches have crept in.
|
||||||
|
and whether the whole SUrvexDirectory class is actually redundant
|
||||||
|
as the info it holds is always embedded in the survexFile path directories
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sds = SurvexDirectory.objects.all().order_by("cave")
|
sds = SurvexDirectory.objects.all() #.order_by("cave")
|
||||||
for sd in sds:
|
for sd in sds:
|
||||||
sd.primarybad = True
|
sd.primarybad = True
|
||||||
if f"{sd.primarysurvexfile}".startswith(str(sd.path)):
|
if f"{sd.primarysurvexfile}".startswith(str(sd.path)):
|
||||||
sd.primarybad = False
|
sd.primarybad = False
|
||||||
|
|
||||||
sd.cavebad = True
|
# sd.cavebad = True
|
||||||
munge = f"caves-{sd.cave}".lower()
|
# munge = f"caves-{sd.cave}".lower()
|
||||||
if str(sd.path).lower().replace("/","-").startswith(munge):
|
# if str(sd.path).lower().replace("/","-").startswith(munge):
|
||||||
sd.cavebad = False
|
# sd.cavebad = False
|
||||||
|
|
||||||
sd.pathbad = True
|
sd.pathbad = True
|
||||||
if Path(settings.SURVEX_DATA, f"{sd.primarysurvexfile}.svx").is_file():
|
if Path(settings.SURVEX_DATA, f"{sd.primarysurvexfile}.svx").is_file():
|
||||||
sd.pathbad = False
|
sd.pathbad = False
|
||||||
return render(request, "survexdir.html", {"survexdirs": sds})
|
|
||||||
|
survexfiles = SurvexFile.objects.all().order_by("cave")
|
||||||
|
# for f in survexfiles:
|
||||||
|
# if f.cave:
|
||||||
|
# print(f, f.cave)
|
||||||
|
return render(request, "survexdir.html", {"survexdirs": sds, "survexfiles": survexfiles})
|
||||||
|
|
||||||
|
|
||||||
def survexcavesingle(request, survex_cave):
|
def survexcavesingle(request, survex_cave):
|
||||||
|
@ -1293,7 +1293,7 @@ class LoadingSurvex:
|
|||||||
#try again
|
#try again
|
||||||
cave = IdentifyCave(headpath)
|
cave = IdentifyCave(headpath)
|
||||||
if cave:
|
if cave:
|
||||||
newdirectory.cave = cave
|
# newdirectory.cave = cave # turns uout to be never used
|
||||||
newfile.cave = cave
|
newfile.cave = cave
|
||||||
# print(f"\n - New directory '{newdirectory}' for cave '{cave}'",file=sys.stderr)
|
# print(f"\n - New directory '{newdirectory}' for cave '{cave}'",file=sys.stderr)
|
||||||
|
|
||||||
@ -2351,7 +2351,8 @@ def display_contents(blocks):
|
|||||||
sfs = SurvexFile.objects.filter(survexblock=b)
|
sfs = SurvexFile.objects.filter(survexblock=b)
|
||||||
for sf in sfs:
|
for sf in sfs:
|
||||||
print(f" SF {sf}")
|
print(f" SF {sf}")
|
||||||
print(f" SD {sf.survexdirectory} {sf.survexdirectory.cave}")
|
# print(f" SD {sf.survexdirectory} {sf.survexdirectory.cave}")
|
||||||
|
print(f" SD {sf.survexdirectory} {sf.survexdirectory.path}")
|
||||||
|
|
||||||
ws = Wallet.objects.filter(survexblock=b)
|
ws = Wallet.objects.filter(survexblock=b)
|
||||||
for w in ws:
|
for w in ws:
|
||||||
@ -2499,7 +2500,8 @@ def MakeSurvexFileRoot():
|
|||||||
|
|
||||||
fileroot = SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
|
fileroot = SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
|
||||||
fileroot.save()
|
fileroot.save()
|
||||||
directoryroot = SurvexDirectory(path=settings.SURVEX_DATA, cave=smk[0], primarysurvexfile=fileroot)
|
#directoryroot = SurvexDirectory(path=settings.SURVEX_DATA, cave=smk[0], primarysurvexfile=fileroot)
|
||||||
|
directoryroot = SurvexDirectory(path=settings.SURVEX_DATA, primarysurvexfile=fileroot)
|
||||||
# MariaDB doesn't like this hack. Complains about non-null cave_id EVEN THOUGH our model file says this is OK:
|
# MariaDB doesn't like this hack. Complains about non-null cave_id EVEN THOUGH our model file says this is OK:
|
||||||
# cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.SET_NULL)
|
# cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.SET_NULL)
|
||||||
directoryroot.save()
|
directoryroot.save()
|
||||||
@ -2526,13 +2528,13 @@ def MakeFileRoot(fn):
|
|||||||
fileroot.survexdirectory = None
|
fileroot.survexdirectory = None
|
||||||
|
|
||||||
|
|
||||||
if cave:
|
# if cave:
|
||||||
# But setting the SurvexDirectory does work !
|
# # But setting the SurvexDirectory does work !
|
||||||
# The fluffy stuff is because of errors in the original setting of survex directories
|
# # The fluffy stuff is because of errors in the original setting of survex directories
|
||||||
# which needs to be cleaned up..
|
# # which needs to be cleaned up..
|
||||||
for sd in cave.survexdirectory_set.filter(cave=cave):
|
# for sd in cave.survexdirectory_set.filter(cave=cave):
|
||||||
if f"{sd.primarysurvexfile}".replace("caves-","").startswith(f"{sd.cave}"[:4]):
|
# if f"{sd.primarysurvexfile}".replace("caves-","").startswith(f"{sd.cave}"[:4]):
|
||||||
fileroot.survexdirectory = sd
|
# fileroot.survexdirectory = sd
|
||||||
fileroot.save()
|
fileroot.save()
|
||||||
fileroot.cave = cave
|
fileroot.cave = cave
|
||||||
print(f" - new fileroot {type(fileroot)} for {fn} with cave {cave} - {fileroot}")
|
print(f" - new fileroot {type(fileroot)} for {fn} with cave {cave} - {fileroot}")
|
||||||
|
@ -7,16 +7,26 @@
|
|||||||
<h1>SurvexDirectory objects</h1>
|
<h1>SurvexDirectory objects</h1>
|
||||||
{% endautoescape %}
|
{% endautoescape %}
|
||||||
|
|
||||||
|
<h2>All SurvexDirectories</h2>
|
||||||
<table>
|
<table>
|
||||||
<tr><th>Cave</th><th>CaveID</th><th>Path</th><th>Primary</th></tr>
|
<tr><th>Dir Path</th><th>Primary svx</th></tr>
|
||||||
{% for sd in survexdirs %}
|
{% for sd in survexdirs %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><span {% if sd.cavebad %} style="color:red" {% endif %}> {{sd.cave}}</span></td>
|
|
||||||
<td><em>{{sd.cave.id}}</em></td>
|
|
||||||
<td>{{sd.path}}</td>
|
<td>{{sd.path}}</td>
|
||||||
<td><a href="/survexfile/{{sd.primarysurvexfile}}"><span {% if sd.pathbad %} style="color:red" {% endif %}>{{sd.primarysurvexfile}}.svx</span></a><span {% if sd.primarybad %} style="color:blue"> <b>MISMATCH</b> {% endif %}</span></td>
|
<td><a href="/survexfile/{{sd.primarysurvexfile}}"><span {% if sd.pathbad %} style="color:red" {% endif %}>{{sd.primarysurvexfile}}.svx</span></a><span {% if sd.primarybad %} style="color:blue"> <b>MISMATCH</b> {% endif %}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
<p>
|
||||||
|
<h2>All SurvexFiles</h2>
|
||||||
|
<table>
|
||||||
|
<tr><th>Cave</th><th>Dir Path</th><th>svx</th></tr>
|
||||||
|
{% for f in survexfiles %}
|
||||||
|
<tr>
|
||||||
|
<td>{{f.cave}}</td>
|
||||||
|
<td>{{f.survexdirectory.path}}</td>
|
||||||
|
<td><a href="/survexfile/{{f.path}}">{{f.path}}.svx</a></td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user