summaryrefslogtreecommitdiff
path: root/sublab_project/calendarium/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'sublab_project/calendarium/models.py')
-rw-r--r--sublab_project/calendarium/models.py30
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.')