当前位置: 首页>>代码示例>>Python>>正文


Python Participant.status方法代码示例

本文整理汇总了Python中oioioi.participants.models.Participant.status方法的典型用法代码示例。如果您正苦于以下问题:Python Participant.status方法的具体用法?Python Participant.status怎么用?Python Participant.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oioioi.participants.models.Participant的用法示例。


在下文中一共展示了Participant.status方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_participants_contest_visibility

# 需要导入模块: from oioioi.participants.models import Participant [as 别名]
# 或者: from oioioi.participants.models.Participant import status [as 别名]
    def test_participants_contest_visibility(self):
        contest = Contest(id='invisible', name='Invisible Contest')
        contest.controller_name = \
                'oioioi.participants.tests.ParticipantsContestController'
        contest.save()
        user = User.objects.get(username='test_user')
        response = self.client.get(reverse('select_contest'))
        self.assertIn('contests/select_contest.html',
                [t.name for t in response.templates])
        self.assertEqual(len(response.context['contests']), 1)

        self.client.login(username='test_user')
        response = self.client.get(reverse('select_contest'))
        self.assertEqual(len(response.context['contests']), 1)

        p1 = Participant(contest=contest, user=user, status='BANNED')
        p1.save()
        self.client.login(username='test_user')
        response = self.client.get(reverse('select_contest'))
        self.assertEqual(len(response.context['contests']), 1)

        p1.status = 'ACTIVE'
        p1.save()
        self.client.login(username='test_user')
        response = self.client.get(reverse('select_contest'))
        self.assertEqual(len(response.context['contests']), 2)

        self.client.login(username='test_admin')
        response = self.client.get(reverse('select_contest'))
        self.assertEqual(len(response.context['contests']), 2)
        self.assertIn('Invisible Contest', response.content)
开发者ID:papedaniel,项目名称:oioioi,代码行数:33,代码来源:tests.py

示例2: test_participants_contest_access

# 需要导入模块: from oioioi.participants.models import Participant [as 别名]
# 或者: from oioioi.participants.models.Participant import status [as 别名]
    def test_participants_contest_access(self):
        contest = Contest.objects.get()
        contest.controller_name = \
                'oioioi.participants.tests.ParticipantsContestController'
        contest.save()

        user = User.objects.get(username='test_user')
        p = Participant(contest=contest, user=user, status='BANNED')
        p.save()

        url = reverse('default_contest_view',
                      kwargs={'contest_id': contest.id})

        self.client.login(username='test_user2')
        response = self.client.get(url, follow=True)
        self.assertEqual(403, response.status_code)
        # Make sure we get nice page, allowing to log out.
        self.assertNotIn('My submissions', response.content)
        self.assertIn('OIOIOI', response.content)
        self.assertIn('Log out', response.content)

        self.client.login(username='test_user')
        response = self.client.get(url, follow=True)
        self.assertEqual(403, response.status_code)

        p.status = 'ACTIVE'
        p.save()

        self.client.login(username='test_user')
        response = self.client.get(url, follow=True)
        self.assertEqual(200, response.status_code)
开发者ID:papedaniel,项目名称:oioioi,代码行数:33,代码来源:tests.py

示例3: test_participants_unregister_forbidden

# 需要导入模块: from oioioi.participants.models import Participant [as 别名]
# 或者: from oioioi.participants.models.Participant import status [as 别名]
    def test_participants_unregister_forbidden(self):
        contest = Contest.objects.get()

        url = reverse('participants_unregister',
                      kwargs={'contest_id': contest.id})

        self.assertTrue(self.client.login(username='test_user'))
        response = self.client.post(url, {'post': 'yes'})
        self.assertEqual(403, response.status_code)

        user = User.objects.get(username='test_user')
        p = Participant(contest=contest, user=user, status='BANNED')
        p.save()
        self.assertEqual(Participant.objects.count(), 1)

        self.assertTrue(self.client.login(username='test_user'))
        response = self.client.post(url, {'post': 'yes'})
        self.assertEqual(403, response.status_code)

        p.status = 'ACTIVE'
        p.save()

        self.assertTrue(self.client.login(username='test_user'))
        response = self.client.post(url, {'post': 'yes'})
        self.assertEqual(403, response.status_code)
