def setUpTestData(self): super().setUpTestData() self.users.update({ 'staff_solution_see_all': create_user( username='******', user_permissions=('see_private_solution',), ), }) _now = timezone.now() self.basic_solution = create_solution(problem='basic') self.private_solution = create_solution( problem='private', is_public=False, publish_on=_now - timezone.timedelta(days=100), ) self.unpublished_problem = create_problem( code='unpublished', name='Unpublished', authors=('staff_problem_edit_own',), ) self.unpublished_solution = create_solution( problem=self.unpublished_problem, is_public=False, publish_on=_now + timezone.timedelta(days=100), authors=('normal',), )
def setUpTestData(self): super().setUpTestData() self.users.update({ 'staff_problem_edit_only_all': create_user( username='******', is_staff=True, user_permissions=('edit_all_problem',), ), }) create_problem_type(name='type') self.basic_problem = create_problem( code='basic', allowed_languages=Language.objects.values_list('key', flat=True), types=('type',), authors=('normal',), testers=('staff_problem_edit_public',), ) limits = [] for lang in Language.objects.filter(common_name=Language.get_python3().common_name): limits.append( LanguageLimit( problem=self.basic_problem, language=lang, time_limit=100, memory_limit=131072, ), ) LanguageLimit.objects.bulk_create(limits) self.organization_private_problem = create_problem( code='organization_private', time_limit=2, is_public=True, is_organization_private=True, curators=('staff_problem_edit_own', 'staff_problem_edit_own_no_staff'), ) self.problem_organization = create_organization( name='problem organization', admins=('normal', 'staff_problem_edit_public'), ) self.organization_admin_private_problem = create_problem( code='org_admin_private', is_organization_private=True, organizations=('problem organization',), ) self.organization_admin_problem = create_problem( code='organization_admin', organizations=('problem organization',), )
def setUpTestData(self): super().setUpTestData() self.users.update({ 'staff_blogpost_edit_own': create_user( username='******', is_staff=True, user_permissions=('change_blogpost',), ), 'staff_blogpost_edit_all': create_user( username='******', is_staff=True, user_permissions=('change_blogpost', 'edit_all_post'), ), }) self.basic_blogpost = create_blogpost( title='basic', authors=('staff_blogpost_edit_own',), ) self.visible_blogpost = create_blogpost( title='visible', visible=True, )
def setUpTestData(self): super().setUpTestData() self.users.update({ 'staff_contest_edit_own': create_user( username='******', is_staff=True, user_permissions=('edit_own_contest',), ), 'staff_contest_see_all': create_user( username='******', user_permissions=('see_private_contest',), ), 'staff_contest_edit_all': create_user( username='******', is_staff=True, user_permissions=('edit_own_contest', 'edit_all_contest'), ), 'normal_during_window': create_user( username='******', ), 'normal_after_window': create_user( username='******', ), 'normal_before_window': create_user( username='******', ), }) _now = timezone.now() self.basic_contest = create_contest( key='basic', start_time=_now - timezone.timedelta(days=1), end_time=_now + timezone.timedelta(days=100), organizers=('superuser', 'staff_contest_edit_own'), ) self.hidden_scoreboard_contest = create_contest( key='hidden_scoreboard', start_time=_now - timezone.timedelta(days=1), end_time=_now + timezone.timedelta(days=100), is_visible=True, scoreboard_visibility=Contest.SCOREBOARD_AFTER_CONTEST, problem_label_script=''' function(n) return tostring(math.floor(n)) end ''', ) self.contest_hidden_scoreboard_contest = create_contest( key='contest_scoreboard', start_time=_now - timezone.timedelta(days=10), end_time=_now + timezone.timedelta(days=100), time_limit=timezone.timedelta(days=1), is_visible=True, scoreboard_visibility=Contest.SCOREBOARD_AFTER_CONTEST, ) self.particip_hidden_scoreboard_contest = create_contest( key='particip_scoreboard', start_time=_now - timezone.timedelta(days=10), end_time=_now + timezone.timedelta(days=100), time_limit=timezone.timedelta(days=1), is_visible=True, scoreboard_visibility=Contest.SCOREBOARD_AFTER_PARTICIPATION, ) self.visible_scoreboard_contest = create_contest( key='visible_scoreboard', start_time=_now - timezone.timedelta(days=10), end_time=_now + timezone.timedelta(days=100), time_limit=timezone.timedelta(days=1), is_visible=True, scoreboard_visibility=Contest.SCOREBOARD_VISIBLE, ) for contest_key in ('contest_scoreboard', 'particip_scoreboard', 'visible_scoreboard'): create_contest_participation( contest=contest_key, user='******', real_start=_now - timezone.timedelta(hours=1), virtual=ContestParticipation.LIVE, ) create_contest_participation( contest=contest_key, user='******', real_start=_now - timezone.timedelta(days=3), virtual=ContestParticipation.LIVE, ) create_contest_participation( contest='particip_scoreboard', user='******', real_start=_now - timezone.timedelta(days=3), virtual=ContestParticipation.LIVE, ) create_contest_participation( contest='particip_scoreboard', user='******', real_start=_now + timezone.timedelta(days=101), virtual=ContestParticipation.SPECTATE, ) self.users['normal'].profile.current_contest = create_contest_participation( contest='hidden_scoreboard', user='******', ) self.users['normal'].profile.save() self.hidden_scoreboard_contest.update_user_count() self.private_contest = create_contest( key='private', start_time=_now - timezone.timedelta(days=5), end_time=_now - timezone.timedelta(days=3), is_visible=True, is_private=True, is_organization_private=True, private_contestants=('staff_contest_edit_own',), ) self.organization_private_contest = create_contest( key='organization_private', start_time=_now + timezone.timedelta(days=3), end_time=_now + timezone.timedelta(days=6), is_visible=True, is_organization_private=True, organizations=('open',), view_contest_scoreboard=('normal',), ) self.private_user_contest = create_contest( key='private_user', start_time=_now - timezone.timedelta(days=3), end_time=_now + timezone.timedelta(days=6), is_visible=True, is_private=True, )
def setUpTestData(self): super().setUpTestData() self.users.update({ 'staff_contest_edit_own': create_user( username='******', is_staff=True, user_permissions=('edit_own_contest', ), ), 'staff_contest_see_all': create_user( username='******', user_permissions=('see_private_contest', ), ), 'staff_contest_edit_all': create_user( username='******', is_staff=True, user_permissions=('edit_own_contest', 'edit_all_contest'), ), }) _now = timezone.now() self.basic_contest = create_contest( key='basic', start_time=_now - timezone.timedelta(days=1), end_time=_now + timezone.timedelta(days=100), organizers=('superuser', 'staff_contest_edit_own'), ) self.hidden_scoreboard_contest = create_contest( key='hidden_scoreboard', start_time=_now - timezone.timedelta(days=1), end_time=_now + timezone.timedelta(days=100), is_visible=True, hide_scoreboard=True, problem_label_script=''' function(n) return tostring(math.floor(n)) end ''', ) self.users[ 'normal'].profile.current_contest = create_contest_participation( contest='hidden_scoreboard', user='******', ) self.users['normal'].profile.save() self.hidden_scoreboard_contest.update_user_count() self.private_contest = create_contest( key='private', start_time=_now - timezone.timedelta(days=5), end_time=_now - timezone.timedelta(days=3), is_visible=True, is_private=True, is_organization_private=True, private_contestants=('staff_contest_edit_own', ), ) self.organization_private_contest = create_contest( key='organization_private', start_time=_now + timezone.timedelta(days=3), end_time=_now + timezone.timedelta(days=6), is_visible=True, is_organization_private=True, organizations=('open', ), view_contest_scoreboard=('normal', ), ) self.private_user_contest = create_contest( key='private_user', start_time=_now - timezone.timedelta(days=3), end_time=_now + timezone.timedelta(days=6), is_visible=True, is_private=True, )
def setUpTestData(self): super().setUpTestData() self.users.update({ 'staff_submission_view_all': create_user( username='******', is_staff=True, user_permissions=('view_all_submission', ), ), }) self.basic_submission = Submission.objects.create( user=self.users['normal'].profile, problem=create_problem(code='basic'), language=Language.get_python3(), result='AC', status='D', case_points=99, case_total=100, memory=20, locked_after=None, ) self.full_ac_submission = Submission.objects.create( user=self.users['normal'].profile, problem=create_problem(code='full_ac'), language=Language.get_python3(), result='AC', status='D', case_points=1, case_total=1, ) self.full_ac_submission_source = SubmissionSource.objects.create( submission=self.full_ac_submission, source='', ) self.locked_submission = Submission.objects.create( user=self.users['normal'].profile, problem=create_problem(code='locked'), language=Language.get_python3(), result='WA', status='D', case_points=1, case_total=1, locked_after=timezone.now() - timezone.timedelta(days=100), ) self.future_locked_submission = Submission.objects.create( user=self.users['normal'].profile, problem=create_problem(code='future_locked'), language=Language.get_python3(), result='WA', status='D', case_points=1, case_total=1, locked_after=timezone.now() + timezone.timedelta(days=100), ) self.ie_submission = Submission.objects.create( user=self.users['superuser'].profile, problem=create_problem( code='ie', is_public=True, ), language=Language.get_python3(), result='IE', status='IE', memory=None, ) # jump down the rabbit hole to attach a contest submission problem = create_problem(code='queued') contest = create_contest(key='queued') self.queued_submission = Submission.objects.create( user=self.users['superuser'].profile, problem=problem, language=Language.get_python3(), contest_object=contest, case_points=50, case_total=100, ) self.queued_contest_submission = ContestSubmission.objects.create( submission=self.queued_submission, problem=create_contest_problem(problem=problem, contest=contest, partial=False), participation=create_contest_participation(contest=contest, user='******'), )