summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-09-06 17:19:20 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2023-09-06 17:19:20 +0300
commit0dc0e275193457d1875ca1690168112a61b4bca4 (patch)
tree774f1c92d20fedcdaf10e48c6843b536af64341b /core
parent3c6cae20eda7dc060aa5bc3fe8da400699130025 (diff)
downloadtroggle-0dc0e275193457d1875ca1690168112a61b4bca4.tar.gz
troggle-0dc0e275193457d1875ca1690168112a61b4bca4.tar.bz2
troggle-0dc0e275193457d1875ca1690168112a61b4bca4.zip
moving primary survex file to each survexfile
Diffstat (limited to 'core')
-rw-r--r--core/models/caves.py3
-rw-r--r--core/models/survex.py14
-rw-r--r--core/views/survex.py30
3 files changed, 28 insertions, 19 deletions
diff --git a/core/models/caves.py b/core/models/caves.py
index e8cfeea..28b9d4c 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -515,9 +515,6 @@ def GetCaveLookup():
global Gcave_count
Gcave_count = defaultdict(int) # sets default value to int(0)
- DataIssue.objects.filter(parser="aliases").delete()
- DataIssue.objects.filter(parser="aliases ok").delete()
-
for cave in Cave.objects.all():
key = cave.official_name.lower()
if key != "" and key != "unamed" and key != "unnamed":
diff --git a/core/models/survex.py b/core/models/survex.py
index 835d31d..2ca7412 100644
--- a/core/models/survex.py
+++ b/core/models/survex.py
@@ -12,16 +12,17 @@ from django.urls import reverse
class SurvexDirectory(models.Model):
- """This relates a Cave to the primary SurvexFile which is the 'head' of the survex tree for
- that cave. Surely this could just be a property of Cave ? No. Several subdirectories
- all relate to the same Cave
+ """This relates a survexfile (identified by path) to the primary SurvexFile
+ which is the 'head' of the survex tree for that cave.
+ Surely this could just be a property of Cave ? No. Several subdirectories
+ all relate to the same Cave.
+
+ But it *could* be a property of SurvexFile
"""
path = models.CharField(max_length=200)
- # 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
)
- # could also include files in directory but not referenced
class Meta:
ordering = ("id",)
@@ -37,6 +38,9 @@ class SurvexDirectory(models.Model):
class SurvexFile(models.Model):
path = models.CharField(max_length=200)
survexdirectory = models.ForeignKey("SurvexDirectory", blank=True, null=True, on_delete=models.SET_NULL)
+ primary = models.ForeignKey(
+ "SurvexFile", related_name="primarysurvex", blank=True, null=True, on_delete=models.SET_NULL
+ )
cave = models.ForeignKey("Cave", blank=True, null=True, on_delete=models.SET_NULL)
class Meta:
diff --git a/core/views/survex.py b/core/views/survex.py
index 3ecd523..10ebbd0 100644
--- a/core/views/survex.py
+++ b/core/views/survex.py
@@ -563,7 +563,11 @@ def get_survexareapath(area):
def survexcaveslist(request):
"""This reads the entire list of caves in the Loser repo directory and produces a complete report.
It can find caves which have not yet been properly registered in the system by Databasereset.py because
- someone may have uploaded the survex files without doing the rest of the integration process.
+ someone may have uploaded the survex files with git without doing the rest of the integration process.
+
+ But maybe we don't care if someone has done that!
+ In which case we don't need any of this reading the filesystem, we can generate it all from
+ what is already in the db, and just construct: onefilecaves, multifilecaves, subdircaves.
It uses very impenetrable code in identifycavedircontents()
"""
@@ -651,23 +655,27 @@ def survexdir(request):
sds = SurvexDirectory.objects.all() #.order_by("cave")
for sd in sds:
- sd.primarybad = True
+ sd.matchbad = 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.matchbad = False
sd.pathbad = True
if Path(settings.SURVEX_DATA, f"{sd.primarysurvexfile}.svx").is_file():
sd.pathbad = False
survexfiles = SurvexFile.objects.all().order_by("cave")
- # for f in survexfiles:
- # if f.cave:
- # print(f, f.cave)
+ for f in survexfiles:
+ f.matchbad = True
+ if f"{f.path}".startswith(str(f.survexdirectory.path)):
+ f.matchbad = False
+ f.primarybad = True
+ if f.primary:
+ f.pathparent = Path(f.primary.path).parent
+ if str(f.survexdirectory.path) == str(f.pathparent):
+ f.primarybad = False
+ f.pathbad = True
+ if Path(settings.SURVEX_DATA, f"{f.path}.svx").is_file():
+ f.pathbad = False
return render(request, "survexdir.html", {"survexdirs": sds, "survexfiles": survexfiles})
def get_directories(cave):