fix: session calendar month navigation not working on course detail page#903
Conversation
WalkthroughThe changes add inline onclick event handlers to calendar navigation buttons and update the calendar data fetch URL to use Django's URL reversal instead of a hard-coded path in the courses detail template. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the session calendar's previous/next month navigation buttons on the course detail page were non-functional. The issue was caused by missing initial onclick handlers and an incorrect hardcoded fetch URL that didn't include the language prefix.
Changes:
- Added initial
onclickhandlers to prev/next month buttons using Django template variables for the year and month values - Fixed the fetch URL in
loadCalendar()function to use Django's{% url %}template tag instead of a hardcoded path, ensuring the language prefix is included
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web/templates/courses/detail.html`:
- Around line 444-454: Replace the inline onclick attributes on the prev/next
buttons in the template (elements with ids prev-month-btn and next-month-btn)
with data-year and data-month attributes initialized from {{ prev_month }} / {{
next_month }}, remove any code that calls setAttribute to update onclick, and
instead add a one-time DOM event listener that calls the existing
loadCalendar(year, month) using parseInt(this.dataset.year) and
parseInt(this.dataset.month); update the part of the JS that currently updates
onclick (in loadCalendar's response handling) to set dataset.year/dataset.month
on the two buttons (or reconstruct them from response.prev_month/next_month)
rather than changing onclick strings.
Related issues
Fixes #902
Checklist
Problem
The session calendar's previous/next month navigation buttons on the course detail page did not work. Clicking the left or right arrows had no visible effect - the calendar remained stuck on the current month.
Solution
onclickhandlers: The previous/next month buttons now have initialonclickhandlers using Django template variables, so they work on first page load/courses/.../calendar/) to Django's{% url %}template tag, which correctly includes the/en/language prefix and prevents silent 404 errorsScreenshots
view attached screen recording as it shows before and after
calendar_issue_fix.mp4
Summary by CodeRabbit