-# -*- 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.
#
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'
raise ValidationError(_('Slug of an open poll needs to be unique'))
return super(Poll, self).clean()
- def __unicode__(self):
+ def __str__(self):
return self.question[:100] + ' (' + self.slug + ')'
def get_absolute_url(self):
class PollItem(models.Model):
- poll = models.ForeignKey(Poll, related_name='items')
+ poll = models.ForeignKey(Poll, models.CASCADE, related_name='items')
content = models.TextField(_('content'))
vote_count = models.IntegerField(_('vote count'), default=0)
verbose_name = _('vote item')
verbose_name_plural = _('vote items')
- def __unicode__(self):
- return self.content + ' @ ' + unicode(self.poll)
+ def __str__(self):
+ return self.content + ' @ ' + str(self.poll)
@property
def vote_ratio(self):