branch merge

This commit is contained in:
expo 2011-09-02 03:39:20 +02:00
commit 378ddfe96d
12 changed files with 103 additions and 55 deletions

View File

@ -30,39 +30,39 @@ def caveindex(request):
def cave(request, cave_id='', offical_name=''):
cave=getCave(cave_id)
if cave.non_public 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, 'cavepage': True})
else:
return render_with_context(request,'cave.html', {'cave': cave, 'cavepage': True})
def caveEntrance(request, slug):
cave = Cave.objects.get(slug = slug)
if cave.non_public 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})
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 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})
else:
return render_with_context(request,'cave_uground_description.html', {'cave': cave})
def caveQMs(request, slug):
cave = Cave.objects.get(slug = slug)
if cave.non_public 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})
else:
return render_with_context(request,'cave_qms.html', {'cave': cave})
def caveLogbook(request, slug):
cave = Cave.objects.get(slug = slug)
if cave.non_public 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})
else:
return render_with_context(request,'cave_logbook.html', {'cave': cave})
def caveSlug(request, slug):
cave = Cave.objects.get(slug = slug)
if cave.non_public 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})
else:
return render_with_context(request,'cave.html', {'cave': cave})

View File

@ -5,7 +5,7 @@ import troggle.settings as settings
import django.db.models
from troggle.parsers.logbooks import LoadLogbookForExpedition
from troggle.parsers.people import GetPersonExpeditionNameLookup
#from troggle.core.forms import PersonForm, getTripForm, get_name
from troggle.core.forms import getTripForm#, get_name, PersonForm
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponse
from django.template import Context, loader

View File

@ -15,7 +15,6 @@ import os
import re
def flatpage(request, path):
print "gggggg", path
try:
r = Redirect.objects.get(originalURL = path)
return HttpResponseRedirect(r.newURL) # Redirect after POST
@ -36,6 +35,7 @@ def flatpage(request, path):
if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated():
print "flat path noinfo", path
return HttpResponseRedirect(reverse("auth_login") + '?next=%s' % request.path)
if path.endswith("/") or path == "":
@ -45,29 +45,34 @@ def flatpage(request, path):
except IOError:
try:
o = open(os.path.normpath(settings.EXPOWEB + path + "index.htm"), "rb")
path = path + "index.html"
path = path + "index.htm"
except IOError:
raise Http404
return render_with_context(request, 'pagenotfound.html', {'path': path})
else:
try:
o = open(os.path.normpath(settings.EXPOWEB + path), "rb")
except IOError:
raise Http404
return render_with_context(request, 'pagenotfound.html', {'path': path})
if path.endswith(".htm") or path.endswith(".html"):
html = o.read()
m = re.search(r"<head>(.*)</head>.*<body>(.*)</body>", html, re.DOTALL)
mwithid = re.search(r'<head>(.*)</head>.*<body id="([^"]*)">(.*)</body>', html, re.DOTALL)
m = re.search(r"<head>(.*)</head>.*<body[^>]*>(.*)</body>", html, re.DOTALL + re.IGNORECASE)
if m:
head, body = m.groups()
bodyid = None
elif mwithid:
head, bodyid, body = mwithid.groups()
else:
return HttpResponse(html + "Page could not be split into header and body")
m = re.search(r"<title>(.*)</title>", head, re.DOTALL + re.IGNORECASE)
if m:
title, = m.groups()
else:
title = ""
linksmatch = re.match('(.*)<ul id="links">', body, re.DOTALL + re.IGNORECASE)
if linksmatch:
body, = linksmatch.groups()
if re.search(r"iso-8859-1", html):
body = unicode(body, "iso-8859-1")
return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'head': head, 'body': body, "bodyid": bodyid})
body.strip
return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'title': title, 'body': body, 'homepage': (path == "index.htm")})
else:
return HttpResponse(o.read(), mimetype=getmimetype(path))
@ -100,28 +105,44 @@ def editflatpage(request, path):
try:
filepath = os.path.normpath(settings.EXPOWEB + path)
o = open(filepath, "r")
html = o.read()
m = re.search(r"<head>(.*)</head>.*<body[^>]*>(.*)</body>", html, re.DOTALL + re.IGNORECASE)
if m:
filefound = True
head, body = m.groups()
linksmatch = re.match('(.*)<ul\s+id="links">', body, re.DOTALL + re.IGNORECASE)
if linksmatch:
body, = linksmatch.groups()
if re.search(r"iso-8859-1", html):
body = unicode(body, "iso-8859-1")
else:
return HttpResponse("Page could not be split into header and body")
except IOError:
raise Http404
html = o.read()
m = re.search(r"<head>(.*)</head>.*<body>(.*)</body>", html, re.DOTALL)
if m:
head, body = m.groups()
if re.search(r"iso-8859-1", html):
body = unicode(body, "iso-8859-1")
else:
return HttpResponse("Page could not be split into header and body")
filefound = False
if request.method == 'POST': # If the form has been submitted...
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, 'head': head})
context = Context({'form': flatpageForm.cleaned_data})
f.write(template.render(context))
f.close()
return HttpResponseRedirect(reverse('flatpage', args=[path])) # Redirect after POST
else:
flatpageForm = FlatPageForm({"html": body})
if filefound:
m = re.search(r"<title>(.*)</title>", head, re.DOTALL + re.IGNORECASE)
if m:
title, = m.groups()
else:
title = ""
flatpageForm = FlatPageForm({"html": body, "title": title})
else:
flatpageForm = FlatPageForm()
return render_with_context(request, 'editflatpage.html', {'path': path, 'form': flatpageForm, })
class FlatPageForm(forms.Form):
html = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
title = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
html = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 20}))

