Example #1
0
 def content_link(self, instance):
     if instance.id is not None:
         href = reverse('contest_attachment',
                     kwargs={'contest_id': str(instance.contest.id),
                             'attachment_id': str(instance.id)})
         return make_html_link(href, instance.content.name)
     return None
Example #2
0
    def checker_link(self, instance):
        if not instance.exe_file:
            return _("No checker for this task.")

        href = reverse('oioioi.programs.views.download_checker_exe_view',
            kwargs={'checker_id': str(instance.id)})
        return make_html_link(href, instance.exe_file.name.split('/')[-1])
Example #3
0
 def input_file_link(self, instance):
     if instance.id is not None:
         href = reverse('oioioi.programs.views.download_input_file_view',
                 kwargs={'test_id': str(instance.id)})
         return make_html_link(href,
                               instance.input_file.name.split('/')[-1])
     return None
Example #4
0
 def output_file_link(self, instance):
     if instance.id is not None:
         href = reverse('download_output_file',
                 kwargs={'test_id': instance.id})
         return make_html_link(href,
                               instance.output_file.name.split('/')[-1])
     return None
Example #5
0
def insert_existing_submission_link(env, **kwargs):
    """Add comment to some existing submission with link to submission view
       of present submission.

       Used ``environ`` keys:
           * ``extra_args`` dictionary with ``submission_report`` object
           * ``contest_id``
           * ``submission_id``
    """
    if 'submission_report_id' not in env['extra_args']:
        logger.info('No submission_report given to generate link')
        return env

    submission_report_id = env['extra_args']['submission_report_id']
    submission_report = SubmissionReport.objects.get(id=submission_report_id)
    dst_submission = submission_report.submission
    src_submission = Submission.objects.get(id=env['submission_id'])
    href = reverse('submission', kwargs={'submission_id': dst_submission.id,
                                         'contest_id': env['contest_id']})
    html_link = make_html_link(href, _("submission report") + ": " +
                               str(dst_submission.id))
    test_names = ', '.join(env.get('test_results', {}).keys())

    # Note that the comment is overwritten by safe string.
    src_submission.comment = \
        "This is an internal submission created after someone requested to " \
        "generate user output on tests: %s, related to %s" % (test_names,
        html_link)
    src_submission.save()

    return env
Example #6
0
 def regeneration_link(self, instance):
     return make_html_link(
         reverse('balloons_access_regenerate',
                 kwargs={'contest_id': instance.contest.id}),
         _("Regenerate key"),
         'POST'
     )
Example #7
0
 def package_link(self, instance):
     if instance.id is not None:
         href = reverse('oioioi.testspackages.views.test_view',
                 kwargs={'package_id': instance.id, 'contest_id':
                     instance.problem.contest.id})
         return make_html_link(href, instance.package.file.name)
     return None
Example #8
0
 def package(self, instance):
     if instance.package_file:
         href = reverse(
                 'oioioi.problems.views.download_problem_package_view',
                 kwargs={'package_id': str(instance.id)})
         return make_html_link(href, instance.package_file)
     return None
Example #9
0
 def content_link(self, instance):
     if instance.id is not None:
         href = reverse(
             'oioioi.problems.views.show_problem_attachment_view',
             kwargs={'attachment_id': str(instance.id)})
         return make_html_link(href, instance.content.name)
     return None
Example #10
0
 def user_login(self, instance):
     if not instance.user:
         return ''
     return make_html_link(
             reverse('user_info', kwargs={
                     'contest_id': instance.round.contest.id,
                     'user_id': instance.user.id}),
             instance.user.username)
Example #11
0
 def package(self, instance):
     problem_package = ProblemPackage.objects \
             .filter(problem=instance.problem).first()
     if problem_package and problem_package.package_file:
         href = reverse('download_package',
                        kwargs={'package_id': str(problem_package.id)})
         return make_html_link(href, problem_package.package_file)
     return None
