summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/models/survex.py2
-rw-r--r--core/views/survex.py19
-rw-r--r--parsers/survex.py22
-rw-r--r--templates/survexdir.html20
4 files changed, 41 insertions, 22 deletions
diff --git a/core/models/survex.py b/core/models/survex.py
index 7c0f38e..835d31d 100644
--- a/core/models/survex.py
+++ b/core/models/survex.py
@@ -17,7 +17,7 @@ class SurvexDirectory(models.Model):
all relate to the same Cave
"""
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(
"SurvexFile", related_name="primarysurvexfile", blank=True, null=True, on_delete=models.SET_NULL
)
diff --git a/core/views/survex.py b/core/views/survex.py
index 7ac206a..bd9df25 100644
--- a/core/views/survex.py
+++ b/core/views/survex.py
@@ -645,23 +645,30 @@ def survexcaveslist(request):
def survexdir(request):
"""report on all the SurvexDirectory objects
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:
sd.primarybad = True
if f"{sd.primarysurvexfile}".startswith(str(sd.path)):
sd.primarybad = False
- sd.cavebad = True
- munge = f"caves-{sd.cave}".lower()
- if str(sd.path).lower().replace("/","-").startswith(munge):
- sd.cavebad = False
+ # sd.cavebad = True
+ # munge = f"caves-{sd.cave}".lower()
+ # if str(sd.path).lower().replace("/","-").startswith(munge):
+ # sd.cavebad = False
sd.pathbad = True
if Path(settings.SURVEX_DATA, f"{sd.primarysurvexfile}.svx").is_file():
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):
diff --git a/parsers/survex.py b/parsers/survex.py
index 52ecc70..a5a9959 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -1293,7 +1293,7 @@ class LoadingSurvex:
#try again
cave = IdentifyCave(headpath)
if cave:
- newdirectory.cave = cave
+ # newdirectory.cave = cave # turns uout to be never used
newfile.cave = cave
# 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)
for sf in sfs:
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)
for w in ws:
@@ -2499,7 +2500,8 @@ def MakeSurvexFileRoot():
fileroot = SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
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:
# cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.SET_NULL)
directoryroot.save()
@@ -2526,13 +2528,13 @@ def MakeFileRoot(fn):
fileroot.survexdirectory = None
- if cave:
- # But setting the SurvexDirectory does work !
- # The fluffy stuff is because of errors in the original setting of survex directories
- # which needs to be cleaned up..
- for sd in cave.survexdirectory_set.filter(cave=cave):
- if f"{sd.primarysurvexfile}".replace("caves-","").startswith(f"{sd.cave}"[:4]):
- fileroot.survexdirectory = sd
+ # if cave:
+ # # But setting the SurvexDirectory does work !
+ # # The fluffy stuff is because of errors in the original setting of survex directories
+ # # which needs to be cleaned up..
+ # for sd in cave.survexdirectory_set.filter(cave=cave):
+ # if f"{sd.primarysurvexfile}".replace("caves-","").startswith(f"{sd.cave}"[:4]):
+ # fileroot.survexdirectory = sd
fileroot.save()
fileroot.cave = cave
print(f" - new fileroot {type(fileroot)} for {fn} with cave {cave} - {fileroot}")
diff --git a/templates/survexdir.html b/templates/survexdir.html
index 7600077..f0cbf11 100644
--- a/templates/survexdir.html
+++ b/templates/survexdir.html
@@ -7,16 +7,26 @@
<h1>SurvexDirectory objects</h1>
{% endautoescape %}
-
+<h2>All SurvexDirectories</h2>
<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 %}
- <tr>
- <td><span {% if sd.cavebad %} style="color:red" {% endif %}> {{sd.cave}}</span></td>
- <td><em>{{sd.cave.id}}</em></td>
+ <tr>
<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>
</tr>
{% endfor %}
</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 %}