Fix broken links when cs_sole_course is set #110
No reviewers
Labels
No labels
accessibility
backport to lts
bug
code
critical
cygwin
documentation
duplicate
error reporting
external
feature
feedback
good first issue
help wanted
infrastructure
invalid
investigate
language spec
logs
lti
lts only
mac
maybe
qtype:bigbox
qtype:checkoff
qtype:expression
qtype:fileupload
qtype:multiexpression
qtype:multiplechoice
qtype:number
qtype:pythoncode
qtype:pythonic
qtype:pythonliteral
qtype:richtext
qtype:smallbox
question
question types
sandbox
security
syntax highlighting
ui/ux
wontfix
wsl
No milestone
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
catsoop/catsoop!110
Loading…
Reference in a new issue
No description provided.
Delete branch "almonds/catsoop:main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
These diffs fix the broken settings links and breadcrumb _util links I mentioned a while ago. I've tested the following on 3.12 and 3.14, with and without
cs_sole_courseset:cs_course(or do start with it, as before)catsoop.this_pathin session storage)A couple causes of the bug were from not checking if
cs_sole_coursewas set. For the other causes, while the original code checked ifcs_sole_coursewas set before popping the first element of the paths, it did not check if the first element of the path wascs_course, so it would remove'_util'by accident, for example.I fixed & moved the
_get_base_urlhelper fromlogin.pytodispatch.py, and I imported it inlogin.pyand in the default handler. (If there's a better place for a helper function that's used in multiple spots, then it could be moved there instead.) The patch should also fix SSO, LDAP3, and OpenID, since those three actually import_get_base_urlfrom the simple login auth, but I did not test these explicitly.I split this PR into two commits, because I noticed the other PRs also affect the default handler. In that file, the session storage was originally not saving the correct URL that accounts for a sole course. Running
blackon the handler changes some other parts of that file, but I did not commit them for this PR, to reduce confusion.While these changes work smoothly for logging in/out and navigating settings, I suspect there are other forms of the same bug hidden somewhere, e.g., for submitting answers to questions. I could look into it, though my personal use case doesn't actually use questions, just logins/settings, and I'm unlikely to have time anytime soon.
cs_sole_courseis set 689191aff4cs_sole_courseis set 33e084258eI only tested this for production instances. Today I notice in my other courses, they aren't serving css, js, or images for local testing, because the URL is missing the
cs_course(e.g.,http://localhost:7667/_static/css/calendar.v0.cssinstead ofhttp://localhost:7667/_static/iesj26/css/calendar.v0.css). I'll change this PR to a WIP, and see if I can figure out what's going on by the end of the day.Fix broken links whento WIP: Fix broken links whencs_sole_courseis setcs_sole_courseis setPretty sure it was because an "and" should have been an "or", oops... I'll test this on a production instance with static resources before removing the WIP.
Damn. This is happening because
['_static', cs_course, 'img', 'blah.jpg']should apparently have thecs_coursebit removed, for['_static', 'img', 'blah.jpg'], and my commits didn't expect that. Looking into it...COURSE/for local & production 0da0590848Turns out the "or" half wasn't necessary in that code branch. (It is necessary in the other branches.) I tested a local instance (locally), a production instance (locally), and a production instance (remote), when
cs_sole_courseis set versus not set:<img src='COURSE/image.jpg'>when/__STATIC__/image.jpgexists<img src='COURSE/img/image.jpg'>when/__STATIC__/img/image.jpgexists<img src='COURSE/test/image.jpg'>when/test/__STATIC__/image.jpgexists<img src='CURRENT/image.jpg'>on the/testpage when/test/__STATIC__/image.jpgexists(
<img src='CURRENT/img/image.jpg'>on the/testpage when/test/__STATIC__/img/image.jpgexists does not work, however, it did not work in the first place, and it looked like I would have to fix that bug elsewhere, so this is fine with me.)All the URLs for the settings link that this PR originally set out to fix still work, so I think this is the one.
WIP: Fix broken links whento Fix broken links whencs_sole_courseis setcs_sole_courseis setSorry for the long delay here, @almonds . I took a look through, and this all looks good to me! Happy to merge this in. Do you want to add yourself to the
CONTRIBUTORS.mdfile as well before I merge it in?Sure thing, one sec
Merged! Big thanks for this! :)