Example #12
0
 def user_full_name(self, instance):
     if not instance.user:
         return ''
     return make_html_link(
             reverse('user_info', kwargs={
                     'contest_id': instance.contest.id,
                     'user_id': instance.user.id}),
             instance.user.get_full_name())
Example #13
0
 def related_submission(self, instance):
     if not instance.submission:
         return ''
     contest = instance.submission.problem_instance.contest
     href = reverse('submission',
                    kwargs={'contest_id': contest.id,
                            'submission_id': instance.submission.id})
     return make_html_link(href, instance.submission.id)
Example #14
0
    def checker_link(self, instance):
        if not instance.exe_file:
            return _("No checker for this task.")

        if instance.id is not None:
            href = reverse('download_checker_file',
                kwargs={'checker_id': str(instance.id)})
            return make_html_link(href, instance.exe_file.name.split('/')[-1])
        return None
Example #15
0
 def access_link(self, instance):
     if instance.access_key:
         url = reverse('balloons_access_set_cookie', kwargs={
             'contest_id': instance.contest.id,
             'access_key': instance.access_key
         })
         return make_html_link(url, url)
     else:
         return _("Not yet generated")
Example #16
0
    def state_with_link(self, instance):
        if not instance.report:
            return instance.state

        if instance.id is not None:
            href = reverse('download_report',
                           kwargs={'pg_id': instance.id,
                                   'contest_id': instance.contest.id})
            return make_html_link(href, instance.state)
        return None
Example #17
0
 def access_link(self, instance):
     if instance.access_key:
         url = reverse(
             'balloons_access_set_cookie',
             kwargs={
                 'contest_id': instance.contest.id,
                 'access_key': instance.access_key,
             },
         )
         return make_html_link(url, url)
     else:
         return _("Not yet generated")
Example #18
0
 def submission_link(self, instance):
     if instance.submission is None:
         return ''
     reverse_kwargs = {
         'contest_id': instance.submission.problem_instance.contest_id,
         'submission_id': instance.submission_id,
     }
     return make_html_link(
         reverse('submission', kwargs=reverse_kwargs),
         '%d (%s)' % (instance.submission_id,
             force_text(instance.submission.problem_instance))
     )
Example #19
0
 def submission_link(self, instance):
     if instance.submission is None:
         return ''
     reverse_kwargs = {
         'contest_id': instance.submission.problem_instance.contest_id,
         'submission_id': instance.submission_id,
     }
     return make_html_link(
         reverse('submission', kwargs=reverse_kwargs),
         '%d (%s)' % (instance.submission_id,
             force_text(instance.submission.problem_instance))
     )
Example #20
0
 def user_login(self, instance):
     if not instance.user:
         return ''
     return make_html_link(
         reverse(
             'user_info',
             kwargs={
                 'contest_id': instance.round.contest.id,
                 'user_id': instance.user.id,
             },
         ),
         instance.user.username,
     )
Example #21
0
 def user_full_name(self, instance):
     if not instance.user:
         return ''
     return make_html_link(
         reverse(
             'user_info',
             kwargs={
                 'contest_id': instance.contest.id,
                 'user_id': instance.user.id
             },
         ),
         instance.user.get_full_name(),
     )
Example #22
0
def insert_existing_submission_link(env, src_submission, **kwargs):
    """Add comment to some existing submission with link to submission view
    of present submission.

    Used ``environ`` keys:
        * ``extra_args`` dictionary with ``submission_report`` object
        * ``contest_id``
        * ``submission_id``
    """
    if 'submission_report_id' not in env['extra_args']:
        logger.info('No submission_report given to generate link')
        return env

    submission_report_id = env['extra_args']['submission_report_id']
    submission_report = SubmissionReport.objects.get(id=submission_report_id)
    dst_submission = submission_report.submission
    href = reverse(
        'submission',
        kwargs={
            'submission_id': dst_submission.id,
            'contest_id': env['contest_id']
        },
    )
    html_link = make_html_link(
        href,
        _("submission report") + ": " + str(dst_submission.id))
    test_names = ', '.join(list(env.get('test_results', {}).keys()))

    # Note that the comment is overwritten by safe string.
    src_submission.comment = (
        "This is an internal submission created after someone requested to "
        "generate user output on tests: %s, related to %s" %
        (test_names, html_link))
    src_submission.save()

    return env
