diff options
Diffstat (limited to 'chimere/scripts/upgrade.py')
-rwxr-xr-x | chimere/scripts/upgrade.py | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/chimere/scripts/upgrade.py b/chimere/scripts/upgrade.py index 46b3548..a5e316f 100755 --- a/chimere/scripts/upgrade.py +++ b/chimere/scripts/upgrade.py @@ -162,33 +162,6 @@ for area in areas: if changed: print " * projections of areas corrected" -# changement from version 1.0 to 1.1: version of django 1.2 -# create specific height and width for image fields - -for cls, attr in ((Icon, "image"), (Marker, "picture"), - (Route, "picture")): - table = cls._meta.db_table - query = QUERY_CHECK_FIELD % (table, 'width') - cursor.execute(query) - transaction.commit_unless_managed() - - row = cursor.fetchone() - if not row: - query_update = "ALTER TABLE "+table+" ADD COLUMN width integer" - cursor.execute(query_update) - transaction.commit_unless_managed() - query_update = "ALTER TABLE "+table+" ADD COLUMN height integer" - cursor.execute(query_update) - transaction.commit_unless_managed() - for obj in cls.objects.all(): - image = getattr(obj, attr) - if not image: - continue - obj.width = image.width - obj.height = image.height - obj.save() - print " * height and width of " + table + " corrected" - # changement from version 1.0 to 1.1: add dated fields to markers and routes if settings.DAYS_BEFORE_EVENT: for cls in (Marker, Route): @@ -223,6 +196,32 @@ available_date timestamp with time zone" transaction.commit_unless_managed() print " * available_date added to table " + table + "." +# changement from version 1.0 to 1.1: version of django 1.2 +# create specific height and width for image fields + +for cls, attr in ((Icon, "image"), (Marker, "picture"), + (Route, "picture")): + table = cls._meta.db_table + query = QUERY_CHECK_FIELD % (table, 'width') + cursor.execute(query) + transaction.commit_unless_managed() + + row = cursor.fetchone() + if not row: + query_update = "ALTER TABLE "+table+" ADD COLUMN width integer" + cursor.execute(query_update) + transaction.commit_unless_managed() + query_update = "ALTER TABLE "+table+" ADD COLUMN height integer" + cursor.execute(query_update) + transaction.commit_unless_managed() + for obj in cls.objects.all(): + image = getattr(obj, attr) + if not image: + continue + obj.width = image.width + obj.height = image.height + obj.save() + print " * height and width of " + table + " corrected" # changement from version 1.0 to 1.1: multiple selection of categories |