Created
June 29, 2010 02:30
-
-
Save mwarkentin/456712 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Event(models.Model): | |
# Setup event types | |
TYPE_OTHER = 0 | |
TYPE_FUNERAL = 1 | |
TYPE_WEDDING = 2 | |
TYPE_CHOICES = ( | |
(TYPE_OTHER, 'Other'), | |
(TYPE_FUNERAL, 'Funeral'), | |
(TYPE_WEDDING, 'Wedding'), | |
) | |
# Core fields | |
description = models.TextField() | |
location = models.ForeignKey(Location) | |
name = models.CharField(max_length=255, help_text='Name of the event.') | |
price = models.DecimalField(max_digits=5, decimal_places=2, default=49.99, help_text='Amount that will be charged to users for this event') | |
date = models.DateField(default=datetime.date.today, help_text='Date of the event.') | |
type = models.IntegerField(choices=TYPE_CHOICES, default=TYPE_FUNERAL, help_text='What type of event is it?') | |
videoURL = models.URLField(verify_exists=True, blank=True, help_text='URL for the video on Amazon S3.') | |
users = models.ManyToManyField(User, through='Purchase') | |
#Metadata | |
operator = models.CharField(help_text='ID of local operator or videographer who recorded the event.', max_length=32) | |
slug = models.SlugField(unique_for_date='date', help_text='Suggested value will be generated automatically from the name. Must be unique.') | |
class Meta: | |
ordering=['-date', 'name'] | |
def __unicode__(self): | |
return self.name | |
def get_absolute_url(self): | |
return "/events/%s/%s/" % (self.date.strftime("%Y/%b/%d").lower(), self.slug) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment