From 662258ae0a1423d9153c5a7528ab3a9e1672e877 Mon Sep 17 00:00:00 2001 From: Kriti Godey Date: Tue, 1 Feb 2011 05:04:51 -0500 Subject: [PATCH] Model changes. --- contrib/julian/models.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/contrib/julian/models.py b/contrib/julian/models.py index db6ad71..33c4d51 100644 --- a/contrib/julian/models.py +++ b/contrib/julian/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.contrib.auth.models import User from philo.models.base import Tag, Entity, Titled import datetime @@ -6,19 +7,23 @@ if not hasattr(settings, 'PHILO_LOCATION_MODULE'): class Location(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) - - +# Needs to be organised in a sensical order. class Event(Entity, Titled): description = models.TextField() - start_time = models.DateTimeField() - end_time = models.DateTimeField() + start_time = models.DateTimeField(blank=True, null=True) + end_time = models.DateTimeField(blank=True, null=True) is_all_day_event = models.BooleanField(default=False) - time_created = models.DateTimeField(default=datetime.datetime.now) - 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) + location = models.ForeignKey(getattr(settings, 'PHILO_LOCATION_MODULE', Location), related_name='events', blank=True, null=True) + tags = models.ManyToManyField(Tag, blank=True, null=True) + parent_event = models.ForeignKey(Event, blank=True, null=True) # To handle series' of events. + user = models.ForeignKey(getattr(settings, 'PHILO_PERSON_MODULE', User)) # Should this be optional? + url = models.URLField(blank=True, null=True) + attachment = models.FileField(upload_to='events/attachments/%Y/%m/%d', blank=True, null=True) + image = models.ImageField(upload_to='events/images/%Y/%m/%d', blank=True, null=True) + +class Calendar(Entity, Titled): + slug = models.SlugField(max_length=255, unique=True) + events = models.ManyToManyField(Event, related_name='calendars') + +# NOTES: Only let start time be blank if it has child events with times. \ No newline at end of file -- 2.20.1