コード例 #1
0
ファイル: models.py プロジェクト: dedaluz/ella
 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)
コード例 #2
0
ファイル: models.py プロジェクト: rpgplanet/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)
コード例 #3
0
ファイル: models.py プロジェクト: 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)
コード例 #4
0
ファイル: test_polls.py プロジェクト: Almad/ella
 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))
コード例 #5
0
ファイル: test_polls.py プロジェクト: Almad/ella
 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))
コード例 #6
0
ファイル: test_polls.py プロジェクト: Almad/ella
 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))
コード例 #7
0
ファイル: test_polls.py プロジェクト: Almad/ella
 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))
コード例 #8
0
ファイル: test_polls.py プロジェクト: Almad/ella
 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))
コード例 #9
0
ファイル: test_polls.py プロジェクト: Almad/ella
 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))
コード例 #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))
コード例 #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))
コード例 #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))
コード例 #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))
コード例 #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))
コード例 #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))