diff --git a/core/forms.py b/core/forms.py
index 939f64f..e0654fb 100644
--- a/core/forms.py
+++ b/core/forms.py
@@ -8,14 +8,14 @@ from datetime import date
from tinymce.widgets import TinyMCE
class CaveForm(ModelForm):
- 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}))
+ underground_description = forms.CharField(required = False, widget=forms.Textarea())
+ explorers = forms.CharField(required = False, widget=forms.Textarea())
+ equipment = forms.CharField(required = False, widget=forms.Textarea())
+ survey = forms.CharField(required = False, widget=forms.Textarea())
+ kataster_status = forms.CharField(required = False, widget=forms.Textarea())
+ underground_centre_line = forms.CharField(required = False, widget=forms.Textarea())
+ notes = forms.CharField(required = False, widget=forms.Textarea())
+ references = forms.CharField(required = False, widget=forms.Textarea())
class Meta:
model = Cave
diff --git a/flatpages/views.py b/flatpages/views.py
index 0999d31..6fb68bb 100644
--- a/flatpages/views.py
+++ b/flatpages/views.py
@@ -57,9 +57,9 @@ def flatpage(request, path):
if path.endswith(".htm") or path.endswith(".html"):
html = o.read()
- m = re.search(r"
(.*).*]*>(.*)", html, re.DOTALL + re.IGNORECASE)
+ m = re.search(r"(.*)<\s*head([^>]*)>(.*)<\s*/head\s*>(.*)<\s*body([^>]*)>(.*)<\s*/body\s*>(.*)", html, re.DOTALL + re.IGNORECASE)
if m:
- head, body = m.groups()
+ preheader, headerattrs, head, postheader, bodyattrs, body, postbody = m.groups()
else:
return HttpResponse(html + "Page could not be split into header and body")
m = re.search(r"(.*)", head, re.DOTALL + re.IGNORECASE)
@@ -107,13 +107,13 @@ def editflatpage(request, path):
filepath = os.path.normpath(settings.EXPOWEB + path)
o = open(filepath, "r")
html = o.read()
- m = re.search(r"(.*).*]*>(.*)", html, re.DOTALL + re.IGNORECASE)
+ m = re.search(r"(.*)]*)>(.*)(.*)]*)>(.*)(.*)", html, re.DOTALL + re.IGNORECASE)
if m:
filefound = True
- head, body = m.groups()
- linksmatch = re.match('(.*)', body, re.DOTALL + re.IGNORECASE)
+ preheader, headerargs, head, postheader, bodyargs, body, postbody = m.groups()
+ linksmatch = re.match('(.*)(.*)', body, re.DOTALL + re.IGNORECASE)
if linksmatch:
- body, = linksmatch.groups()
+ body, links = linksmatch.groups()
if re.search(r"iso-8859-1", html):
body = unicode(body, "iso-8859-1")
else:
@@ -126,9 +126,22 @@ def editflatpage(request, path):
flatpageForm = FlatPageForm(request.POST) # A form bound to the POST data
if flatpageForm.is_valid():# Form valid therefore write file
f = open(filepath, "w")
- template = loader.get_template('dataformat/flatfile.html')
- context = Context({'form': flatpageForm.cleaned_data})
- f.write(template.render(context))
+ if filefound:
+ headmatch = re.match(r"(.*).*(.*)", head, re.DOTALL + re.IGNORECASE)
+ if headmatch:
+ head = headmatch.group(1) + "" + flatpageForm.cleaned_data["title"] + "" + headmatch.group(2)
+ else:
+ head = "" + flatpageForm.cleaned_data["title"] + ""
+ else:
+ head = "" + flatpageForm.cleaned_data["title"] + ""
+ preheader = ""
+ headerargs = ""
+ postheader = ""
+ bodyargs = ""
+ postbody = ""
+ body = flatpageForm.cleaned_data["html"]
+ body = body.replace("\r", "")
+ f.write("%s%s%s\n%s%s" % (preheader, headerargs, head, postheader, bodyargs, body, postbody))
f.close()
return HttpResponseRedirect(reverse('flatpage', args=[path])) # Redirect after POST
else:
@@ -146,4 +159,4 @@ def editflatpage(request, path):
class FlatPageForm(forms.Form):
title = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
- html = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 20}))
+ html = forms.CharField(widget=forms.Textarea())
diff --git a/templates/cave_entrances.html b/templates/cave_entrances.html
index e4e939d..1364acf 100644
--- a/templates/cave_entrances.html
+++ b/templates/cave_entrances.html
@@ -51,11 +51,16 @@
{% if ent.entrance.bearings %}
- Bearings
- {{ ent.entrance.bearings|safe }}
{% endif %}
-
- {{ ent.entrance.tag_station|safe }}
- {{ ent.entrance.exact_station|safe }}
- {{ ent.entrance.other_station|safe }}
- {{ ent.entrance.other_description|safe }}
+ {% if ent.entrance.exact_station %}
+ - Exact Station
- {{ ent.entrance.exact_station|safe }}
+ {% endif %}
+ {% if ent.entrance.other_station %}
+ - Other Station
- {{ ent.entrance.other_station|safe }}
+ {% if ent.entrance.other_description %}
+ - {{ ent.entrance.other_description|safe }}
+ {% endif %}
+
+ {% endif %}
{% endfor %}
diff --git a/templates/dataformat/flatfile.html b/templates/dataformat/flatfile.html
deleted file mode 100644
index 07d03ca..0000000
--- a/templates/dataformat/flatfile.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{% autoescape off %}
-
-
-{{ form.title }}
-
-
-{{ form.html }}
-
-
-{% endautoescape %}
diff --git a/templates/editcave.html b/templates/editcave.html
index 0e1785b..d7bdf37 100644
--- a/templates/editcave.html
+++ b/templates/editcave.html
@@ -13,7 +13,7 @@
{% endblock %}
diff --git a/templates/editcave2.html b/templates/editcave2.html
index e57b4cd..edac202 100644
--- a/templates/editcave2.html
+++ b/templates/editcave2.html
@@ -12,7 +12,7 @@
{% endblock %}
diff --git a/templates/editentrance.html b/templates/editentrance.html
index d17d1f9..3b0e12b 100644
--- a/templates/editentrance.html
+++ b/templates/editentrance.html
@@ -12,7 +12,7 @@
{% endblock %}
diff --git a/templates/editfile.html b/templates/editfile.html
index 954a1c4..b9ae115 100644
--- a/templates/editfile.html
+++ b/templates/editfile.html
@@ -90,7 +90,7 @@
{{ fileForm.html }}
-
+
{% endblock %}