summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2010-11-18 22:36:43 +0100
committerÉtienne Loks <etienne.loks@peacefrogs.net>2010-11-18 22:36:43 +0100
commitb418a3977cabb6df34099c06f3b8ea563bc9c964 (patch)
tree7502f4a9e6c411c7871c754813f256e176499ab5
parentfdf82c977f28d86c7d9352c11765461e6a15241c (diff)
downloadChimère-b418a3977cabb6df34099c06f3b8ea563bc9c964.tar.bz2
Chimère-b418a3977cabb6df34099c06f3b8ea563bc9c964.zip
Add dated fields for markers and routes in model - update of the upgrade
script (refs #270)
-rw-r--r--chimere/main/models.py8
-rwxr-xr-xchimere/scripts/upgrade.py19
2 files changed, 27 insertions, 0 deletions
diff --git a/chimere/main/models.py b/chimere/main/models.py
index 564552f..489d48d 100644
--- a/chimere/main/models.py
+++ b/chimere/main/models.py
@@ -197,6 +197,10 @@ class Marker(models.Model):
for key, label in STATUS:
STATUS_DCT[key] = label
status = models.CharField(_("Status"), max_length=1, choices=STATUS)
+ start_date = models.DateField(_("Start date"), blank=True, null=True,
+ help_text=_("Not mandatory. Set it for dated item such as event."))
+ end_date = models.DateField(_("End date"), blank=True, null=True,
+ help_text=_("Not mandatory. Set it only if you have set a start date."))
objects = models.GeoManager()
def __unicode__(self):
@@ -268,6 +272,10 @@ class Route(models.Model):
STATUS_DCT = {}
for key, label in STATUS:
STATUS_DCT[key] = label
+ start_date = models.DateField(_("Start date"), blank=True, null=True,
+ help_text=_("Not mandatory. Set it for dated item such as event."))
+ end_date = models.DateField(_("End date"), blank=True, null=True,
+ help_text=_("Not mandatory. Set it only if you have set a start date."))
status = models.CharField(_("Status"), max_length=1, choices=STATUS)
objects = models.GeoManager()
diff --git a/chimere/scripts/upgrade.py b/chimere/scripts/upgrade.py
index 4c1cdc0..bd6e46e 100755
--- a/chimere/scripts/upgrade.py
+++ b/chimere/scripts/upgrade.py
@@ -188,6 +188,25 @@ for cls, attr in ((Icon, "image"), (Marker, "picture"),
obj.save()
print " * height and width of " + table + " corrected"
+# changement from version 1.0 to 1.1: add dated fields to markers and routes
+
+for cls in (Marker, Route):
+ table = cls._meta.db_table
+ query = QUERY_CHECK_FIELD % (table, 'start_date')
+ cursor.execute(query)
+ transaction.commit_unless_managed()
+
+ row = cursor.fetchone()
+ if not row:
+ query_update = "ALTER TABLE "+table+" ADD COLUMN start_date date"
+ cursor.execute(query_update)
+ transaction.commit_unless_managed()
+ query_update = "ALTER TABLE "+table+" ADD COLUMN end_date date"
+ cursor.execute(query_update)
+ transaction.commit_unless_managed()
+ print " * start_date and end_date added to table " + table + "."
+
+
# changement from version 1.0 to 1.1: multiple selection of categories
for cls in (Marker, Route):