Example #23
0
 def submission_link(self, instance):
     return make_html_link(reverse('submission',
         kwargs=dict(
             contest_id=instance.submission.problem_instance.contest_id,
             submission_id=instance.submission_id)),
         instance.submission_id)
Example #24
0
 def _get_link(self, caption, app, *args, **kwargs):
     url = reverse(app, args=args, kwargs=kwargs)
     return make_html_link(url, caption)
Example #25
0
 def output_file_link(self, instance):
     if instance.id is not None:
         href = reverse('download_output_file', kwargs={'test_id': instance.id})
         return make_html_link(href, instance.output_file.name.split('/')[-1])
     return None
Example #26
0
 def package(self, instance):
     if instance.package_file:
         href = reverse('download_package',
                        kwargs={'package_id': str(instance.id)})
         return make_html_link(href, instance.package_file)
     return None
Example #27
0
 def file_link(self, instance):
     href = reverse('oioioi.sinolpack.views.download_extra_file_view',
                    kwargs={'file_id': str(instance.id)})
     return make_html_link(href, instance.name)
Example #28
0
 def output_file_link(self, instance):
     href = reverse('oioioi.programs.views.download_output_file_view',
                    kwargs={'test_id': instance.id})
     return make_html_link(href, instance.output_file.name.split('/')[-1])
Example #29
0
 def participants_link(self, instance):
     return make_html_link(instance.get_participants_url(),
                           _("Participants"))
Example #30
0
 def file_link(self, instance):
     if instance.id is not None:
         href = reverse('download_extra_file',
                        kwargs={'file_id': str(instance.id)})
         return make_html_link(href, instance.name)
     return None
Example #31
0
 def bans(self, obj):
     return make_html_link(reverse('oioioiadmin:forum_ban_changelist', ),
                           _("Bans"))
Example #32
0
 def participants_link(self, instance):
     return make_html_link(instance.get_participants_url(),
                           _("Participants"))
Example #33
0
 def postal_code_link(self, instance):
     url = reverse('oioioiadmin:oi_school_changelist') + '?' + \
             urllib.urlencode({'q': instance.postal_code})
     return make_html_link(url, instance.postal_code)
Example #34
0
 def name_link(self, instance):
     href = self._problem_site_href(instance)
     return make_html_link(href, instance.problem.name)
Example #35
0
 def submission_link(self, instance):
     return make_html_link(reverse('submission',
         kwargs=dict(
             contest_id=instance.submission.problem_instance.contest_id,
             submission_id=instance.submission_id)),
         instance.submission_id)
Example #36
0
 def group_link(self, instance):
     return make_html_link(
         reverse('oioioiadmin:similarsubmits_'
                 'submissionssimilaritygroup_change',
         args=[instance.group_id]),
         instance.group_id)
Example #37
0
 def add_category(self, obj):
     return make_html_link(reverse('oioioiadmin:forum_category_add', ), '+')
Example #38
0
 def short_name_link(self, instance):
     href = self._problem_change_href(instance)
     return make_html_link(href, instance.short_name)
Example #39
0
 def content_link(self, instance):
     href = reverse("oioioi.problems.views.show_statement_view", kwargs={"statement_id": str(instance.id)})
     return make_html_link(href, instance.content.name)
Example #40
0
 def _get_link(self, caption, app, *args, **kwargs):
     url = reverse(app, args=args, kwargs=kwargs)
     return make_html_link(url, caption)
Example #41
0
 def output_file_link(self, instance):
     if instance.id is not None:
         href = reverse('oioioi.programs.views.download_output_file_view',
                 kwargs={'test_id': instance.id})
         return make_html_link(href, _("out"))
     return None
