forked from expo/troggle
Render a cave editing page. Nb it does not do save anything yet.
This commit is contained in:
parent
8222ed3b6a
commit
599c59454a
@ -1,15 +1,41 @@
|
|||||||
from django.forms import ModelForm
|
from django.forms import ModelForm
|
||||||
from models import Cave, Person, PersonExpedition, LogbookEntry, QM, Expedition
|
from models import Cave, Person, PersonExpedition, LogbookEntry, QM, Expedition, Entrance, CaveAndEntrance
|
||||||
import django.forms as forms
|
import django.forms as forms
|
||||||
from django.forms.formsets import formset_factory
|
from django.forms.formsets import formset_factory
|
||||||
|
from django.forms.models import formset_factory
|
||||||
from django.contrib.admin.widgets import AdminDateWidget
|
from django.contrib.admin.widgets import AdminDateWidget
|
||||||
import string
|
import string
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from tinymce.widgets import TinyMCE
|
from tinymce.widgets import TinyMCE
|
||||||
|
|
||||||
#class CaveForm(ModelForm):
|
class CaveForm(ModelForm):
|
||||||
# class Meta:
|
underground_description = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
|
||||||
# model = Cave
|
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 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 PersonForm(ModelForm):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
@ -48,8 +74,8 @@ from tinymce.widgets import TinyMCE
|
|||||||
# super(LogbookEntryForm, self).__init__(*args, **kwargs)
|
# super(LogbookEntryForm, self).__init__(*args, **kwargs)
|
||||||
# self.fields['text'].help_text=self.wikiLinkHints()#
|
# self.fields['text'].help_text=self.wikiLinkHints()#
|
||||||
|
|
||||||
class CaveForm(forms.Form):
|
#class CaveForm(forms.Form):
|
||||||
html = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
|
# html = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
|
||||||
|
|
||||||
def getTripForm(expedition):
|
def getTripForm(expedition):
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
from troggle.core.models import Cave, CaveAndEntrance, Survey, Expedition, QM, CaveDescription
|
from troggle.core.models import Cave, CaveAndEntrance, Survey, Expedition, QM, CaveDescription, Entrance
|
||||||
from troggle.core.forms import CaveForm
|
from troggle.core.forms import CaveForm
|
||||||
import troggle.core.models as models
|
import troggle.core.models as models
|
||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
from troggle.helper import login_required_if_public
|
from troggle.helper import login_required_if_public
|
||||||
|
|
||||||
from django.forms.models import formset_factory
|
from django.forms.models import formset_factory
|
||||||
|
from django import forms
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from utils import render_with_context # see views_logbooks for explanation on this.
|
from utils import render_with_context # see views_logbooks for explanation on this.
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
@ -63,16 +64,26 @@ def caveLogbook(request, slug):
|
|||||||
def caveSlug(request, slug):
|
def caveSlug(request, slug):
|
||||||
cave = Cave.objects.get(slug = slug)
|
cave = Cave.objects.get(slug = slug)
|
||||||
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
|
||||||
return render_with_context(request,'nonpublic.html', {'instance': cave})
|
return render_with_context(request,'nonpublic.html', {'instance': cave, 'cave_editable': slug})
|
||||||
else:
|
else:
|
||||||
return render_with_context(request,'cave.html', {'cave': cave})
|
return render_with_context(request,'cave.html', {'cave': cave, 'cave_editable': slug})
|
||||||
|
|
||||||
@login_required_if_public
|
@login_required_if_public
|
||||||
def editCave(request, slug=None):
|
def edit_cave(request, slug=None):
|
||||||
form = CaveForm()
|
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)
|
||||||
return render_with_context(request,
|
return render_with_context(request,
|
||||||
'editcave.html',
|
'editcave2.html',
|
||||||
{'form': form})
|
{'form': form,
|
||||||
|
'caveAndEntranceFormSet': ceFormSet
|
||||||
|
})
|
||||||
|
|
||||||
def qm(request,cave_id,qm_id,year,grade=None):
|
def qm(request,cave_id,qm_id,year,grade=None):
|
||||||
year=int(year)
|
year=int(year)
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
$( "#tabs" ).tabs();
|
$( "#tabs" ).tabs();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
{% block extraheaders %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
|
18
templates/editcave2.html
Normal file
18
templates/editcave2.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{% extends "cavebase.html" %}
|
||||||
|
{% load csrffaker %}
|
||||||
|
{% block title %}Edit Cave{% endblock %}
|
||||||
|
{% block extraheaders %}
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="{{ settings.MEDIA_URL }}css/ui-lightness/jquery-ui-1.8.12.custom.css" type="text/css" media="all" />
|
||||||
|
<script src="{{ settings.MEDIA_URL }}js/jquery-ui-1.8.12.custom.min.js" type="text/javascript"></script>
|
||||||
|
<script src="{{ settings.MEDIA_URL }}js/jquery.formset.min.js" type="text/javascript"></script>
|
||||||
|
<script src="{{ settings.TINY_MCE_MEDIA_URL }}tiny_mce.js" type="text/javascript"></script>
|
||||||
|
{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<strong> This form does not do anything .... yet ....</strong>
|
||||||
|
<form action="" method="post">{% csrf_token %}
|
||||||
|
<table>{{ form }}{{caveAndEntranceFormSet}}</table>
|
||||||
|
<p><input type="submit" value="Sumbit" /></p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -8,5 +8,6 @@
|
|||||||
<li><a href="/handbook/index.htm">Handbook</a></li>
|
<li><a href="/handbook/index.htm">Handbook</a></li>
|
||||||
<li><a href="/pubs.htm">Reports</a></li>
|
<li><a href="/pubs.htm">Reports</a></li>
|
||||||
{% if editable %}<li><a href="{% url editflatpage path %}" class="editlink"><strong>Edit this page</strong></a></li>{% endif %}
|
{% if editable %}<li><a href="{% url editflatpage path %}" class="editlink"><strong>Edit this page</strong></a></li>{% endif %}
|
||||||
|
{% if cave_editable %}<li><a href="{% url edit_cave cave_editable %}" class="editlink"><strong>Edit this cave</strong></a></li>{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
4
urls.py
4
urls.py
@ -57,7 +57,7 @@ actualurlpatterns = patterns('',
|
|||||||
url(r'^jgtuploadfile$', view_surveys.jgtuploadfile, name="jgtuploadfile"),
|
url(r'^jgtuploadfile$', view_surveys.jgtuploadfile, name="jgtuploadfile"),
|
||||||
|
|
||||||
url(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent),
|
url(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent),
|
||||||
#(r'^cave/(?P<cave_id>[^/]+)/edit/$', edit_cave),
|
url(r'^cave/(?P<slug>[^/]+)/edit/$', edit_cave, name="edit_cave"),
|
||||||
#(r'^cavesearch', caveSearch),
|
#(r'^cavesearch', caveSearch),
|
||||||
|
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ actualurlpatterns = patterns('',
|
|||||||
url(r'^eyecandy$', views_other.eyecandy),
|
url(r'^eyecandy$', views_other.eyecandy),
|
||||||
|
|
||||||
(r'^admin/doc/?', include('django.contrib.admindocs.urls')),
|
(r'^admin/doc/?', include('django.contrib.admindocs.urls')),
|
||||||
url(r'^admin/(.*)', admin.site.root, name="admin"),
|
url(r'^admin/(.*)', admin.site.get_urls, name="admin"),
|
||||||
|
|
||||||
# don't know why this needs troggle/ in here. nice to get it out
|
# don't know why this needs troggle/ in here. nice to get it out
|
||||||
url(r'^troggle/media-admin/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ADMIN_DIR, 'show_indexes':True}),
|
url(r'^troggle/media-admin/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ADMIN_DIR, 'show_indexes':True}),
|
||||||
|
Loading…
Reference in New Issue
Block a user