1 from django.db import models
2 from django.contrib.auth.models import User
3 from philo.models.base import Tag, Entity, Titled
6 if not hasattr(settings, 'PHILO_LOCATION_MODULE'):
7 class Location(Entity, Titled):
8 slug = models.SlugField(max_length=255, unique=True)
10 # Needs to be organised in a sensical order.
11 class Event(Entity, Titled):
12 description = models.TextField()
13 start_time = models.DateTimeField(blank=True, null=True)
14 end_time = models.DateTimeField(blank=True, null=True)
15 is_all_day_event = models.BooleanField(default=False)
16 location = models.ForeignKey(getattr(settings, 'PHILO_LOCATION_MODULE', Location), related_name='events', blank=True, null=True)
17 tags = models.ManyToManyField(Tag, blank=True, null=True)
18 parent_event = models.ForeignKey(Event, blank=True, null=True) # To handle series' of events.
19 user = models.ForeignKey(getattr(settings, 'PHILO_PERSON_MODULE', User)) # Should this be optional?
20 url = models.URLField(blank=True, null=True)
21 attachment = models.FileField(upload_to='events/attachments/%Y/%m/%d', blank=True, null=True)
22 image = models.ImageField(upload_to='events/images/%Y/%m/%d', blank=True, null=True)
25 class Calendar(Entity, Titled):
26 slug = models.SlugField(max_length=255, unique=True)
27 events = models.ManyToManyField(Event, related_name='calendars')
29 # NOTES: Only let start time be blank if it has child events with times.