from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ValidationError
raise ValidationError(_('Slug of an open poll needs to be unique'))
return super(Poll, self).clean()
raise ValidationError(_('Slug of an open poll needs to be unique'))
return super(Poll, self).clean()
def voted(self, session):
return self.id in session.get(USED_POLLS_KEY, set())
def voted(self, session):
return self.id in session.get(USED_POLLS_KEY, set())
def vote(self, session):
self.vote_count = self.vote_count + 1
self.save()
session.setdefault(USED_POLLS_KEY, set()).add(self.poll.id)
def vote(self, session):
self.vote_count = self.vote_count + 1
self.save()
session.setdefault(USED_POLLS_KEY, set()).add(self.poll.id)