Skip to content

Commit 966361d

Browse files
committed
Add extensibility hooks and method for entity instance name
Introduce new template blocks for custom JS/CSS in the header and footer to enhance layout flexibility. Add a method to retrieve the authorized entity instance's name, improving clarity and usability in views.
1 parent 7b9ff1b commit 966361d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

django_ledger/templates/django_ledger/layouts/base.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
<title>{% block page_title %}{% session_entity_name %} | {{ page_title }}{% endblock %}</title>
1111
<script src="{% static 'django_ledger/bundle/styles.bundle.js' %}"></script>
1212
<link rel="shortcut icon" type="image/jpg" href="{% static 'django_ledger/logo/favicon.png' %}">
13+
14+
{% block header_extra_js %}{% endblock %}
15+
{% block header_extra_css %}{% endblock %}
16+
1317
</head>
1418

1519
<body>
@@ -50,8 +54,9 @@
5054
datePickers.forEach(dp => djLedger.getCalendar(dp.attributes.id.value, dateNavigationUrl))
5155
{% endif %}
5256
</script>
53-
5457
{% endblock %}
5558

59+
{% block bottom_extra_js %}{% endblock %}
60+
5661
</body>
5762
</html>

django_ledger/views/mixins.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,12 @@ def get_authorized_entity_instance(self, raise_exception: bool = True) -> Option
361361
return
362362
return self.AUTHORIZED_ENTITY_MODEL
363363

364+
def get_authorized_entity_instance_name(self) -> Optional[str]:
365+
entity_model: EntityModel = self.get_authorized_entity_instance()
366+
if not entity_model:
367+
return None
368+
return entity_model.name
369+
364370

365371
class EntityUnitMixIn:
366372
UNIT_SLUG_KWARG = 'unit_slug'

0 commit comments

Comments
 (0)