View File

@ -1,9 +1,10 @@
import sys
# link localsettings to this file for use on expo computer in austria
DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'troggle' # Or path to database file if using sqlite3.
DATABASE_USER = 'troggler3' # Not used with sqlite3.
DATABASE_PASSWORD = 'ggg' # Not used with sqlite3.
DATABASE_USER = 'expo' # Not used with sqlite3.
DATABASE_PASSWORD = 'gosser' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
@ -48,4 +49,4 @@ TEMPLATE_DIRS = (
# Don't forget to use absolute paths, not relative paths.
)
LOGFILE = '/home/expo/expofiles/expoweb/parsing_log.txt'
LOGFILE = '/home/expo/expofiles/troggle/parsing_log.txt'

View File

@ -16,11 +16,6 @@
</head>
<body>
{% block content %}{% endblock %}
{% block menu %}
<ul id="links">
<li>Back to <a href="/index.htm">Expedition home page</a></li>
<li>Back to <a href="http://cucc.survex.com/">CUCC home page</a></li>
</ul>
{% endblock %}
{% include "menu.html" %}
</body>
</html>

View File

@ -10,7 +10,7 @@
<h3>Notable caves</h3>
<ul>
{% for cave in notablecaves %}
<li> <a href="{{ cave.get_absolute_url }}">{% if cave.kataster_number %}{{ cave.kataster_number }}{% else %}{{cave.unofficial_number }}{%endif %} {{cave.official_name|safe}}</a> </li>
<li> <a href="{{ cave.url }}">{% if cave.kataster_number %}{{ cave.kataster_number }}{% else %}{{cave.unofficial_number }}{%endif %} {{cave.official_name|safe}}</a> </li>
{% endfor %}
</ul>
@ -19,7 +19,7 @@
<ul class="searchable">
{% for cave in caves1623 %}
<li> <a href="{{ cave.get_absolute_url }}">{% if cave.kataster_number %}{{ cave.kataster_number }}{% else %}{{cave.unofficial_number }}{%endif %} {{cave.official_name|safe}}</a> </li>
<li> <a href="{{ cave.url }}">{% if cave.kataster_number %}{{ cave.kataster_number }}{% else %}{{cave.unofficial_number }}{%endif %} {{cave.official_name|safe}}</a> </li>
{% endfor %}
</ul>
@ -29,7 +29,7 @@
<ul class="searchable">
{% for cave in caves1626 %}
<li> <a href="{{ cave.get_absolute_url }}">{% if cave.kataster_number %}{{ cave.kataster_number }}{% else %}{{cave.unofficial_number }}{%endif %} {{cave.official_name|safe}}</a> </li>
<li> <a href="{{ cave.url }}">{% if cave.kataster_number %}{{ cave.kataster_number }}{% else %}{{cave.unofficial_number }}{%endif %} {{cave.official_name|safe}}</a> </li>
{% endfor %}
</ul>

View File

@ -1,7 +1,7 @@
{% autoescape off %}
<html>
<head>
{{ head }}
<title>{{ form.title }}</title>
</head>
<body>
{{ form.html }}

View File

@ -1,12 +1,14 @@
{% extends "base.html" %}
{% extends "expobase.html" %}
{% block title %}Edit {{ path }}{% endblock %}
{% block head %}
{% block extrahead %}
{% load csrffaker %}
<script src="{{ settings.TINY_MCE_MEDIA_URL }}tiny_mce.js" type="text/javascript"></script>
{% endblock %}
{% block content %}
{% block body %}
<h1>Edit {{ path }}</h1>
<form action="" method="post">{% csrf_token %}
{{form}}
{{form.as_p}}
<p><input type="submit" value="Submit" /></p>
</form>
{% include "menu.html" %}
{% endblock %}

13
templates/expobase.html Normal file
View File

@ -0,0 +1,13 @@
{% autoescape off %}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="/css/main2.css" />
{% block extrahead %}{% endblock %}
</head>
<body {% block bodyattrs %}{% endblock %}>
{% block body %}{% endblock %}
</body>
</html>
{% endautoescape %}

View File

@ -1,10 +1,7 @@
<html>
<head>
{{ head|safe }}
</head>
<body{% if bodyid %} id="{{ bodyid }}"{% endif %}>
{% extends "expobase.html" %}
{% block title %}{{ title }}{% endblock %}
{% block bodyattrs %}{% if homepage %} id="homepage"{% endif %}{% endblock %}
{% block body %}
{{ body|safe }}
{% if editable %}<a href="{% url editflatpage path %}">Edit</a>{% endif %}
<a href="/troggle">Troggle</a>
</body>
</html>
{% if homepage %}{% if editable %}<a href="{% url editflatpage path %}">Edit</a>{% endif %}{%else %}{% include "menu.html" %}{% endif %}
{% endblock %}

12
templates/menu.html Normal file
View File

@ -0,0 +1,12 @@
{% if not homepage %}
<ul id="links">
<li><a href="/index.htm">Home</a></li>
<li><a href="/infodx.htm">Main Index</a></li>
<li><a href="/troggle">Troggle</a></li>
<li><a href="/areas.htm">Areas</a></li>
<li><a href="/indxal.htm">Caves</a></li>
<li><a href="/handbook/index.htm">Handbook</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 %}
</ul>
{% endif %}

View File

@ -0,0 +1,7 @@
{% extends "expobase.html" %}
{% block title %}Page not found {{ path }}{% endblock %}
{% block body %}
<h1>Page not found {{ path }}</h1>
<a href="{%url editflatpage path %}">Create this page.</a>
{% include "menu.html" %}
{% endblock %}