maposmatic-dev
[Top][All Lists]
Advanced

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

[Maposmatic-dev] [PATCH 2/2] models: extend can_recreate() to take into


From: Thomas Petazzoni
Subject: [Maposmatic-dev] [PATCH 2/2] models: extend can_recreate() to take into account new fields
Date: Sat, 14 Apr 2012 19:07:34 +0200

All the jobs that are part of our database and have been submitted
with the previous MapOSMatic version have their layout, stylesheet,
paper_width_mm and paper_height_mm set to default values (empty for
string fields, -1 for integer fields), because they didn't exist in
the previous MapOSMatic version.

The problem is that when an user clicks on a "Recreate this map" link,
we re-create a new job with the same properties... and it is now
invalid to have a job with layout, stylesheet empty or unset
paper_width_mm and paper_height_mm.

Therefore, we adjust can_recreate() to ensure that it is not possible
to recreate jobs from jobs that have been rendered with the old
version of MapOSMatic. We could have set layout and stylesheet to
default values when they are empty, but it was much more complicated
to set a sane value for paper_width_mm and paper_height_mm.

We hope this is one of the reason why we have new jobs with the
stylesheet and layout fields empty, and the paper_width_mm and
paper_height_mm fields set to -1.

Signed-off-by: Thomas Petazzoni <address@hidden>
---
 www/maposmatic/models.py |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/www/maposmatic/models.py b/www/maposmatic/models.py
index 92640a0..d2d4c0d 100644
--- a/www/maposmatic/models.py
+++ b/www/maposmatic/models.py
@@ -162,9 +162,11 @@ class MapRenderingJob(models.Model):
     def is_cancelled(self):         return self.status == 4
 
     def can_recreate(self):
-        return ((self.administrative_city and self.administrative_osmid) or
+        return (((self.administrative_city and self.administrative_osmid) or
                 (self.lat_upper_left and self.lon_upper_left and
-                 self.lat_bottom_right and self.lon_bottom_right))
+                 self.lat_bottom_right and self.lon_bottom_right)) and
+                self.stylesheet and self.layout and
+                self.paper_width_mm != -1 and self.paper_height_mm != -1)
 
     def get_map_fileurl(self, format):
         return www.settings.RENDERING_RESULT_URL + "/" + self.files_prefix() + 
"." + format
-- 
1.7.4.1




reply via email to

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