def get_context_data(self, **kwargs): data = super().get_context_data(**kwargs) self.template.template_code_as_html = transform_code_to_html( self.template.template_code, self.template.language) self.template.grader_code_as_html = transform_code_to_html( self.template.grader_code, self.template.language) data["template"] = self.template return data
def process_check_report_detail(self, report, solution_id, case_id): ft = list( filter( lambda x: x.get("solution") == solution_id and x.get("case_id") == case_id, report["tasks"])) if len(ft) == 0: raise Http404 dt = ft[0] # TODO: solution permission check solution = Program.objects.get(id=solution_id) return [("Source", solution.name), ("Language", solution.get_lang_display()), ("Test #", dt.get("case_number", "")), ("Verdict", dt.get("verdict", "")), ("Time", "%d ms" % round(dt.get("time", 0) * 1000)), ("Memory", "%d MB" % round(dt.get("memory", 0))), ("Exit Code", dt.get("exit_code", 0)), ("Signal", dt.get("signal", 0)), ("Input", dt.get("input", "")), ("Output", dt.get("output", "")), ("Answer", dt.get("answer", "")), ("Stderr", dt.get("stderr", "")), ("Checker's Comment", dt.get("checker_comment", "")), ("Checker Exitcode", dt.get("checker_exit_code", "")), ("Code", transform_code_to_html(solution.code, solution.lang))]
def get_context_data(self, **kwargs): data = super().get_context_data(**kwargs) try: paste = Paste.objects.get(fingerprint=self.kwargs["pk"]) except: raise Http404 if not self.check_permission(paste, self.request.user): raise PermissionDenied paste.code_as_html = transform_code_to_html(paste.code, paste.lang) data["paste"] = paste return data
def code_as_html(self): return transform_code_to_html(self.code, self.lang)
def get_context_data(self, **kwargs): data = super().get_context_data(**kwargs) data["program"] = self.program self.program.code_as_html = transform_code_to_html( self.program.code, self.program.lang) return data