summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/models/caves.py75
-rw-r--r--core/views/caves.py10
-rw-r--r--parsers/caves.py5
-rw-r--r--templates/cave_debug.html36
-rw-r--r--templates/editcave.html2
-rw-r--r--urls.py3
6 files changed, 91 insertions, 40 deletions
diff --git a/core/models/caves.py b/core/models/caves.py
index 0001814..bae8eb5 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -74,30 +74,32 @@ class CaveAndEntrance(models.Model):
def __str__(self):
return str(self.cave) + str(self.entrance_letter)
+# class CaveSlug(models.Model):
+# moved to models/logbooks.py to avoid cyclic import problem
class Cave(TroggleModel):
# too much here perhaps,
- official_name = models.CharField(max_length=160)
area = models.ManyToManyField(Area, blank=True)
- kataster_code = models.CharField(max_length=20, blank=True, null=True)
- kataster_number = models.CharField(max_length=10, blank=True, null=True)
- unofficial_number = models.CharField(max_length=60, blank=True, null=True)
+ depth = models.CharField(max_length=100, blank=True, null=True)
+ description_file = models.CharField(max_length=200, blank=True, null=True)
entrances = models.ManyToManyField("Entrance", through="CaveAndEntrance")
- explorers = models.TextField(blank=True, null=True)
- underground_description = models.TextField(blank=True, null=True)
equipment = models.TextField(blank=True, null=True)
- references = models.TextField(blank=True, null=True)
- survey = models.TextField(blank=True, null=True)
+ explorers = models.TextField(blank=True, null=True)
+ extent = models.CharField(max_length=100, blank=True, null=True)
+ filename = models.CharField(max_length=200)
+ kataster_code = models.CharField(max_length=20, blank=True, null=True)
+ kataster_number = models.CharField(max_length=10, blank=True, null=True)
kataster_status = models.TextField(blank=True, null=True)
- underground_centre_line = models.TextField(blank=True, null=True)
- notes = models.TextField(blank=True, null=True)
length = models.CharField(max_length=100, blank=True, null=True)
- depth = models.CharField(max_length=100, blank=True, null=True)
- extent = models.CharField(max_length=100, blank=True, null=True)
+ notes = models.TextField(blank=True, null=True)
+ official_name = models.CharField(max_length=160)
+ references = models.TextField(blank=True, null=True)
survex_file = models.CharField(max_length=100, blank=True, null=True) # should be a foreign key
- description_file = models.CharField(max_length=200, blank=True, null=True)
+ survey = models.TextField(blank=True, null=True)
+ underground_centre_line = models.TextField(blank=True, null=True)
+ underground_description = models.TextField(blank=True, null=True)
+ unofficial_number = models.CharField(max_length=60, blank=True, null=True)
url = models.CharField(max_length=200, blank=True, null=True)
- filename = models.CharField(max_length=200)
# class Meta:
# unique_together = (("area", "kataster_number"), ("area", "unofficial_number"))
@@ -267,15 +269,6 @@ class EntranceSlug(models.Model):
class Entrance(TroggleModel):
- name = models.CharField(max_length=100, blank=True, null=True)
- entrance_description = models.TextField(blank=True, null=True)
- explorers = models.TextField(blank=True, null=True)
- map_description = models.TextField(blank=True, null=True)
- location_description = models.TextField(blank=True, null=True)
- lastvisit = models.TextField(blank=True, null=True)
- approach = models.TextField(blank=True, null=True)
- underground_description = models.TextField(blank=True, null=True)
- photo = models.TextField(blank=True, null=True)
MARKING_CHOICES = (
("P", "Paint"),
("P?", "Paint (?)"),
@@ -286,25 +279,34 @@ class Entrance(TroggleModel):
("S?", "Spit (?)"),
("U", "Unmarked"),
("?", "Unknown"),
- )
- marking = models.CharField(max_length=2, choices=MARKING_CHOICES)
- marking_comment = models.TextField(blank=True, null=True)
+ )
FINDABLE_CHOICES = (("?", "To be confirmed ..."), ("S", "Coordinates"), ("L", "Lost"), ("R", "Refindable"))
- findability = models.CharField(max_length=1, choices=FINDABLE_CHOICES, blank=True, null=True)
- findability_description = models.TextField(blank=True, null=True)
alt = models.TextField(blank=True, null=True)
- northing = models.TextField(blank=True, null=True)
+ approach = models.TextField(blank=True, null=True)
+ bearings = models.TextField(blank=True, null=True)
+ cached_primary_slug = models.CharField(max_length=200, blank=True, null=True)
easting = models.TextField(blank=True, null=True)
+ entrance_description = models.TextField(blank=True, null=True)
+ exact_station = models.TextField(blank=True, null=True)
+ explorers = models.TextField(blank=True, null=True)
+ filename = models.CharField(max_length=200)
+ findability = models.CharField(max_length=1, choices=FINDABLE_CHOICES, blank=True, null=True)
+ findability_description = models.TextField(blank=True, null=True)
+ lastvisit = models.TextField(blank=True, null=True)
lat_wgs84 = models.TextField(blank=True, null=True)
+ location_description = models.TextField(blank=True, null=True)
long_wgs84 = models.TextField(blank=True, null=True)
- tag_station = models.TextField(blank=True, null=True)
- exact_station = models.TextField(blank=True, null=True)
- other_station = models.TextField(blank=True, null=True)
+ map_description = models.TextField(blank=True, null=True)
+ marking = models.CharField(max_length=2, choices=MARKING_CHOICES)
+ marking_comment = models.TextField(blank=True, null=True)
+ name = models.CharField(max_length=100, blank=True, null=True)
+ northing = models.TextField(blank=True, null=True)
other_description = models.TextField(blank=True, null=True)
- bearings = models.TextField(blank=True, null=True)
+ other_station = models.TextField(blank=True, null=True)
+ photo = models.TextField(blank=True, null=True)
+ tag_station = models.TextField(blank=True, null=True)
+ underground_description = models.TextField(blank=True, null=True)
url = models.CharField(max_length=200, blank=True, null=True)
- filename = models.CharField(max_length=200)
- cached_primary_slug = models.CharField(max_length=200, blank=True, null=True)
class Meta:
ordering = ["caveandentrance__entrance_letter"]
@@ -393,6 +395,9 @@ class Entrance(TroggleModel):
return res
def slug(self):
+ """Returns the first slug with primary=True that it can find,
+ if there are none with primary=True, then it returns the first slug it finds
+ """
if not self.cached_primary_slug:
primarySlugs = self.entranceslug_set.filter(primary=True)
if primarySlugs:
diff --git a/core/views/caves.py b/core/views/caves.py
index af59bc9..81a1e8e 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -483,7 +483,15 @@ def ent(request, cave_id, ent_letter):
},
)
-
+def cave_debug(request):
+ ents = Entrance.objects.all()
+ #slugs = self.entranceslug_set.filter()
+ return render(
+ request,
+ "cave_debug.html",
+ {"ents": ents},
+ )
+
# def entranceSlug(request, slug):
# '''This seems to be a fossil, but I am not sure...
# '''
diff --git a/parsers/caves.py b/parsers/caves.py
index f12cd84..feb8fbb 100644
--- a/parsers/caves.py
+++ b/parsers/caves.py
@@ -373,7 +373,8 @@ def readentrance(filename):
# need to cope with duplicates
message = f" ! FAILED to get precisely one ENTRANCE when updating using: cave_entrance/{filename}"
DataIssue.objects.create(parser="caves", message=message, url=f"/cave/{slug}/edit/")
- kents = EntranceSlug.objects.all().filter(entrance=e, slug=slug, primary=primary)
+ # kents = EntranceSlug.objects.all().filter(entrance=e, slug=slug, primary=primary)
+ kents = EntranceSlug.objects.all().filter(entrance=e, slug=slug)
for k in kents:
message = " ! - DUPLICATE in db. entrance:" + str(k.entrance) + ", slug:" + str(k.slug())
DataIssue.objects.create(parser="caves", message=message, url=f"/cave/{slug}/edit/")
@@ -509,7 +510,7 @@ def readcave(filename):
newArea.save()
areas_xslug[area_slug] = newArea
c.area.add(newArea)
- primary = True
+ primary = True # this sets the first thing we find to be primary=True and all the others =False
for slug in slugs:
if slug in caves_xslug:
cs = caves_xslug[slug]
diff --git a/templates/cave_debug.html b/templates/cave_debug.html
new file mode 100644
index 0000000..be0ce20
--- /dev/null
+++ b/templates/cave_debug.html
@@ -0,0 +1,36 @@
+{% extends "base.html" %}
+{% block title %}DEBUG page
+<!-- cave_debug.html - this text visible because this template has been included -->
+{% endblock %}
+
+{% block content %}
+
+<h2 id="cmult">Entrances</h2>
+<table>
+<tr><th>ent</th>
+<th>cached_primary_slug</th>
+<th>N slugs</th>
+<th>slugs</th>
+</tr>
+{% for ent in ents %}
+<tr>
+ <td>
+ {{ent}}
+ </td>
+ <td>
+ {{ent.cached_primary_slug}}
+ </td>
+ <td>
+ {{ent.entranceslug_set.all|length }}
+ </td>
+ <td>
+ {% for s in ent.entranceslug_set.all %}
+ {{s.slug}},
+ {% endfor %}
+ </td>
+
+{% endfor %}
+</table>
+
+
+{% endblock %}
diff --git a/templates/editcave.html b/templates/editcave.html
index 75033b3..640412a 100644
--- a/templates/editcave.html
+++ b/templates/editcave.html
@@ -8,7 +8,7 @@
{% include 'html_editor_pop_ups.html' %}
<h2>{{message}}</h2>
<form action="" method="post">{% csrf_token %}
- <table>{{ form }}<!--1-->{{caveAndEntranceFormSet}}<!--2--></table>
+ <table>{{ form }}<!-- begin caveAndEntranceFormSet-->{{caveAndEntranceFormSet}}<!--end caveAndEntranceFormSet--></table>
<p><input type="submit" value="Submit" /></p>
</form>
diff --git a/urls.py b/urls.py
index e257832..fbee871 100644
--- a/urls.py
+++ b/urls.py
@@ -5,7 +5,7 @@ from django.urls import include, path, re_path
from troggle.core.views import statistics, survex
from troggle.core.views.auth import expologin, expologout
from troggle.core.views.caves import (cave3d, caveEntrance, caveindex,
- cavepage, caveQMs, edit_cave,
+ cavepage, caveQMs, edit_cave, cave_debug,
edit_entrance, get_entrances, qm)
from troggle.core.views.drawings import dwgallfiles, dwgfilesingle
from troggle.core.views.editor_helpers import image_selector, new_image_form
@@ -133,6 +133,7 @@ trogglepatterns = [
re_path(r'^getEntrances/(?P<caveslug>.*)', get_entrances, name = "get_entrances"), # used internally ?
# Cave description pages
+ path('cave_debug', cave_debug, name="cave_debug"),
re_path(r'^newcave/$', edit_cave, name="newcave"),
re_path(r'^cave/3d/(?P<cave_id>[^/]+)$', cave3d, name="cave3d"),