maposmatic-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maposmatic-dev] [PATCH 1/2] forms: add validation of layout and stylesh


From: Thomas Petazzoni
Subject: [Maposmatic-dev] [PATCH 1/2] forms: add validation of layout and stylesheet
Date: Sat, 14 Apr 2012 18:44:07 +0200

We have received several rendering requests with layout and stylesheet
empty. We believe that people might have written scripts against the
previous version of MapOSMatic, and so they didn't fill those
fields. Therefore, we add some form-level validation logic to reject
jobs that have layout and/or stylesheet empty.

Signed-off-by: Thomas Petazzoni <address@hidden>
---
 www/maposmatic/forms.py |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/www/maposmatic/forms.py b/www/maposmatic/forms.py
index 13a3248..4035739 100644
--- a/www/maposmatic/forms.py
+++ b/www/maposmatic/forms.py
@@ -146,6 +146,8 @@ class MapRenderingJobForm(forms.ModelForm):
         mode = cleaned_data.get("mode")
         city = cleaned_data.get("administrative_city")
         title = cleaned_data.get("maptitle")
+        layout = cleaned_data.get("layout")
+        stylesheet = cleaned_data.get("stylesheet")
 
         if cleaned_data.get("paperorientation") == 'landscape':
             cleaned_data["paper_width_mm"], cleaned_data["paper_height_mm"] = \
@@ -156,6 +158,16 @@ class MapRenderingJobForm(forms.ModelForm):
             self._errors["maptitle"] = forms.util.ErrorList([msg])
             del cleaned_data["maptitle"]
 
+        if layout == '':
+            msg = _(u"Layout required")
+            self._errors["layout"] = forms.util.ErrorList([msg])
+            del cleaned_data["layout"]
+
+        if stylesheet == '':
+            msg = _(u"Stylesheet required")
+            self._errors["stylesheet"] = forms.util.ErrorList([msg])
+            del cleaned_data["stylesheet"]
+
         if mode == 'admin':
             if city == "":
                 msg = _(u"Administrative city required")
-- 
1.7.4.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]