<commit_before>from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.core.paginator import PageNotAnInteger, EmptyPage
from django.core.urlresolvers import reverse
from django.http import Http404, HttpResponseRedirect, HttpResponseBadRequest
from django.shortcuts import render_to_response
from django.template import RequestContext
from judge.highlight_code import highlight_code
from judge.models import Problem, Submission, SubmissionTestCase, Profile
from judge.utils.diggpaginator import DiggPaginator
from judge.views import get_result_table
from judge import event_poster as event


def user_completed_codes(profile):
    return list(Submission.objects.filter(user=profile, result='AC').values_list('problem__code', flat=True).distinct())


def submission_source(request, sub_id):
    try:
        submission = Submission.objects.get(id=int(sub_id))

        if not request.user.is_authenticated():
            raise PermissionDenied()

        if not request.user.profile.is_admin and submission.user != request.user.profile and \
                not Submission.objects.filter(user=request.user.profile, result='AC', problem__code=submission.problem.code).exists():
            raise PermissionDenied()

        return render_to_response('submission_src.jade',
                                  {
                                      'submission': submission,
                                      'source': highlight_code(submission.source, submission.language.pygments),
                                      'title': 'Submission %s of %s by %s' % (
                                          submission.id, submission.problem.name, submission.user.user.username)
                                  },
                                  context_instance=RequestContext(request))
    except ObjectDoesNotExist:
        raise Http404()


def submission_status(request, code):
    try:
        submission = Submission.objects.get(id=int(code))

        if not request.user.is_authenticated():
            raise PermissionDenied()

        if not request.user.profile.is_admin and submission.user != request.user.profile and \
                not Submission.objects.filter(user=request.user.profile, result='AC', problem__code=submission.problem.code).exists():
            raise PermissionDenied()
        test_cases = SubmissionTestCase.objects.filter(submission=submission)
        return render_to_response('submission_status.jade',
                                  {'submission': submission, 'test_cases': test_cases,<commit_msg>Applied same change to submission_status view.<commit_after>from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.core.paginator import PageNotAnInteger, EmptyPage
from django.core.urlresolvers import reverse
from django.http import Http404, HttpResponseRedirect, HttpResponseBadRequest
from django.shortcuts import render_to_response
from django.template import RequestContext
from judge.highlight_code import highlight_code
from judge.models import Problem, Submission, SubmissionTestCase, Profile
from judge.utils.diggpaginator import DiggPaginator
from judge.views import get_result_table
from judge import event_poster as event


def user_completed_codes(profile):
    return list(Submission.objects.filter(user=profile, result='AC').values_list('problem__code', flat=True).distinct())


def submission_source(request, sub_id):
    try:
        submission = Submission.objects.get(id=int(sub_id))

        if not request.user.is_authenticated():
            raise PermissionDenied()

        if not request.user.profile.is_admin and submission.user != request.user.profile and \
                not Submission.objects.filter(user=request.user.profile, result='AC', problem__code=submission.problem.code).exists():
            raise PermissionDenied()

        return render_to_response('submission_src.jade',
                                  {
                                      'submission': submission,
                                      'source': highlight_code(submission.source, submission.language.pygments),
                                      'title': 'Submission %s of %s by %s' % (
                                          submission.id, submission.problem.name, submission.user.user.username)
                                  },
                                  context_instance=RequestContext(request))
    except ObjectDoesNotExist:
        raise Http404()


def submission_status(request, code):
    try:
        submission = Submission.objects.get(id=int(code))

        if not request.user.is_authenticated():
            raise PermissionDenied()

        if not request.user.profile.is_admin and submission.user != request.user.profile and \
                not Submission.objects.filter(user=request.user.profile, result='AC', problem__code=submission.problem.code).exists():
            raise PermissionDenied()
        return render_to_response('submission_status.jade',
                                  {'submission': submission, 'test_cases': submission.test_cases.all(),
{'fraction_non_alphanumeric': 0.08434442270058709, 'fraction_numerical': 0.0023483365949119373, 'mean_word_length': 2.6982633863965266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1971767', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1233, 'n_words': 276}