X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/b2d342589a7889a3b096e7192453d53bd28eed7d..a0f904af83bea5306b09fd66d8dfa254761f5a07:/src/polls/models.py diff --git a/src/polls/models.py b/src/polls/models.py index bfc36394b..1eb18d936 100644 --- a/src/polls/models.py +++ b/src/polls/models.py @@ -1,11 +1,9 @@ -# -*- coding: utf-8 -*- -# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # from django.db import models -from django.utils.translation import ugettext_lazy as _ from django.core.exceptions import ValidationError -from django.core.urlresolvers import reverse +from django.urls import reverse USED_POLLS_KEY = 'used_polls' @@ -13,20 +11,20 @@ USED_POLLS_KEY = 'used_polls' class Poll(models.Model): - question = models.TextField(_('question')) - slug = models.SlugField(_('slug')) - open = models.BooleanField(_('open'), default=False) + question = models.TextField('pytanie') + slug = models.SlugField('slug') + open = models.BooleanField('otwarta', default=False) class Meta: - verbose_name = _('Poll') - verbose_name_plural = _('Polls') + verbose_name = 'ankieta' + verbose_name_plural = 'ankiety' def clean(self): if self.open and Poll.objects.exclude(pk=self.pk).filter(slug=self.slug).exists(): - raise ValidationError(_('Slug of an open poll needs to be unique')) + raise ValidationError('Slug otwartej ankiety musi być unikalny') return super(Poll, self).clean() - def __unicode__(self): + def __str__(self): return self.question[:100] + ' (' + self.slug + ')' def get_absolute_url(self): @@ -42,16 +40,16 @@ class Poll(models.Model): class PollItem(models.Model): - poll = models.ForeignKey(Poll, related_name='items') - content = models.TextField(_('content')) - vote_count = models.IntegerField(_('vote count'), default=0) + poll = models.ForeignKey(Poll, models.CASCADE, related_name='items') + content = models.TextField('treść') + vote_count = models.IntegerField('licznik głosów', default=0) class Meta: - verbose_name = _('vote item') - verbose_name_plural = _('vote items') + verbose_name = 'pozycja ankiety' + verbose_name_plural = 'pozycje ankiety' - def __unicode__(self): - return self.content + ' @ ' + unicode(self.poll) + def __str__(self): + return self.content + ' @ ' + str(self.poll) @property def vote_ratio(self):