Hardcoded /login URLs do not work with FORCE_SCRIPT_NAME
markkuriekkinen opened this issue · 1 comments
When the mooc-grader installation uses the FORCE_SCRIPT_NAME
Django setting to serve all mooc-grader views behind a common URL prefix, then the system breaks down due to the hardcoded /login
URL in a couple of places. The code should use the Django URL resolvers to form the URLs instead of hardcoding the URL strings.
This affects Tampere University since they use FORCE_SCRIPT_NAME
. Their graders are supposed to be served from URL paths starting /graderA
, on another server /graderE
and so on. The prefix should affect all URLs of the MOOC-Grader. The URL path prefix is needed when the URL domain name is shared between multiple servers.
Hardcoded /login
is used here:
Line 11 in 1f5b163
When Tampere hardcodes
login_required_base(redirect_url="/graderA/login?referer={url}")
there, it works.Note that
reverse()
doesn't seem to work in the module-level code since Django has not set up everything when the module is loaded and the module-level code is executed.https://docs.djangoproject.com/en/3.2/ref/urlresolvers/#reverse
Aalto internal ticket:
https://rt.cs.aalto.fi/Ticket/Display.html?id=21827
At least, fixing the template should be trivial since it can use the normal url template tag:
https://docs.djangoproject.com/en/3.2/ref/templates/builtins/#url