本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)