[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH 2/3] Only use a map title for bounding box defin
From: |
Maxime Petazzoni |
Subject: |
[Maposmatic-dev] [PATCH 2/3] Only use a map title for bounding box defined maps. |
Date: |
Sun, 6 Sep 2009 13:06:54 +0200 |
This changes removes the need for a map title when requesting for a map
by city name. When the request is made by administrative boundary, the
map title is directly infered from the city name. Otherwise, a map title
is of course still required.
---
www/locale/fr/LC_MESSAGES/django.po | 10 +++++--
www/maposmatic/views.py | 11 +++++++-
www/templates/maposmatic/index.html | 45 ++++++++++++++++++-----------------
3 files changed, 40 insertions(+), 26 deletions(-)
diff --git a/www/locale/fr/LC_MESSAGES/django.po
b/www/locale/fr/LC_MESSAGES/django.po
index 20d73e6..a8c8e0b 100644
--- a/www/locale/fr/LC_MESSAGES/django.po
+++ b/www/locale/fr/LC_MESSAGES/django.po
@@ -47,15 +47,19 @@ msgstr "Limites administratives (nom de ville)"
msgid "Bounding box"
msgstr "Zone géographique"
-#: maposmatic/views.py:76
+#: maposmatic/views.py:79
msgid "Administrative city required"
msgstr "Nom de ville obligatoire"
-#: maposmatic/views.py:80
+#: maposmatic/views.py:83
msgid "No administrative boundaries found for this city. Try with proper
casing."
msgstr "Aucune limite administrative disponible pour cette ville. Essayez en
corrigeant la casse (majuscule sur la première lettre)"
-#: maposmatic/views.py:89
+#: maposmatic/views.py:91
+msgid "Map title required"
+msgstr "Titre de la carte obligatoire"
+
+#: maposmatic/views.py:99
msgid "Required"
msgstr "Obligatoire"
diff --git a/www/maposmatic/views.py b/www/maposmatic/views.py
index 1a25a87..6c94348 100644
--- a/www/maposmatic/views.py
+++ b/www/maposmatic/views.py
@@ -24,7 +24,7 @@
# Create your views here.
from django.forms.util import ErrorList
-from django.forms import ChoiceField, RadioSelect, ModelForm, ValidationError
+from django.forms import CharField, ChoiceField, RadioSelect, ModelForm,
ValidationError
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
@@ -64,12 +64,14 @@ class MapRenderingJobForm(ModelForm):
modes = (('admin', _('Administrative boundary')),
('bbox', _('Bounding box')))
mode = ChoiceField(choices=modes, initial='admin', widget=RadioSelect)
+ maptitle = CharField(max_length=256, required=False)
def clean(self):
cleaned_data = self.cleaned_data
mode = cleaned_data.get("mode")
city = cleaned_data.get("administrative_city")
+ title = cleaned_data.get("maptitle")
if mode == 'admin':
if city == "":
@@ -81,7 +83,14 @@ class MapRenderingJobForm(ModelForm):
self._errors["administrative_city"] = ErrorList([msg])
del cleaned_data["administrative_city"]
+ cleaned_data["maptitle"] = city
+
if mode == 'bbox':
+ if title == '':
+ msg = _(u"Map title required")
+ self._errors["maptitle"] = ErrorList([msg])
+ del cleaned_data["maptitle"]
+
for f in [ "lat_upper_left", "lon_upper_left",
"lat_bottom_right", "lon_bottom_right" ]:
val = cleaned_data.get(f)
diff --git a/www/templates/maposmatic/index.html
b/www/templates/maposmatic/index.html
index 2faabe1..470c72f 100644
--- a/www/templates/maposmatic/index.html
+++ b/www/templates/maposmatic/index.html
@@ -29,22 +29,23 @@
{% block extrajs %}
function area_selection_mode_switch(mode)
{
- if (mode == 'bbox-mode')
- {
- document.getElementById('admin-mode').style.display = 'none';
- document.getElementById('bbox-mode').style.display = '';
- }
- else if (mode == 'admin-mode')
- {
- document.getElementById('admin-mode').style.display = '';
- document.getElementById('bbox-mode').style.display = 'none';
+ var arr = document.getElementById('mapform').getElementsByTagName('tr');
+ for (i=0; i < arr.length; i++) {
+ arr[i].style.display = '';
+ if ((arr[i].className == 'byadmin' && mode != 'admin-mode') ||
+ (arr[i].className == 'bybbox' && mode != 'bbox-mode')) {
+ arr[i].style.display = 'none';
+ }
}
}
function pageinit()
{
- document.getElementById('id_mode_0').setAttribute('onclick',
"area_selection_mode_switch('admin-mode')");
- document.getElementById('id_mode_1').setAttribute('onclick',
"area_selection_mode_switch('bbox-mode')");
+ document.getElementById('id_mode_0').setAttribute('onclick',
+ "area_selection_mode_switch('admin-mode')");
+ document.getElementById('id_mode_1').setAttribute('onclick',
+ "area_selection_mode_switch('bbox-mode')");
+
if (document.getElementById('id_mode_0').getAttribute('checked') ==
'checked')
area_selection_mode_switch('admin-mode');
else if (document.getElementById('id_mode_1').getAttribute('checked') ==
'checked')
@@ -143,24 +144,24 @@ map.{%endblocktrans%}</p>
<form method="post" action="">
-<table style="margin: auto; border: 1px solid #CCC; padding: 10px;">
+<table id="mapform" style="margin: auto; border: 1px solid #CCC; padding:
10px; width: 70%;">
<tr>
- <td width="50%">{% trans "Title of the map" %}</td>
- <td>{{ form.maptitle }}</td>
- <td>{{ form.maptitle.errors }}</td>
- </tr>
- <tr>
- <td>{% trans "Area selection mode" %}</td>
- <td>
+ <td width="50%">{% trans "Area selection mode" %}</td>
+ <td width="50%" colspan="2">
{{ form.mode }}
</td>
</tr>
- <tr id="admin-mode">
+ <tr class="byadmin">
<td>{% trans "City name" %}</td>
<td>{{ form.administrative_city }}</td>
<td>{{ form.administrative_city.errors }}</td>
</tr>
- <tr id="bbox-mode" style="display: none;">
+ <tr class="bybbox">
+ <td width="50%">{% trans "Title of the map" %}</td>
+ <td>{{ form.maptitle }}</td>
+ <td>{{ form.maptitle.errors }}</td>
+ </tr>
+ <tr class="bybbox" style="display: none;">
<td>{% trans "Bounding box" %}</td>
<td style="text-align: center">
<input type="text" name="lat_upper_left" style="width: 100px;
margin-bottom: 5px;"/>{{ form.lat_upper_left.errors }}<br/>
@@ -171,7 +172,7 @@ map.{%endblocktrans%}</p>
</tr>
<tr>
<td></td>
- <td><input type="submit" value="{% trans 'Generate' %}"/></td>
+ <td colspan="2"><input type="submit" value="{% trans 'Generate' %}"/></td>
</tr>
</table>
--
1.6.3.3.210.g29cb3
Re: [Maposmatic-dev] [PATCH 1/3] Re-add the session application to the INSTALLED_APPS list., Thomas Petazzoni, 2009/09/07