summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoretienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864>2010-02-07 20:55:13 +0000
committeretienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864>2010-02-07 20:55:13 +0000
commitf7e5307d405849ff89b5a99e8072e2f5225bc37e (patch)
tree4c817d33185b6659aa35dbd852d015e62e58a205
parent3a8e39a3968703d9c6aa73a26e4f41ff9bbd1e7f (diff)
downloadChimère-f7e5307d405849ff89b5a99e8072e2f5225bc37e.tar.bz2
Chimère-f7e5307d405849ff89b5a99e8072e2f5225bc37e.zip
Add a contact page
git-svn-id: http://www.peacefrogs.net/svn/chimere/trunk@53 9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864
-rw-r--r--locale/fr/LC_MESSAGES/django.po92
-rw-r--r--main/actions.py1
-rw-r--r--main/forms.py31
-rw-r--r--main/views.py38
-rw-r--r--settings.py4
-rw-r--r--templates/contactus.html20
-rw-r--r--urls.py1
7 files changed, 149 insertions, 38 deletions
diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po
index 31b5c21..9d90ee4 100644
--- a/locale/fr/LC_MESSAGES/django.po
+++ b/locale/fr/LC_MESSAGES/django.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-01-19 00:40+0100\n"
+"POT-Creation-Date: 2010-02-07 21:47+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -31,20 +31,32 @@ msgstr "Ajout d'un point remarquable"
msgid "Add a new route"
msgstr "Ajout d'un nouveau trajet"
-#: main/forms.py:37
+#: main/actions.py:37
+msgid "Contact us"
+msgstr "Nous contacter"
+
+#: main/forms.py:53
msgid "New submission for"
msgstr "Nouvelle proposition pour"
-#: main/forms.py:40
+#: main/forms.py:54
#, python-format
msgid "The new item \"%s\" has been submited in the category: "
msgstr "Le nouvel élément « %s » a été proposé dans la catégorie : "
-#: main/forms.py:42
+#: main/forms.py:56
msgid "To valid, precise or unvalid this item: "
msgstr "Pour valider, préciser ou rejeter cet élément : "
-#: main/forms.py:205 main/models.py:282
+#: main/forms.py:65
+msgid "Email (optional)"
+msgstr ""
+
+#: main/forms.py:66
+msgid "Object"
+msgstr ""
+
+#: main/forms.py:226 main/models.py:282
msgid "Area"
msgstr "Zone"
@@ -175,37 +187,51 @@ msgstr "Valeur"
msgid "Property"
msgstr "Propriété"
-#: main/widgets.py:103
+#: main/views.py:193
+msgid "Comments/request on the map"
+msgstr "Commentaires/reuètes sur la carte"
+
+#: main/views.py:196
+msgid ""
+"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."
+msgstr ""
+
+#: main/views.py:200
+msgid "Temporary error. Renew your message later."
+msgstr "Erreur temporaire. Réenvoyez votre message plus tard."
+
+#: main/widgets.py:109
msgid "Latitude"
msgstr "Latitude"
-#: main/widgets.py:103
+#: main/widgets.py:109
msgid "Longitude"
msgstr "Longitude"
-#: main/widgets.py:127
+#: main/widgets.py:133
msgid "Invalid point"
msgstr "Point invalide"
-#: main/widgets.py:153
+#: main/widgets.py:159
msgid "Creation mode"
msgstr "Mode création"
-#: main/widgets.py:154
+#: main/widgets.py:160
msgid ""
"To start drawing the route click on the toggle button : \"Start drawing\"."
msgstr ""
-"Pour commencer le dession cliquez sur le bouton : « Commencer le tracé » "
+"Pour commencer le dessin cliquez sur le bouton : « Commencer le tracé » "
-#: main/widgets.py:155
+#: main/widgets.py:161
msgid "Then click on the map to begin the drawing."
msgstr "Puis cliquez sur la carte pour commencer le dessin."
-#: main/widgets.py:156
+#: main/widgets.py:162
msgid "You can add points by clicking again."
msgstr "Vous pouvez ajouter des points en cliquant de nouveau."
-#: main/widgets.py:157
+#: main/widgets.py:163
msgid ""
"To finish the drawing double click. When the drawing is finished you can "
"edit it."
@@ -213,7 +239,7 @@ msgstr ""
"Pour finir le tracé double-cliquez. Quand le tracé est fini vous pouvez "
"toujours l'éditer."
-#: main/widgets.py:159
+#: main/widgets.py:165
msgid ""
"While creating to undo a drawing click again on the toggle button \"Stop "
"drawing\"."
@@ -221,24 +247,24 @@ msgstr ""
"En mode création vous pouvez annuler un tracé en appuyant sur le bouton « "
"Arrêter le tracé »"
-#: main/widgets.py:164
+#: main/widgets.py:170
msgid "Modification mode"
msgstr "Mode modification"
-#: main/widgets.py:165
+#: main/widgets.py:171
msgid "To move a point click on it and drag it to the desired position."
msgstr ""
"Pour bouger un point, cliquez dessus, maintenez le click pour le déposer à "
"la position désirée"
-#: main/widgets.py:166
+#: main/widgets.py:172
msgid ""
"To delete a point move the mouse cursor over it and press the \"d\" key."
msgstr ""
"Pour supprimer un point, mettez le curseur de la souris sur celui-ci et "
"appuyez sur le touche « d »"
-#: main/widgets.py:167
+#: main/widgets.py:173
msgid ""
"To add a point click in the middle of a segment and drag the new point to "
"the desired position"
@@ -247,15 +273,15 @@ msgstr ""
"maintenez le bouton appuyé et déplacez le nouveau point à la position "
"désirée."
-#: main/widgets.py:176
+#: main/widgets.py:182
msgid "Start drawing"
msgstr "Commencer le tracé"
-#: main/widgets.py:176
+#: main/widgets.py:182
msgid "Stop drawing"
msgstr "Arrêter le tracé"
-#: templates/base.html:36
+#: templates/base.html:37
msgid "This site uses Chimère"
msgstr "Ce site utilise Chimère"
@@ -263,6 +289,16 @@ msgstr "Ce site utilise Chimère"
msgid "Close"
msgstr "Fermer"
+#: templates/contactus.html:11
+msgid ""
+"If you have some requests or remarks about this site you can leave them here."
+msgstr "Si vous avez des requètes, des remarques a propos de ce site vous "
+"pouvez nous laisser un commentaire ici."
+
+#: templates/contactus.html:14
+msgid "Submit"
+msgstr "Proposer"
+
#: templates/edit.html:9
msgid "Add a new site"
msgstr "Ajouter un nouveau site"
@@ -309,15 +345,15 @@ msgstr ""
msgid "Shortcuts"
msgstr "Raccourcis"
-#: templates/main_map.html:46
-msgid "Permalink"
-msgstr "Lien permanent"
-
-#: templates/main_map.html:56
+#: templates/main_map.html:42
msgid "Welcome message"
msgstr "Message d'accueil"
-#: templates/main_map.html:56
+#: templates/main_map.html:47
+msgid "Permalink"
+msgstr "Lien permanent"
+
+#: templates/main_map.html:57
msgid "Map"
msgstr "Carte"
diff --git a/main/actions.py b/main/actions.py
index d2cd409..74b622a 100644
--- a/main/actions.py
+++ b/main/actions.py
@@ -34,4 +34,5 @@ actions = ((Action('view', '', _('View')), []),
(Action('edit', 'edit', _('Add a new point of interest')),
Action('edit_route', 'edit_route', _('Add a new route')))
),
+ (Action('contact', 'contact', _('Contact us')), []),
)
diff --git a/main/forms.py b/main/forms.py
index ee69328..be18b2f 100644
--- a/main/forms.py
+++ b/main/forms.py
@@ -24,7 +24,7 @@ from django import forms
from django.contrib.gis.db import models
from django.utils.translation import ugettext as _
from django.contrib.auth.models import User
-from django.core.mail import send_mail
+from django.core.mail import EmailMessage, BadHeaderError
from chimere import settings
@@ -32,17 +32,38 @@ from chimere.main.models import Marker, Route, PropertyModel, Property, Area,\
News, Category
from chimere.main.widgets import AreaField, PointField, TextareaWidget
-def notifyStaff(geo_object):
- category = unicode(geo_object.subcategory)
- subject = u'[Chimère] %s %s' % (_(u"New submission for"), category)
+def notifyStaff(subject, body, sender=None):
+ if settings.PROJECT_NAME:
+ subject = u'[%s] %s' % (settings.PROJECT_NAME, subject)
user_list = [u.email for u in
User.objects.filter(is_staff=True).exclude(email="").order_by('id')]
+ headers = {}
+ if sender:
+ headers['Reply-To'] = sender
+ email = EmailMessage(subject, body, user_list[0], user_list,
+ headers=headers)
+ try:
+ email.send()
+ except BadHeaderError:
+ return False
+ return True
+
+def notifySubmission(geo_object):
+ category = unicode(geo_object.subcategory)
+ subject = u'%s %s' % (_(u"New submission for"), category)
message = _(u'The new item "%s" has been submited in the category: ') % \
geo_object.name + category
message += "\n\n" + _(u"To valid, precise or unvalid this item: ")
message += settings.BASE_URL + 'admin'
message += u"\n\n--\nChimère"
- send_mail(subject, message, user_list[0], user_list)
+ return notifyStaff(subject, message)
+
+class ContactForm(forms.Form):
+ """
+ Main form for categories
+ """
+ email = forms.EmailField(label=_("Email (optional)"), required=False)
+ content = forms.CharField(label=_("Object"), widget=forms.Textarea)
class NewsAdminForm(forms.ModelForm):
"""
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
diff --git a/settings.py b/settings.py
index a20037e..36c6858 100644
--- a/settings.py
+++ b/settings.py
@@ -1,4 +1,8 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
# Django settings for chimere project.
+PROJECT_NAME = u'Chimère'
ROOT_PATH = '/var/local/django/chimere/'
diff --git a/templates/contactus.html b/templates/contactus.html
new file mode 100644
index 0000000..7464c72
--- /dev/null
+++ b/templates/contactus.html
@@ -0,0 +1,20 @@
+{% extends "base_user.html" %}
+{% load i18n %}
+{% block message_map %}{% endblock %}
+{% block message_edit%}{% endblock %}
+{% block content %}{{ block.super }}
+<div id='content'>
+{% if message %}
+<div class='warning'><p>{{message}}</p></div>
+{% else %}
+<fieldset class='edit'>
+<p>{% trans "If you have some requests or remarks about this site you can leave them here." %}</p>
+<form action="" method="post">
+{{contact_form.as_p}}
+<input type="submit" value="{% trans "Submit" %}" />
+</form>
+</fieldset>
+{% endif %}
+</div>
+{% endblock %}
+
diff --git a/urls.py b/urls.py
index 67c64f2..0cf6862 100644
--- a/urls.py
+++ b/urls.py
@@ -12,6 +12,7 @@ js_info_dict = {
urlpatterns = patterns('',
(r'^' + EXTRA_URL + r'admin/(.*)', admin.site.root),
(r'^' + EXTRA_URL + r'$', 'chimere.main.views.index'),
+ (r'^' + EXTRA_URL + r'contact/$', 'chimere.main.views.contactus'),
(r'^' + EXTRA_URL + r'edit/$', 'chimere.main.views.edit'),
(r'^' + EXTRA_URL + r'edit_route/$', 'chimere.main.views.editRoute'),
(r'^' + EXTRA_URL + r'submited/(?P<action>\w+)/$$', 'chimere.main.views.submited'),