Esempio n. 1
0
 def prepare(self, context):
     super(PollBox, self).prepare(context)
     SECOND_RENDER = context.get('SECOND_RENDER', False)
     self.state = None
     if DOUBLE_RENDER and SECOND_RENDER or context.has_key('request'):
         from ella.polls import views
         self.state = views.poll_check_vote(context['request'], self.obj)
Esempio n. 2
0
    def prepare(self, context):
        super(PollBox, self).prepare(context)
        SECOND_RENDER = context.get('SECOND_RENDER', False)
        self.state = None
        if getattr(settings, 'DOUBLE_RENDER', False) and not SECOND_RENDER or 'request' not in context:
            return

        from ella.polls import views
        self.state = views.poll_check_vote(context['request'], self.obj)
Esempio n. 3
0
File: models.py Progetto: whit/ella
    def prepare(self, context):
        super(PollBox, self).prepare(context)
        SECOND_RENDER = context.get('SECOND_RENDER', False)
        self.state = None
        if getattr(settings, 'DOUBLE_RENDER',
                   False) and not SECOND_RENDER or 'request' not in context:
            return

        from ella.polls import views
        self.state = views.poll_check_vote(context['request'], self.obj)
Esempio n. 4
0
 def test_check_vote_authetnticated_user_allready_voted_by_session(self):
     user = User.objects.create(username='******')
     session = {views.POLLS_COOKIE_NAME: [self.poll.pk]}
     self.assert_equals(
         views.POLL_USER_ALLREADY_VOTED, 
         views.poll_check_vote(build_request(user=user, session=session), self.poll))
Esempio n. 5
0
 def test_check_vote_annonymous_user_allready_voted_by_cookies(self):
     cookies = {views.POLLS_COOKIE_NAME: ','.join(str(self.poll.pk))}
     self.assert_equals(
         views.POLL_USER_ALLREADY_VOTED,
         views.poll_check_vote(build_request(cookies=cookies), self.poll))
Esempio n. 6
0
 def test_check_vote_authetnticated_user_allready_voted_by_vote_object(self):
     user = User.objects.create(username='******')
     Vote.objects.create(poll=self.poll, user=user)
     self.assert_equals(
         views.POLL_USER_ALLREADY_VOTED, 
         views.poll_check_vote(build_request(user=user), self.poll))
Esempio n. 7
0
 def test_check_vote_annonymous_user_allready_voted_by_vote_object(self):
     Vote.objects.create(poll=self.poll, ip_address='127.0.0.1')
     self.assert_equals(
         views.POLL_USER_ALLREADY_VOTED, 
         views.poll_check_vote(build_request(ip_address='127.0.0.1'), self.poll))
Esempio n. 8
0
 def test_check_vote_authetnticated_user_not_yet_voted(self):
     user = User.objects.create(username='******')
     self.assert_equals(
         views.POLL_USER_NOT_YET_VOTED, 
         views.poll_check_vote(build_request(user=user), self.poll))
Esempio n. 9
0
 def test_check_vote_annonymous_user_not_yet_voted(self):
     self.assert_equals(
         views.POLL_USER_NOT_YET_VOTED, 
         views.poll_check_vote(build_request(ip_address='127.0.0.1'), self.poll))
Esempio n. 10
0
 def test_check_vote_authetnticated_user_allready_voted_by_session(self):
     user = User.objects.create(username='******')
     session = {conf.POLL_COOKIE_NAME: [self.poll.pk]}
     self.assert_equals(
         conf.USER_ALLREADY_VOTED, 
         views.poll_check_vote(build_request(user=user, session=session), self.poll))
Esempio n. 11
0
 def test_check_vote_annonymous_user_allready_voted_by_cookies(self):
     cookies = {conf.POLL_COOKIE_NAME: ','.join(str(self.poll.pk))}
     self.assert_equals(
         conf.USER_ALLREADY_VOTED,
         views.poll_check_vote(build_request(cookies=cookies), self.poll))
Esempio n. 12
0
 def test_check_vote_authetnticated_user_allready_voted_by_vote_object(self):
     user = User.objects.create(username='******')
     Vote.objects.create(poll=self.poll, user=user)
     self.assert_equals(
         conf.USER_ALLREADY_VOTED, 
         views.poll_check_vote(build_request(user=user), self.poll))
Esempio n. 13
0
 def test_check_vote_annonymous_user_allready_voted_by_vote_object(self):
     Vote.objects.create(poll=self.poll, ip_address='127.0.0.1')
     self.assert_equals(
         conf.USER_ALLREADY_VOTED, 
         views.poll_check_vote(build_request(ip_address='127.0.0.1'), self.poll))
Esempio n. 14
0
 def test_check_vote_authetnticated_user_not_yet_voted(self):
     user = User.objects.create(username='******')
     self.assert_equals(
         conf.USER_NOT_YET_VOTED, 
         views.poll_check_vote(build_request(user=user), self.poll))
Esempio n. 15
0
 def test_check_vote_annonymous_user_not_yet_voted(self):
     self.assert_equals(
         conf.USER_NOT_YET_VOTED, 
         views.poll_check_vote(build_request(ip_address='127.0.0.1'), self.poll))