First attempt at breadcrumbs.#2738
Conversation
| <li class="breadcrumb-item">{{ evaluation.course.name }}</li> | ||
| {% url 'staff:evaluation_edit' evaluation.id as eval_edit_id %} | ||
| {% create_breadcrumb eval_edit_id %} | ||
| {{ evaluation.course.name }} |
There was a problem hiding this comment.
If we need this often, could we have two block tags, one breadcrumb_url that forwards all inputs for url and then uses the output as the link target, and one breadcrumb that takes the link target directly?
Code-wise, one could call the other, so it should just be one more line of code in python, but we could skip the additional line in each template to define the URL (and we don't have to think about a variable name -- eval_edit_id is not great, but coming up with a good name is also hard here).
What do you think about this? (cc @niklasmohrin)
There was a problem hiding this comment.
Makes sense to me
Some time ago, I was thinking about something more radical even, but I am not sure if it works for all cases. (probably not)
Just give the object directly to the breadcrumb helper and let the helper do
if isinstance(obj, Evaluation):
url = reverse("staff:evaluation_view", ...)
elif isinstance(obj, Course):
url = ...and so on. Probably not exactly like this, but similar (we can probably use a match statement to make it a lot nicer).
There was a problem hiding this comment.
Would be possible, however, would probably have to come with some interesting behavior for many of the edge-cases for breadcrumbs. I will look into if it is a nice solution, first intuition is no though.
niklasmohrin
left a comment
There was a problem hiding this comment.
What do you think about #2738 (comment) ?
First attempt at doing the link-if-not-self-breadcrumbs from issue #2642 .