diff options
author | Markus Zapke-Grùˆndemann <info@keimlink.de> | 2012-01-04 23:58:44 +0100 |
---|---|---|
committer | Markus Zapke-Grùˆndemann <info@keimlink.de> | 2012-01-04 23:58:44 +0100 |
commit | 7e960881ae6cbcd709538dcd73e4fd89e33507d3 (patch) | |
tree | ceea18c587ca1efe4f1877e3b891fa7d61948a06 /sublab_project/calendarium/models.py | |
parent | 9d873fd644b9cc265ad63dbc33f308dbd888ca19 (diff) |
Added model, admin, tests and tasks for calendarium.
Diffstat (limited to 'sublab_project/calendarium/models.py')
-rw-r--r-- | sublab_project/calendarium/models.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/sublab_project/calendarium/models.py b/sublab_project/calendarium/models.py index 71a8362..1cd0665 100644 --- a/sublab_project/calendarium/models.py +++ b/sublab_project/calendarium/models.py @@ -1,3 +1,31 @@ from django.db import models -# Create your models here. + +class Event(models.Model): + """A calendar event. + """ + SOURCE_ADMIN = 'admin' + SOURCE_IMPORT = 'import' + name = models.CharField('Name', max_length=255) + description = models.TextField('Beschreibung', blank=True) + start = models.DateTimeField('Beginn') + end = models.DateTimeField('Ende') + source = models.CharField('Quelle', max_length=10, editable=False, + default=SOURCE_IMPORT) + + class Meta: + verbose_name = 'Termin' + verbose_name_plural = 'Termine' + ordering = ['start', 'end', 'name'] + + def __unicode__(self): + return '%s (%s - %s)' % (self.name, + self.start.strftime('%d.%m.%Y %T'), + self.end.strftime('%d.%m.%Y %T')) + + def clean(self): + """Checks if the start date is lower than the end date. + """ + from django.core.exceptions import ValidationError + if self.start > self.end: + raise ValidationError('Der Beginn darf nicht vor dem Ende liegen.') |