-
Notifications
You must be signed in to change notification settings - Fork 165
Description
For the breadcrumbs at the top of the page, we want elements to be clickable links unless the user is already on the page that we would link to. Currently, we typically implement this with extra state passed to the template:
EvaP/evap/staff/templates/staff_course_base.html
Lines 15 to 19 in a68bace
| {% if disable_breadcrumb_course %} | |
| <li class="breadcrumb-item">{{ course.name }}</li> | |
| {% else %} | |
| <li class="breadcrumb-item"><a href="{% url 'staff:course_edit' course.id %}">{{ course.name }}</a></li> | |
| {% endif %} |
EvaP/evap/grades/templates/grades_course_base.html
Lines 8 to 12 in a68bace
| {% if disable_breadcrumb_course %} | |
| <li class="breadcrumb-item">{{ course.name }}</li> | |
| {% else %} | |
| <li class="breadcrumb-item"><a href="{% url 'grades:course_view' course.id %}">{{ course.name }}</a></li> | |
| {% endif %} |
EvaP/evap/staff/templates/staff_semester_base.html
Lines 14 to 18 in a68bace
| {% if disable_breadcrumb_semester %} | |
| <li class="breadcrumb-item">{{ semester.name }}</li> | |
| {% else %} | |
| <li class="breadcrumb-item"><a href="{% url 'staff:semester_view' semester.id %}">{{ semester.name }}</a></li> | |
| {% endif %} |
and one instance is being added in #2599 in evap/staff/templates/staff_questionnaire_base.html
This requires juggling additional state. It should be possible to build a custom django template block tag that is just passed the target URL and then selectively adds the HTML anchor only if the user isn't already on this page.
Some more context:
- Related stackoverflow question for a similar problem: https://stackoverflow.com/questions/10263482/compare-request-path-with-a-reversed-url-in-django-template
- Related discussion: https://github.com/e-valuation/EvaP/pull/2599/changes#r2716402428