diff --git a/core/views/caves.py b/core/views/caves.py index bd1de70..90a8451 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -453,6 +453,9 @@ def edit_entrance(request, path="", caveslug=None, entslug=None): Warning. This uses Django deep magic for multiple forms and the CaveAndEntrance class. It does save the data into into the database directly, not by parsing the file. + + GET RID of all this entranceletter stuff. Far too overcomplexified. + We don't need it. Just the entrance slug is fine, then check uniqueness. """ try: @@ -479,23 +482,35 @@ def edit_entrance(request, path="", caveslug=None, entslug=None): if caveAndEntrance.entranceletter == "" and cave.entrances().count() > 0 : # this should not be blank on a multiple-entrance cave - # but it doesn't trigger the entrnce letter form unless entletter has a value + # but it doesn't trigger the entrance letter form unless entletter has a value entlettereditable = True print(f"{entlettereditable=}") + # if the entletter is no editable, then the entletterform does not appear and so is always invalid. if request.POST: print(f"POST Online edit of entrance: '{entrance}' where {cave=}") - form = EntranceForm(request.POST, instance=entrance) - entletterform = EntranceLetterForm(request.POST, instance=caveAndEntrance) - if form.is_valid() and entletterform.is_valid(): - entrance = form.save(commit=False) - ce = entletterform.save(commit=False) - print(f"- POST {caveslug=} {entslug=} {ce=} {entletterform.cleaned_data['entranceletter']=} {path=}") + entform = EntranceForm(request.POST, instance=entrance) + if not entlettereditable: + entranceletter = caveAndEntrance.entranceletter + ce = caveAndEntrance + else: + entletterform = EntranceLetterForm(request.POST, instance=caveAndEntrance) + if entletterform.is_valid(): + ce = entletterform.save(commit=False) + entranceletter = entletterform.cleaned_data["entranceletter"] + else: + print(f"- POST INVALID {caveslug=} {entslug=} {path=} entletterform invalid.") + return render(request, "errors/badslug.html", {"entletter problem in edit_entrances()"}) + # if entform.is_valid() and entletterform.is_valid(): + if entform.is_valid(): + entrance = entform.save(commit=False) + + print(f"- POST {caveslug=} {entslug=} {entranceletter=} {path=}") if entslug is None: - if entletterform.cleaned_data["entranceletter"]: - slugname = cave.slug() + entletterform.cleaned_data["entranceletter"] - print(f"- POST letter {entletterform.cleaned_data['entranceletter']=}") + if entranceletter: + slugname = cave.slug() + entranceletter + print(f"- POST letter {entranceletter=}") else: slugname = cave.slug() entrance.slug = slugname @@ -524,6 +539,8 @@ def edit_entrance(request, path="", caveslug=None, entslug=None): print(f"- POST WRITE letter: '{ce}' {entrance=}") write_and_commit([entrance_file, cave_file], f"Online edit of entrance {entrance.slug}") return HttpResponseRedirect("/" + cave.url) + else: # one of the forms is not valid + print(f"- POST INVALID {caveslug=} {entslug=} {path=} entform valid:{entform.is_valid()} entletterform valid:{entletterform.is_valid()}") else: # GET the page, not POST, or if either of the forms were invalid when POSTed entletterform = None diff --git a/templates/eastings.html b/templates/eastings.html index 399cb97..e759c42 100644 --- a/templates/eastings.html +++ b/templates/eastings.html @@ -70,8 +70,35 @@ Such converted eastings and northings are in italics in the table below {% endfor %} +
and what those stations are: +
Cave | tag | tag x | tag y | tag exact | exact x | exact y | tag other | other x | other y |
---|---|---|---|---|---|---|---|---|---|
+ {% for c in ent.cavelist %}
+
+ {% if c.official_name %}
+ {{c.official_name|safe}}
+ {% else %}
+ {{c|safe}}
+ {% endif %} + {% endfor %} |
+
+ {{ent.tag_station}} | +{{ent.tag_ts.x|floatformat:0}} | +{{ent.tag_ts.y|floatformat:0}} | +{{ent.exact_station}} | +{{ent.tag_es.x|floatformat:0}} | +{{ent.tag_es.y|floatformat:0}} | +{{ent.other_station}} | +{{ent.tag_os.x|floatformat:0}} | +{{ent.tag_os.y|floatformat:0}} | +
and now the GPS equivalents: +
Cave | GPS Lat | GPS Long | best Lat | best Long | tag | tag Lat | tag Long | tag exact | exact Lat | exact Long | tag other | other Lat | other Long |
---|
See also Entrances list.
But the Entrances - the objects in the troggle system - are not properly connected to the dataset which is the combined set of survex data. They are only linked - and only implicitly - by the tag name. The data in the table below is calculated directly from the assemblage of survex files, including fixed point files, and is probably 'correct'.
But which coordinate system are they in ? Read these three articles to find out: