1 # -*- coding: utf-8 -*-
2 # This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.conf import settings
6 from django.core.exceptions import ValidationError
7 from django.db import models
8 from django.utils.translation import ugettext_lazy as _, ugettext
9 from migdal.helpers import add_translatable
12 class Event(models.Model):
13 date = models.DateTimeField(_('date'), max_length=255, db_index=True)
14 link = models.URLField(_('link'))
17 verbose_name = _('event')
18 verbose_name_plural = _('events')
21 def __unicode__(self):
25 for lc, ln in settings.LANGUAGES:
26 if (getattr(self, "published_%s" % lc) and
27 not getattr(self, "title_%s" % lc)):
28 raise ValidationError(
29 ugettext("Published event should have a title in relevant language (%s).") % lc)
32 add_translatable(Event, {
33 'title': models.CharField(_('title'), max_length=255, blank=True),
34 'organizer': models.CharField(_('organizer'), max_length=255,
35 db_index=True, blank=True),
36 'place': models.CharField(_('place'), max_length=255, blank=True),
37 'published': models.BooleanField(_('published'), default=False),