From 4294efcad168429838c93eb3626b60bfe9a6db68 Mon Sep 17 00:00:00 2001 From: Kriti Godey Date: Sun, 9 Jan 2011 17:55:18 -0500 Subject: [PATCH] Changed Location & Calendar to check for constants in the settings file for which model to use, and made given models the default ones (only to be initialised if no other models are defined.) --- contrib/julian/models.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/contrib/julian/models.py b/contrib/julian/models.py index 049473c..db6ad71 100644 --- a/contrib/julian/models.py +++ b/contrib/julian/models.py @@ -2,12 +2,14 @@ from django.db import models from philo.models.base import Tag, Entity, Titled import datetime -class Location(Entity, Titled): - slug = models.SlugField(max_length=255, unique=True) +if not hasattr(settings, 'PHILO_LOCATION_MODULE'): + class Location(Entity, Titled): + slug = models.SlugField(max_length=255, unique=True) -class Calendar(Entity, Titled): - slug = models.SlugField(max_length=255, unique=True) +if not hasattr(settings, 'PHILO_CALENDAR_MODULE'): + class Calendar(Entity, Titled): + slug = models.SlugField(max_length=255, unique=True) class Event(Entity, Titled): @@ -16,7 +18,7 @@ class Event(Entity, Titled): end_time = models.DateTimeField() is_all_day_event = models.BooleanField(default=False) time_created = models.DateTimeField(default=datetime.datetime.now) - location = models.ForeignKey(Location) - calendars = models.ManyToManyField(Calendar) + location = models.ForeignKey(getattr(settings, 'PHILO_LOCATION_MODULE', Location), related_name='events') + calendars = models.ManyToManyField(getattr(settings, 'PHILO_CALENDAR_MODULE', Calendar), related_name='events') tags = models.ManyToManyField(Tag) -- 2.20.1