开发者ID:sio2project,项目名称:oioioi,代码行数:27,代码来源:tests.py

示例4: test_submit_permissions

# 需要导入模块: from oioioi.participants.models import Participant [as 别名]
# 或者: from oioioi.participants.models.Participant import status [as 别名]
    def test_submit_permissions(self):
        contest = Contest.objects.get()
        contest.controller_name = \
                'oioioi.participants.tests.ParticipantsContestController'
        contest.save()

        round = Round.objects.get(pk=1)
        problem_instance = ProblemInstance.objects.get(pk=1)
        self.assertTrue(problem_instance.round == round)
        round.start_date = datetime(2012, 7, 31, tzinfo=utc)
        round.end_date = datetime(2012, 8, 5, tzinfo=utc)
        round.save()

        user = User.objects.get(username='test_user')
        p = Participant(contest=contest, user=user, status='BANNED')
        p.save()

        with fake_time(datetime(2012, 8, 4, 0, 5, tzinfo=utc)):
            self.client.login(username='test_user2')
            response = self.submit_file(contest, problem_instance)
            self.assertEqual(403, response.status_code)

            self.client.login(username='test_user')
            response = self.submit_file(contest, problem_instance)
            self.assertEqual(403, response.status_code)

            p.status = 'ACTIVE'
            p.save()

            self.client.login(username='test_user')
            response = self.submit_file(contest, problem_instance)
            self._assertSubmitted(contest, response)
开发者ID:papedaniel,项目名称:oioioi,代码行数:34,代码来源:tests.py

示例5: test_participants_unregister

# 需要导入模块: from oioioi.participants.models import Participant [as 别名]
# 或者: from oioioi.participants.models.Participant import status [as 别名]
    def test_participants_unregister(self):
        contest = Contest.objects.get()
        contest.controller_name = \
                'oioioi.oi.controllers.OIOnsiteContestController'
        contest.save()

        self.client.login(username='test_user')
        response = self.client.post('/c/%s/unregister' % (contest.id,),
                                    {'post': 'yes'})
        self.assertEqual(404, response.status_code)

        user = User.objects.get(username='test_user')
        p = Participant(contest=contest, user=user, status='BANNED')
        p.save()
        self.assertEqual(Participant.objects.count(), 1)

        self.client.login(username='test_user')
        response = self.client.post('/c/%s/unregister' % (contest.id,),
                                    {'post': 'yes'})
        self.assertEqual(403, response.status_code)

        p.status = 'ACTIVE'
        p.save()

        self.client.login(username='test_user')
        response = self.client.post('/c/%s/unregister' % (contest.id,),
                                    {'post': 'yes'})
        self.assertEqual(403, response.status_code)
开发者ID:mahrud,项目名称:oioioi,代码行数:30,代码来源:tests.py

示例6: test_contest_access

# 需要导入模块: from oioioi.participants.models import Participant [as 别名]
# 或者: from oioioi.participants.models.Participant import status [as 别名]
    def test_contest_access(self):
        contest = Contest.objects.get()
        contest.controller_name = \
                'oioioi.oi.controllers.OIContestController'
        contest.save()

        user = User.objects.get(username='test_user')
        p = Participant(contest=contest, user=user, status='BANNED')
        p.save()

        url = reverse('default_contest_view',
                      kwargs={'contest_id': contest.id})

        self.client.login(username='test_user2')
        response = self.client.get(url, follow=True)
        self.assertEqual(200, response.status_code)

        self.client.login(username='test_user')
        response = self.client.get(url, follow=True)
        self.assertEqual(200, response.status_code)

        p.status = 'ACTIVE'
        p.save()

        self.client.login(username='test_user')
        response = self.client.get(url, follow=True)
        self.assertEqual(200, response.status_code)
开发者ID:papedaniel,项目名称:oioioi,代码行数:29,代码来源:tests.py

示例7: test_participants_unregister

