[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH 04/13] Add layout, stylesheet and papersize to M
From: |
Thomas Petazzoni |
Subject: |
[Maposmatic-dev] [PATCH 04/13] Add layout, stylesheet and papersize to MapRenderingForm |
Date: |
Thu, 5 Aug 2010 16:56:17 +0200 |
The form used to ask the user for the various parameters of the map
needs to be extended with the new layout, stylesheet and papersize
parameters.
As OCitySMap doesn't yet implement the list of layouts, stylesheets
and paper sizes, so we use stub lists.
The ChoiceField choice lists are filled dynamically in the __init__
constructor instead of directly using the "choices" argument of the
ChoiceField constructor so that the result of a function call can be
used as the list of possible choices.
Signed-off-by: Thomas Petazzoni <address@hidden>
---
www/maposmatic/forms.py | 23 +++++++++++++++++++++++
www/media/style.css | 4 ++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/www/maposmatic/forms.py b/www/maposmatic/forms.py
index adcca19..8044db2 100644
--- a/www/maposmatic/forms.py
+++ b/www/maposmatic/forms.py
@@ -25,12 +25,22 @@
# Forms for MapOSMatic
from django import forms
+from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from ocitysmap.coords import BoundingBox as OCMBoundingBox
from www.maposmatic import helpers, models, widgets
import www.settings
+def get_layout_list():
+ return [("plain", "Sans index"), ("index", "With index"), ("booklet",
"Booklet")]
+
+def get_stylesheet_list():
+ return [("default", "Mapnik par défaut"), ("nobuildings", "Mapnik no
buildings")]
+
+def get_papersize_list():
+ return [("A4", 210, 297), ("A3", 297, 420), ("A2", 420, 594), ("US
Letter", 216, 279)]
+
class MapSearchForm(forms.Form):
"""
The map search form, allowing search through the rendered maps.
@@ -55,6 +65,9 @@ class MapRenderingJobForm(forms.ModelForm):
mode = forms.ChoiceField(choices=MODES, initial='admin',
widget=forms.RadioSelect)
+ layout = forms.ChoiceField(choices=(), widget=forms.RadioSelect)
+ stylesheet = forms.ChoiceField(choices=(), widget=forms.RadioSelect)
+ papersize = forms.ChoiceField(choices=(), widget=forms.RadioSelect)
maptitle = forms.CharField(max_length=256, required=False)
bbox = widgets.AreaField(label=_("Area"),
fields=(forms.FloatField(), forms.FloatField(),
@@ -65,6 +78,16 @@ class MapRenderingJobForm(forms.ModelForm):
administrative_osmid = forms.IntegerField(widget=forms.HiddenInput,
required=False)
+ def __init__(self, *args, **kwargs):
+ super(MapRenderingJobForm, self).__init__(*args, **kwargs)
+ self.fields['layout'].choices = get_layout_list()
+ self.fields['layout'].initial = 'index'
+ self.fields['stylesheet'].choices = get_stylesheet_list()
+ self.fields['stylesheet'].initial = 'default'
+ self.fields['papersize'].choices = \
+ [(p[0], mark_safe("%s <em class=\"papersize\">(%.1f × %.1f
cm²)</em>" % \
+ (p[0], p[1] / 10., p[2] / 10.))) for p in
get_papersize_list()]
+
def clean(self):
"""Cleanup function for the map query form. Different checks are
required depending on the selected mode (by admininstrative city, or by
diff --git a/www/media/style.css b/www/media/style.css
index c1732ea..ce960d0 100644
--- a/www/media/style.css
+++ b/www/media/style.css
@@ -369,6 +369,10 @@ div.pagination {
font-size: 13pt;
}
+#mainfrm em.papersize {
+ font-style: italic;
+}
+
/* Suggest */
#suggest {
margin: 0;
--
1.7.0.4
- [Maposmatic-dev] [PATCH 01/13] Extend MapRenderingJob with stylesheet, papersize and layout, Thomas Petazzoni, 2010/08/05
- [Maposmatic-dev] [PATCH 03/13] Add a get_bbox_from_osm_id() helper, Thomas Petazzoni, 2010/08/05
- [Maposmatic-dev] [PATCH 11/13] Fix language selector to work on Chrome, Thomas Petazzoni, 2010/08/05
- [Maposmatic-dev] [PATCH 07/13] Fix maptitle handling in MapRenderingJobForm, Thomas Petazzoni, 2010/08/05
- [Maposmatic-dev] [PATCH 04/13] Add layout, stylesheet and papersize to MapRenderingForm,
Thomas Petazzoni <=
- [Maposmatic-dev] [PATCH 13/13] Improve the slippy map notifier usage to show when the area is too big, Thomas Petazzoni, 2010/08/05
- [Maposmatic-dev] [PATCH 12/13] Move Ajax service to the /apis/ directory, Thomas Petazzoni, 2010/08/05
- [Maposmatic-dev] [PATCH 10/13] Update licence years, Thomas Petazzoni, 2010/08/05
- [Maposmatic-dev] [PATCH 02/13] Implement a skeleton /papersize/ service, Thomas Petazzoni, 2010/08/05
- [Maposmatic-dev] [PATCH 06/13] Implement a brand new wizard for map creation, Thomas Petazzoni, 2010/08/05
- [Maposmatic-dev] [PATCH 08/13] Add link and form to search maps on the front page, Thomas Petazzoni, 2010/08/05
- [Maposmatic-dev] [PATCH 09/13] Add licence boilerplate in map_rendering_form.css, Thomas Petazzoni, 2010/08/05
- [Maposmatic-dev] [PATCH 05/13] Upgrade jquery to 1.4.2, Thomas Petazzoni, 2010/08/05