Skip to content

Instantly share code, notes, and snippets.

@EdwardIII
Last active December 16, 2015 03:39
Show Gist options
  • Save EdwardIII/5371580 to your computer and use it in GitHub Desktop.
Save EdwardIII/5371580 to your computer and use it in GitHub Desktop.
class Event(models.Model):
name = models.CharField(max_length=500)
start_date = models.DateField(default=datetime.date.today() + datetime.timedelta(days=1))
end_date = models.DateField(blank=True, null=True)
start_time = models.TimeField(blank=True, null=True)
end_time = models.TimeField(blank=True, null=True)
description = models.TextField('Full event description', blank=True)
website = models.CharField(max_length=500, blank=True)
map_code = models.CharField(max_length=500, blank=True)
publish_status = models.CharField(max_length=15, choices=PUBLISH_STATUS, default=UNSAVED)
UNSAVED = 'unsaved'
PREVIEW = 'preview'
DRAFT = 'draft'
PUBLISHED = 'published'
PUBLISH_STATUS = (
(UNSAVED, 'Unsaved'),
(PREVIEW, 'Preview'),
(DRAFT, 'Draft'),
(PUBLISHED, 'Published'),
)
def save(self, *args, **kwargs):
if self.publish_status == self.UNSAVED:
self.publish_status = self.DRAFT
super(Event, self).save(*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment