mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-14 16:47:24 +00:00
Editing for entrances along with caves
More detailed display of entrances
This commit is contained in:
@@ -9,34 +9,32 @@ from datetime import date
|
||||
from tinymce.widgets import TinyMCE
|
||||
|
||||
class CaveForm(ModelForm):
|
||||
underground_description = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
|
||||
explorers = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
equipment = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
survey = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
kataster_status = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
underground_centre_line = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
notes = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
references = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
underground_description = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
|
||||
explorers = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
equipment = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
survey = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
kataster_status = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
underground_centre_line = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
notes = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
references = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
class Meta:
|
||||
model = Cave
|
||||
|
||||
class CaveAndEntranceForm(forms.Form):
|
||||
entrance = forms.ChoiceField(choices=[("", "-----")] +
|
||||
[(x.slug, x.slug)
|
||||
for x
|
||||
in Entrance.objects.all()])
|
||||
entrance_letter = forms.CharField(max_length=20)
|
||||
non_public = forms.BooleanField()
|
||||
|
||||
CaveAndEntranceFormSet = formset_factory(CaveAndEntranceForm)
|
||||
|
||||
|
||||
class EntranceForm(ModelForm):
|
||||
class Meta:
|
||||
model = Entrance
|
||||
|
||||
class CaveForm(ModelForm):
|
||||
underground_description = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
|
||||
explorers = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
equipment = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
survey = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
kataster_status = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
underground_centre_line = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
notes = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
references = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
|
||||
class Meta:
|
||||
model = Cave
|
||||
|
||||
#class PersonForm(ModelForm):
|
||||
# class Meta:
|
||||
# model = Person
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from troggle.core.models import Cave, CaveAndEntrance, Survey, Expedition, QM, CaveDescription, Entrance
|
||||
from troggle.core.forms import CaveForm
|
||||
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet
|
||||
import troggle.core.models as models
|
||||
import troggle.settings as settings
|
||||
from troggle.helper import login_required_if_public
|
||||
@@ -42,6 +42,7 @@ def caveEntrance(request, slug):
|
||||
return render_with_context(request,'nonpublic.html', {'instance': cave})
|
||||
else:
|
||||
return render_with_context(request,'cave_entrances.html', {'cave': cave})
|
||||
|
||||
def caveDescription(request, slug):
|
||||
cave = Cave.objects.get(slug = slug)
|
||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
||||
@@ -71,14 +72,17 @@ def caveSlug(request, slug):
|
||||
@login_required_if_public
|
||||
def edit_cave(request, slug=None):
|
||||
cave = Cave.objects.get(slug = slug)
|
||||
form = CaveForm(instance=cave)
|
||||
class CaveAndEntranceForm(forms.Form):
|
||||
entrance = forms.ChoiceField(choices=[("", "-----")] + [(x.slug, x.slug) for x in Entrance.objects.all()])
|
||||
entrance_letter = forms.CharField(max_length=20)
|
||||
non_public = forms.BooleanField()
|
||||
CaveAndEntranceFormSet = formset_factory(CaveAndEntranceForm)
|
||||
i = [{"entrance": x.entrance.slug, "entrance_letter": x.entrance_letter, "non_public": x.non_public} for x in cave.caveandentrance_set.all()]
|
||||
ceFormSet = CaveAndEntranceFormSet(initial=i)
|
||||
if request.POST:
|
||||
form = CaveForm(request.POST, instance=cave)
|
||||
ceFormSet = CaveAndEntranceFormSet(request.POST)
|
||||
else:
|
||||
form = CaveForm(instance=cave)
|
||||
i = [{"entrance": x.entrance.slug,
|
||||
"entrance_letter": x.entrance_letter,
|
||||
"non_public": x.non_public}
|
||||
for x
|
||||
in cave.caveandentrance_set.all()]
|
||||
ceFormSet = CaveAndEntranceFormSet(initial=i)
|
||||
return render_with_context(request,
|
||||
'editcave2.html',
|
||||
{'form': form,
|
||||
|
||||
Reference in New Issue
Block a user