# 需要导入模块: from oioioi.participants.models import Participant [as 别名]
# 或者: from oioioi.participants.models.Participant import status [as 别名]
    def test_participants_unregister(self):
        contest = Contest.objects.get()
        contest.controller_name = \
                'oioioi.participants.tests.OpenRegistrationContestController'
        contest.save()

        url = reverse('participants_unregister',
                      kwargs={'contest_id': contest.id})

        self.client.login(username='test_user')
        response = self.client.post(url, {'post': 'yes'})
        self.assertEqual(403, response.status_code)

        user = User.objects.get(username='test_user')
        p = Participant(contest=contest, user=user, status='BANNED')
        p.save()
        self.assertEqual(Participant.objects.count(), 1)

        self.client.login(username='test_user')
        response = self.client.post(url, {'post': 'yes'})
        self.assertEqual(403, response.status_code)

        p.status = 'ACTIVE'
        p.save()

        self.client.login(username='test_user')
        response = self.client.post(url, {'post': 'yes'})
        self.assertEqual(302, response.status_code)
        self.assertEqual(Participant.objects.count(), 0)
开发者ID:matrach,项目名称:oioioi,代码行数:31,代码来源:tests.py

示例8: test_participants_contest_access

# 需要导入模块: from oioioi.participants.models import Participant [as 别名]
# 或者: from oioioi.participants.models.Participant import status [as 别名]
    def test_participants_contest_access(self):
        contest = Contest.objects.get()
        contest.controller_name = \
                'oioioi.participants.tests.ParticipantsContestController'
        contest.save()

        user = User.objects.get(username='test_user')
        p = Participant(contest=contest, user=user, status='BANNED')
        p.save()


        self.client.login(username='test_user2')
        response = self.client.get('/c/%s/' % (contest.id,), follow=True)
        self.assertEqual(403, response.status_code)

        self.client.login(username='test_user')
        response = self.client.get('/c/%s/' % (contest.id,), follow=True)
        self.assertEqual(403, response.status_code)

        p.status = 'ACTIVE'
        p.save()

        self.client.login(username='test_user')
        response = self.client.get('/c/%s/' % (contest.id,), follow=True)
        self.assertEqual(200, response.status_code)
开发者ID:mahrud,项目名称:oioioi,代码行数:27,代码来源:tests.py

示例9: test_mailsubmit_permissions

# 需要导入模块: from oioioi.participants.models import Participant [as 别名]
# 或者: from oioioi.participants.models.Participant import status [as 别名]
    def test_mailsubmit_permissions(self):
        contest = Contest.objects.get()
        contest.controller_name = \
            'oioioi.participants.tests.ParticipantsContestController'
        contest.save()

        problem_instance = ProblemInstance.objects.get()
        problem_instance.submissions_limit = 0
        problem_instance.save()
        round = Round.objects.get()
        round.start_date = datetime(2012, 7, 31, tzinfo=utc)
        round.end_date = datetime(2012, 8, 10, tzinfo=utc)
        round.save()
        msc = MailSubmissionConfig(contest=contest, enabled=True,
                start_date=datetime(2012, 8, 12, tzinfo=utc),
                end_date=datetime(2012, 8, 14, tzinfo=utc))
        msc.save()

        user = User.objects.get(username='test_user')
        p = Participant(contest=contest, user=user, status='BANNED')
        p.save()

        with fake_time(datetime(2012, 8, 13, 0, 5, tzinfo=utc)):
            self.client.login(username='test_user2')
            response = self.submit_file(contest, problem_instance)
            self.assertEqual(403, response.status_code)

            self.client.login(username='test_user')
            response = self.submit_file(contest, problem_instance)
            self.assertEqual(403, response.status_code)

            p.status = 'ACTIVE'
            p.save()

            self.assertEqual(MailSubmission.objects.count(), 0)

            self.client.login(username='test_user')
            response = self.submit_file(contest, problem_instance)
            self.assertEqual(200, response.status_code)

            self.assertEqual(MailSubmission.objects.count(), 1)
开发者ID:papedaniel,项目名称:oioioi,代码行数:43,代码来源:tests.py


注:本文中的oioioi.participants.models.Participant.status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。