Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring: abstract entity template #1446

Closed
gythaogg opened this issue Nov 25, 2024 · 0 comments · Fixed by #1449 or #1428
Closed

refactoring: abstract entity template #1446

gythaogg opened this issue Nov 25, 2024 · 0 comments · Fixed by #1449 or #1428
Labels
refactor Clean-up or restructuring of code for readability/speed/simplicity

Comments

@gythaogg
Copy link
Contributor

object_table template is included in the abstract entity detail template
<div class="card-body">{% include "generic/partials/object_table.html" %}</div>

To customise the left panel of the detail view we can create custom templates for our entities (such as person_table, place_table, etc)- but in order to include the custom templates we need to override the abstract entity detail template as well. Instead could we select this object_table template by default and use a more specific template when available, such as person_table or something?

@gythaogg gythaogg added the refactor Clean-up or restructuring of code for readability/speed/simplicity label Nov 25, 2024
b1rger added a commit that referenced this issue Nov 25, 2024
The template_list templatetag returns a list of templatenames, based on
the MRO of the model passed and a suffix. So instead of hardcoding the
`object_table.html` template, we now use this list to look for matching
templates, which makes it easier to overload the template.
Given that all the models inherit at some point from `genericmodel`, the
`object_table.html` template is now being replaced by a
`genericmodel_card_table.html` template.
Using this template_list approach, it is probably possible to drop some
of the templates alltogether and make the template inheritance chain way
less complex.

Closes: #1446
@gythaogg gythaogg linked a pull request Nov 26, 2024 that will close this issue
b1rger added a commit that referenced this issue Nov 27, 2024
The template_list templatetag returns a list of templatenames, based on
the MRO of the model passed and a suffix. So instead of hardcoding the
`object_table.html` template, we now use this list to look for matching
templates, which makes it easier to overload the template.
Given that all the models inherit at some point from `genericmodel`, the
`object_table.html` template is now being replaced by a
`genericmodel_card_table.html` template.
Using this template_list approach, it is probably possible to drop some
of the templates alltogether and make the template inheritance chain way
less complex.

Closes: #1446
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Clean-up or restructuring of code for readability/speed/simplicity
Projects
None yet
1 participant