2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

ent.url removed and entrance edit path simplified

This commit is contained in:
Philip Sargent 2023-11-07 23:23:15 +02:00
parent 1ba37665b5
commit 1e8a5bea6e
6 changed files with 13 additions and 13 deletions

View File

@ -185,7 +185,7 @@ class EntranceForm(ModelForm):
model = Entrance
exclude = (
"cached_primary_slug",
"filename",
"filename"
)
def clean(self):

View File

@ -251,7 +251,6 @@ class Entrance(TroggleModel):
photo = models.TextField(blank=True, null=True)
slug = models.SlugField(max_length=50, unique=True, default="default_slug_id")
underground_description = models.TextField(blank=True, null=True)
url = models.CharField(max_length=300, blank=True, null=True)
tag_station = models.TextField(blank=True, null=True)
other_station = models.TextField(blank=True, null=True)

View File

@ -551,10 +551,9 @@ def read_entrance(filename, ent=None):
ent.other_description=other_description[0]
ent.other_station=other_station[0]
ent.photo=photo[0]
# ent.slug=slugs[0]
# ent.slug=slugs[0] # set algorithically
ent.tag_station=tag_station[0]
ent.underground_description=underground_description[0]
ent.url=url[0]
for st in [ent.other_station, ent.tag_station]:
#validate_station(st)
@ -604,12 +603,15 @@ def read_cave(filename, cave=None):
letter = getXML(e, "letter", maxItems=1, context=context)[0]
if len(entrances) > 1 and letter =="":
# user error, but we can recover
# Usually the second entrance is 'b', but the first is still unlettered. So probably 'a'
letter = eslug[-1].lower()
if letter.lower() not in list(string.ascii_lowercase):
letter = "x"
letter = "a"
message = f"- Warning - Empty 'letter' field for '{eslug}' in multiple-entrance cave '{cave}', setting to {letter}."
DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}_cave_edit/")
#eurl = f"{cave.url}_cave_edit/"
eurl = Path(cave.url).parent + f"{cave.slug()}_cave_edit/"
# edit recognizer: (?P<path>.*)/(?P<slug>[^/]+)_cave_edit/$
DataIssue.objects.create(parser="entrances", message=message, url=eurl)
print(message)
if len(entrances) == 1 and not eslug: # may be empty: <entranceslug></entranceslug>
@ -821,8 +823,7 @@ def read_cave(filename, cave=None):
cave.extent=extent[0]
cave.survex_file=survex_file[0]
cave.description_file=description_file[0]
# cave.url=url[0]
# override url in file. We now have a standard canonical form:
# cave.url=url[0] # set algorithically:
cave.url = f"{cave.areacode}/{cave.number()}/{cave.number()}.html"
check_directory(cave.areacode, cave.number(), cave.url, cave)

View File

@ -137,7 +137,7 @@ def validate_entrance_stations(ent=None):
"""
nonlocal bads
nonlocal good
# {% url "editentrance" ent.entrance.url_parent cave.slug ent.entrance.slug %}
# {% url "editentrance" cave.slug ent.entrance.slug %}
# e.g. url = f"/1623/101/1623-101:{ent}_entrance_edit"
cavelist = ent.cavelist()
if len(cavelist) == 1:

View File

@ -137,7 +137,7 @@
Id letter: '{{ ent.entranceletter|safe}}'
{% if ent.entrance.name %}
{{ ent.entrance.name|safe }}
{% endif %}<a class="editlink" href="{% if local %}https://expo.survex.com{% endif %}{% url "editentrance" ent.entrance.url_parent cave.slug ent.entrance.slug %}">Edit this entrance</a>
{% endif %}<a class="editlink" href="{% if local %}https://expo.survex.com{% endif %}{% url "editentrance" cave.slug ent.entrance.slug %}">Edit this entrance</a>
<dl>
{% if ent.entrance.marking %}
<dt>Marking</dt><dd>{{ ent.entrance.marking_val|safe }}</dd>

View File

@ -156,7 +156,7 @@ trogglepatterns = [
# Edit caves and entrances
re_path(r'^(?P<path>.*)/(?P<slug>[^/]+)_cave_edit/$', edit_cave, name="edit_cave"), # edit_cave needed by cave.html template for url matching
re_path(r'^(?P<path>.*)/(?P<caveslug>[^/]+):(?P<entslug>[^:]+)_entrance_edit', edit_entrance, name = "editentrance"), #edit existing entrance
re_path(r'^(?P<caveslug>[^/]+):(?P<entslug>[^:]+)_entrance_edit', edit_entrance, name = "editentrance"), #edit existing entrance
re_path(r'^(?P<path>.*)/(?P<caveslug>[^/]+)_entrance_new$', edit_entrance, name = "newentrance"), # new entrance for a cave
re_path(r'^(.*)_edit$', editexpopage, name="editexpopage"),