summaryrefslogtreecommitdiff
path: root/main/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'main/views.py')
-rw-r--r--main/views.py38
1 files changed, 33 insertions, 5 deletions
diff --git a/main/views.py b/main/views.py
index ce41c40..9de8f4b 100644
--- a/main/views.py
+++ b/main/views.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2008 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2008-2010 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
@@ -23,6 +23,7 @@ Views of the project
import datetime
+from django.utils.translation import ugettext as _
from django.shortcuts import render_to_response
from django.template import loader
from django.http import HttpResponseRedirect, HttpResponse
@@ -35,7 +36,8 @@ from chimere.main.models import Category, SubCategory, PropertyModel, Marker, \
from chimere.main.widgets import getMapJS, PointChooserWidget, \
RouteChooserWidget, URL_OSM_JS, URL_OSM_CSS
-from chimere.main.forms import MarkerForm, RouteForm, notifyStaff
+from chimere.main.forms import MarkerForm, RouteForm, ContactForm, \
+ notifySubmission, notifyStaff
def index(request):
"""
@@ -100,7 +102,7 @@ def edit(request):
# set the submited status
marker.status = 'S'
marker.save()
- notifyStaff(marker)
+ notifySubmission(marker)
return HttpResponseRedirect('/' + settings.EXTRA_URL +'submited/edit')
else:
# An unbound form
@@ -136,8 +138,9 @@ def editRoute(request):
# set the submited status
route.status = 'S'
route.save()
- notifyStaff(route)
- return HttpResponseRedirect('/' + settings.EXTRA_URL + 'submited/edit_route')
+ notifySubmission(route)
+ return HttpResponseRedirect('/' + settings.EXTRA_URL + \
+ 'submited/edit_route')
else:
# An unbound form
form = RouteForm()
@@ -176,6 +179,31 @@ def submited(request, action):
'media_path':settings.MEDIA_URL,}
return render_to_response('submited.html', response_dct)
+def contactus(request):
+ """
+ Contact page
+ """
+ form = None
+ msg = ''
+ # If the form has been submited
+ if request.method == 'POST':
+ form = ContactForm(request.POST)
+ # All validation rules pass
+ if form.is_valid():
+ response = notifyStaff(_(u"Comments/request on the map"),
+ form.cleaned_data['content'], form.cleaned_data['email'])
+ if response:
+ msg = _(u"Thank you for your contribution. It will be taken \
+into account. If you have left your email you may be contacted soon for more \
+details.")
+ else:
+ msg = _(u"Temporary error. Renew your message later.")
+ else:
+ form = ContactForm()
+ response_dct = {'actions':actions, 'action_selected':('contact',),
+ 'media_path':settings.MEDIA_URL,'contact_form':form, 'message':msg}
+ return render_to_response('contactus.html', response_dct)
+
def getDetail(request, marker_id):
'''
Get the detail for a marker