mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-21 23:01:52 +00:00
fix edit entrance bug
This commit is contained in:
parent
2452fe5752
commit
7e1c8797b8
@ -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
|
||||
|
@ -70,8 +70,35 @@ Such converted eastings and northings are <em>in italics</em> in the table below
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<p>and what those stations are:
|
||||
<table>
|
||||
<tr><th>Cave</th><th>tag</th><th>tag x</th><th>tag y</th><th>tag exact</th><th>exact x</th><th>exact y</th><th>tag other</th><th>other x</th><th>other y</th></tr>
|
||||
{% for ent in ents %}
|
||||
<tr>
|
||||
<td style="text-align:left">
|
||||
{% for c in ent.cavelist %}
|
||||
<a href="/{{c.url}}">
|
||||
{% if c.official_name %}
|
||||
{{c.official_name|safe}}
|
||||
{% else %}
|
||||
<em>{{c|safe}}</em>
|
||||
{% endif %}</a><br>
|
||||
{% endfor %}</td>
|
||||
|
||||
<td style="text-align:right">{{ent.tag_station}}</td>
|
||||
<td style="text-align:right">{{ent.tag_ts.x|floatformat:0}}</td>
|
||||
<td style="text-align:right">{{ent.tag_ts.y|floatformat:0}}</td>
|
||||
<td style="text-align:right">{{ent.exact_station}}</td>
|
||||
<td style="text-align:right">{{ent.tag_es.x|floatformat:0}}</td>
|
||||
<td style="text-align:right">{{ent.tag_es.y|floatformat:0}}</td>
|
||||
<td style="text-align:right">{{ent.other_station}}</td>
|
||||
<td style="text-align:right">{{ent.tag_os.x|floatformat:0}}</td>
|
||||
<td style="text-align:right">{{ent.tag_os.y|floatformat:0}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<p>and now the GPS equivalents:
|
||||
<h3>and now the GPS equivalents</h3>
|
||||
<table>
|
||||
<tr><th>Cave</th><th>GPS Lat</th><th>GPS Long</th><th>best Lat</th><th>best Long</th><th>tag</th><th>tag Lat</th><th>tag Long</th><th>tag exact</th><th>exact Lat</th><th>exact Long</th><th>tag other</th><th>other Lat</th><th>other Long</th></tr>
|
||||
{% for ent in gpsents %}
|
||||
@ -103,6 +130,8 @@ Such converted eastings and northings are <em>in italics</em> in the table below
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<h3>All entrances in Trogggle</h3>
|
||||
<p> See also <a href="/entrances">Entrances list</a>.
|
||||
<p>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'.
|
||||
<p>But which coordinate system are they in ? Read these three articles to find out:
|
||||
|
Loading…
Reference in New Issue
Block a user