Example #42
0
 def output_file_link(self, instance):
     href = reverse('oioioi.programs.views.download_output_file_view',
             kwargs={'test_id': instance.id})
     return make_html_link(href, instance.output_file.name.split('/')[-1])
Example #43
0
 def thread_link(self, obj):
     return make_html_link(obj.get_in_thread_url(), obj.thread.name)
Example #44
0
 def regeneration_link(self, instance):
     return make_html_link(
         reverse('balloons_access_regenerate',
                 kwargs={'contest_id': instance.contest.id}),
         _("Regenerate key"), 'POST')
Example #45
0
 def posts_admin(self, obj):
     return make_html_link(reverse('oioioiadmin:forum_post_changelist', ),
                           _("Posts admin view"))
Example #46
0
 def content_link(self, instance):
     if instance.id is not None:
         href = reverse('show_problem_attachment',
                        kwargs={'attachment_id': str(instance.id)})
         return make_html_link(href, instance.content.name)
     return None
Example #47
0
 def bans(self, obj):
     return make_html_link(reverse('oioioiadmin:forum_ban_changelist', ),
                           _("Bans"))
Example #48
0
 def content_link(self, instance):
     href = reverse('oioioi.problems.views.show_problem_attachment_view',
                    kwargs={'attachment_id': str(instance.id)})
     return make_html_link(href, instance.content.name)
Example #49
0
 def content_link(self, instance):
     if instance.id is not None:
         href = reverse('oioioi.problems.views.show_statement_view',
                        kwargs={'statement_id': str(instance.id)})
         return make_html_link(href, instance.content.name)
     return None
Example #50
0
 def group_link(self, instance):
     return make_html_link(
         reverse('oioioiadmin:similarsubmits_'
                 'submissionssimilaritygroup_change',
         args=[instance.group_id]),
         instance.group_id)
Example #51
0
 def file_link(self, instance):
     href = reverse('oioioi.sinolpack.views.download_extra_file_view',
         kwargs={'file_id': str(instance.id)})
     return make_html_link(href, instance.name)
Example #52
0
def make_list_elem(elem, text=None):
    if not text:
        text = elem.name
    return '<li>%s</li>' % make_html_link(elem.get_admin_url(), text)
Example #53
0
 def logo_link(self, instance):
     if instance.id is not None:
         href = reverse('oioioi.contestlogo.views.logo_image_view',
                        kwargs={'contest_id': str(instance.contest.id)})
         return make_html_link(href, instance.filename)
     return None
Example #54
0
 def short_name_link(self, instance):
     href = self._problem_change_href(instance)
     return make_html_link(href, instance.short_name)
Example #55
0
 def file_link(self, instance):
     if instance.id is not None:
         href = reverse('download_extra_file',
             kwargs={'file_id': str(instance.id)})
         return make_html_link(href, instance.name)
     return None
Example #56
0
 def content_link(self, instance):
     href = reverse('oioioi.contests.views.contest_attachment_view',
                 kwargs={'contest_id': str(instance.contest),
                         'attachment_id': str(instance.id)})
     return make_html_link(href, instance.content.name)
Example #57
0
 def input_file_link(self, instance):
     if instance.id is not None:
         href = reverse('oioioi.programs.views.download_input_file_view',
                        kwargs={'test_id': instance.id})
         return make_html_link(href, _("in"))
     return None
Example #58
0
 def postal_code_link(self, instance):
     url = reverse('oioioiadmin:oi_school_changelist') + '?' + \
             six.moves.urllib.parse.urlencode({'q': instance.postal_code})
     return make_html_link(url, instance.postal_code)
Example #59
0
 def output_file_link(self, instance):
     if instance.id is not None:
         href = reverse('download_output_file',
                        kwargs={'test_id': instance.id})
         return make_html_link(href, _("out"))
     return None