Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix raw problem view when access directly #1799

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion judge/views/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ def get_context_data(self, **kwargs):
context['problem_name'] = self.object.name
context['url'] = self.request.build_absolute_uri()
context['description'] = self.object.description
context['math_engine'] = self.request.profile.math_engine
if self.request.profile is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. Why do we need to define a math_engine here in the first place? What's wrong with using MATH_ENGINE in https://github.com/DMOJ/online-judge/blob/master/judge/template_context.py#L122?

cc @int-y1.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that we don't use RequestContext when rendering PDFs and the math engine depends on the PDF rendering backend?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess what I meant is why are we using math_engine here instead of changing everything to MATH_ENGINE. In this view, RequestContext is used, so we can get rid of this line (which isn't correct as there's more logic for auto in https://github.com/DMOJ/online-judge/blob/master/judge/template_context.py#L122 than in here). In ProblemPDFView we can rename math_engine to MATH_ENGINE.

context['math_engine'] = self.request.profile.math_engine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might still cause error 500 when the user set self.request.profile.math_engine to auto.

else:
context['math_engine'] = "jax"
return context

def get(self, request, *args, **kwargs):
Expand Down