diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2010-11-18 22:50:17 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2010-11-18 22:50:17 +0100 |
commit | 52b79196688dacf5a7874db254bbd9b9748d8ee3 (patch) | |
tree | 2161cf6d3a85716f6920e40aac893f9f5d0ce893 | |
parent | b418a3977cabb6df34099c06f3b8ea563bc9c964 (diff) | |
download | Chimère-52b79196688dacf5a7874db254bbd9b9748d8ee3.tar.bz2 Chimère-52b79196688dacf5a7874db254bbd9b9748d8ee3.zip |
Make the management of dated object optionnal (refs #270)
-rw-r--r-- | chimere/main/models.py | 18 | ||||
-rwxr-xr-x | chimere/scripts/upgrade.py | 30 | ||||
-rw-r--r-- | chimere/settings.py.example | 3 |
3 files changed, 28 insertions, 23 deletions
diff --git a/chimere/main/models.py b/chimere/main/models.py index 489d48d..28f1446 100644 --- a/chimere/main/models.py +++ b/chimere/main/models.py @@ -197,10 +197,11 @@ 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.")) + if settings.DAYS_BEFORE_EVENT: + 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): @@ -272,10 +273,11 @@ 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.")) + if settings.DAYS_BEFORE_EVENT: + 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 bd6e46e..8f5c65a 100755 --- a/chimere/scripts/upgrade.py +++ b/chimere/scripts/upgrade.py @@ -189,22 +189,22 @@ for cls, attr in ((Icon, "image"), (Marker, "picture"), 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) +if settings.DAYS_BEFORE_EVENT: + for cls in (Marker, Route): + table = cls._meta.db_table + query = QUERY_CHECK_FIELD % (table, 'start_date') + cursor.execute(query) transaction.commit_unless_managed() - print " * start_date and end_date added to table " + table + "." + + 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 diff --git a/chimere/settings.py.example b/chimere/settings.py.example index edfaa2e..ebb4fc5 100644 --- a/chimere/settings.py.example +++ b/chimere/settings.py.example @@ -31,6 +31,9 @@ DYNAMIC_CATEGORIES = False DISPLAY_AREAS = True # specific css for areas CSS_AREAS = True +# number of day before an event to display +# if equal to 0: disable event management +DAYS_BEFORE_EVENT = 30 # default id category to check on the map DEFAULT_CATEGORIES = [1] |