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
|
||||
|
||||
|
||||
# This next line is called from the templates/edit_cave.html template.
|
||||
# This is sufficient to create an entire entry for for the cave fields automatically
|
||||
# http://localhost:8000/cave/new/
|
||||
# using django built-in Deep Magic. https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
|
||||
# for forms which map directly onto a Django Model
|
||||
CaveAndEntranceFormSet = modelformset_factory(CaveAndEntrance, exclude=("cave",))
|
||||
# This is used only in edit_entrance() in views/caves.py
|
||||
# # This next line 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/
|
||||
# # for forms which map directly onto a Django Model
|
||||
# CaveAndEntranceFormSet = modelformset_factory(CaveAndEntrance, exclude=("cave",))
|
||||
# # This is used only in templates/editcave.html which is called only to edit caves in core/views/cave.py
|
||||
|
||||
class EntranceLetterForm(ModelForm):
|
||||
"""Form to link entrances to caves, along with an entrance number.
|
||||
|
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import re
|
||||
import django
|
||||
import subprocess
|
||||
import tempfile
|
||||
import zipfile
|
||||
@ -14,7 +15,7 @@ from django.shortcuts import render, redirect
|
||||
from django.urls import NoReverseMatch, reverse
|
||||
|
||||
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.logbooks import QM
|
||||
from troggle.core.models.wallets import Wallet
|
||||
@ -472,8 +473,7 @@ def edit_cave(request, path="", slug=None):
|
||||
|
||||
if request.POST:
|
||||
form = CaveForm(request.POST, instance=cave)
|
||||
#ceFormSet = CaveAndEntranceFormSet(request.POST)
|
||||
if form.is_valid(): # and ceFormSet.is_valid():
|
||||
if form.is_valid():
|
||||
print(f'edit_cave(): POST is valid. Editing {cave}')
|
||||
cave = form.save(commit=False)
|
||||
# print(cave)
|
||||
@ -489,10 +489,6 @@ def edit_cave(request, path="", slug=None):
|
||||
cs = CaveSlug(cave=cave, slug=slug, primary=True)
|
||||
print(f"edit_cave(): New CaveSlug saved {slug}")
|
||||
cs.save()
|
||||
#ceinsts = ceFormSet.save(commit=False)
|
||||
#for ceinst in ceinsts:
|
||||
# ceinst.cave = cave
|
||||
# ceinst.save()
|
||||
try:
|
||||
cave_file = cave.file_output()
|
||||
write_and_commit([cave_file], f"Online edit of cave {cave}")
|
||||
@ -523,20 +519,24 @@ def edit_cave(request, path="", slug=None):
|
||||
raise
|
||||
|
||||
form = CaveForm(instance=cave, initial={'cave_slug': cave.slug()})
|
||||
#ceFormSet = CaveAndEntranceFormSet(queryset=cave.caveandentrance_set.all())
|
||||
else:
|
||||
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(
|
||||
request,
|
||||
"editcave.html",
|
||||
{
|
||||
"form": form,
|
||||
"cave": cave,
|
||||
"message": message, "year": current_expo(),
|
||||
#"caveAndEntranceFormSet": ceFormSet,
|
||||
"message": message, "year": current_expo(), "tabletype": tabletype,
|
||||
"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>
|
||||
|
||||
<form action="" method="post">{% csrf_token %}
|
||||
<table>{{ form }}
|
||||
<!-- begin caveAndEntranceFormSet-->{{caveAndEntranceFormSet}}<!--end caveAndEntranceFormSet--></table>
|
||||
{% if tabletype == 'table' %}<table>{% else %}<div>{% endif %}
|
||||
{{ 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>
|
||||
</form>
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.HTMLarea { width:1000px;}
|
||||
.HTMLarea { width:100%;}
|
||||
|
||||
.popup-overlay.active {
|
||||
/*displays pop-up when "active" class is present*/
|
||||
@ -70,7 +70,7 @@
|
||||
<style type=text/css>
|
||||
.CodeMirror {
|
||||
float: left;
|
||||
width: 50%;
|
||||
width: 85%;
|
||||
border: 1px solid black;
|
||||
height: 70%;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user