mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-12-18 14:32:19 +00:00
Make edit fields wider
This commit is contained in:
parent
7730b2535f
commit
cfc7a4b9f6
@ -226,13 +226,11 @@ class EntranceForm(ModelForm):
|
|||||||
return self.cleaned_data
|
return self.cleaned_data
|
||||||
|
|
||||||
|
|
||||||
# This next line is called from the templates/edit_cave.html template.
|
# # This next line is sufficient to create an entire entry for for the cave fields automatically
|
||||||
# This is sufficient to create an entire entry for for the cave fields automatically
|
# # using django built-in Deep Magic. https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
|
||||||
# http://localhost:8000/cave/new/
|
# # for forms which map directly onto a Django Model
|
||||||
# using django built-in Deep Magic. https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
|
# CaveAndEntranceFormSet = modelformset_factory(CaveAndEntrance, exclude=("cave",))
|
||||||
# for forms which map directly onto a Django Model
|
# # This is used only in templates/editcave.html which is called only to edit caves in core/views/cave.py
|
||||||
CaveAndEntranceFormSet = modelformset_factory(CaveAndEntrance, exclude=("cave",))
|
|
||||||
# This is used only in edit_entrance() in views/caves.py
|
|
||||||
|
|
||||||
class EntranceLetterForm(ModelForm):
|
class EntranceLetterForm(ModelForm):
|
||||||
"""Form to link entrances to caves, along with an entrance number.
|
"""Form to link entrances to caves, along with an entrance number.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import django
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import zipfile
|
import zipfile
|
||||||
@ -14,7 +15,7 @@ from django.shortcuts import render, redirect
|
|||||||
from django.urls import NoReverseMatch, reverse
|
from django.urls import NoReverseMatch, reverse
|
||||||
|
|
||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
from troggle.core.forms import CaveAndEntranceFormSet, CaveForm, EntranceForm, EntranceLetterForm
|
from troggle.core.forms import CaveForm, EntranceForm, EntranceLetterForm # CaveAndEntranceFormSet,
|
||||||
from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance, GetCaveLookup, get_cave_leniently
|
from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance, GetCaveLookup, get_cave_leniently
|
||||||
from troggle.core.models.logbooks import QM
|
from troggle.core.models.logbooks import QM
|
||||||
from troggle.core.models.wallets import Wallet
|
from troggle.core.models.wallets import Wallet
|
||||||
@ -472,8 +473,7 @@ def edit_cave(request, path="", slug=None):
|
|||||||
|
|
||||||
if request.POST:
|
if request.POST:
|
||||||
form = CaveForm(request.POST, instance=cave)
|
form = CaveForm(request.POST, instance=cave)
|
||||||
#ceFormSet = CaveAndEntranceFormSet(request.POST)
|
if form.is_valid():
|
||||||
if form.is_valid(): # and ceFormSet.is_valid():
|
|
||||||
print(f'edit_cave(): POST is valid. Editing {cave}')
|
print(f'edit_cave(): POST is valid. Editing {cave}')
|
||||||
cave = form.save(commit=False)
|
cave = form.save(commit=False)
|
||||||
# print(cave)
|
# print(cave)
|
||||||
@ -489,10 +489,6 @@ def edit_cave(request, path="", slug=None):
|
|||||||
cs = CaveSlug(cave=cave, slug=slug, primary=True)
|
cs = CaveSlug(cave=cave, slug=slug, primary=True)
|
||||||
print(f"edit_cave(): New CaveSlug saved {slug}")
|
print(f"edit_cave(): New CaveSlug saved {slug}")
|
||||||
cs.save()
|
cs.save()
|
||||||
#ceinsts = ceFormSet.save(commit=False)
|
|
||||||
#for ceinst in ceinsts:
|
|
||||||
# ceinst.cave = cave
|
|
||||||
# ceinst.save()
|
|
||||||
try:
|
try:
|
||||||
cave_file = cave.file_output()
|
cave_file = cave.file_output()
|
||||||
write_and_commit([cave_file], f"Online edit of cave {cave}")
|
write_and_commit([cave_file], f"Online edit of cave {cave}")
|
||||||
@ -523,20 +519,24 @@ def edit_cave(request, path="", slug=None):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
form = CaveForm(instance=cave, initial={'cave_slug': cave.slug()})
|
form = CaveForm(instance=cave, initial={'cave_slug': cave.slug()})
|
||||||
#ceFormSet = CaveAndEntranceFormSet(queryset=cave.caveandentrance_set.all())
|
|
||||||
else:
|
else:
|
||||||
form = CaveForm()
|
form = CaveForm()
|
||||||
#ceFormSet = CaveAndEntranceFormSet(queryset=CaveAndEntrance.objects.none())
|
# The way formsets are rendered chnaged between Django 4 and Django 5
|
||||||
|
major, _, _, _, _ = django.VERSION
|
||||||
|
if major < 5:
|
||||||
|
tabletype = "table"
|
||||||
|
else:
|
||||||
|
tabletype = "div"
|
||||||
|
print(f"edit_cave(): returning render() with tabletype={tabletype} {django.VERSION} ")
|
||||||
|
|
||||||
|
|
||||||
print(f"edit_cave(): returning render()")
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"editcave.html",
|
"editcave.html",
|
||||||
{
|
{
|
||||||
"form": form,
|
"form": form,
|
||||||
"cave": cave,
|
"cave": cave,
|
||||||
"message": message, "year": current_expo(),
|
"message": message, "year": current_expo(), "tabletype": tabletype,
|
||||||
#"caveAndEntranceFormSet": ceFormSet,
|
|
||||||
"path": path + "/", # used for saving images if attached
|
"path": path + "/", # used for saving images if attached
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -59,8 +59,9 @@ at troggle/core/forms.py ass this uses a Django magic form creation thinggy. -->
|
|||||||
<h2>{{message}}</h2>
|
<h2>{{message}}</h2>
|
||||||
|
|
||||||
<form action="" method="post">{% csrf_token %}
|
<form action="" method="post">{% csrf_token %}
|
||||||
<table>{{ form }}
|
{% if tabletype == 'table' %}<table>{% else %}<div>{% endif %}
|
||||||
<!-- begin caveAndEntranceFormSet-->{{caveAndEntranceFormSet}}<!--end caveAndEntranceFormSet--></table>
|
{{ form }}
|
||||||
|
{% if tabletype == 'table' %}</table>{% else %}</div>{% endif %}
|
||||||
<p><input style="font-weight: bold; font-size: 200%; font-variant-caps: small-caps; margin-left: 40%;" type="submit" value="Submit" /></p>
|
<p><input style="font-weight: bold; font-size: 200%; font-variant-caps: small-caps; margin-left: 40%;" type="submit" value="Submit" /></p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
z-index: 20;
|
z-index: 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
.HTMLarea { width:1000px;}
|
.HTMLarea { width:100%;}
|
||||||
|
|
||||||
.popup-overlay.active {
|
.popup-overlay.active {
|
||||||
/*displays pop-up when "active" class is present*/
|
/*displays pop-up when "active" class is present*/
|
||||||
@ -70,7 +70,7 @@
|
|||||||
<style type=text/css>
|
<style type=text/css>
|
||||||
.CodeMirror {
|
.CodeMirror {
|
||||||
float: left;
|
float: left;
|
||||||
width: 50%;
|
width: 85%;
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
height: 70%;
|
height: 70%;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user