Skip to content

Commit

Permalink
chore: extract usertools as include
Browse files Browse the repository at this point in the history
  • Loading branch information
lalver1 committed Oct 8, 2024
1 parent e932a32 commit 6ee7e3c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
25 changes: 1 addition & 24 deletions benefits/templates/admin/agency-base.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,7 @@ <h1 class="p-0 m-0 text-white">{{ site_header }}</h1>
{% endblock branding %}

{% block usertools %}
{% if has_permission %}
<div id="user-tools">
{% block welcome-msg %}
<span class="text-uppercase text-white">
Welcome,
<span class="fw-bold">{% firstof user.get_short_name user.get_username %}</span>.
</span>
{% endblock welcome-msg %}
{% block userlinks %}
{% if user.is_active and user.is_staff %}
{% url 'django-admindocs-docroot' as docsroot %}
{% if docsroot %}<a href="{{ docsroot }}">Documentation</a> /{% endif %}
{% endif %}
{% if user.has_usable_password %}
<a href="{% url 'admin:password_change' %}">Change password</a> /
{% endif %}
<img class="icon" width="15" height="15" src="{% static "img/icon/box-arrow-right.svg" %}" alt="" />
<form id="logout-form" method="post" action="{% url 'admin:logout' %}">
{% csrf_token %}
<button type="submit" class="border-0">Log out</button>
</form>
{% endblock userlinks %}
</div>
{% endif %}
{% include "admin/includes/usertools.html" %}
{% endblock usertools %}

{% block coltype %}
Expand Down
26 changes: 26 additions & 0 deletions benefits/templates/admin/includes/usertools.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% load i18n static %}

{% if has_permission %}
<div id="user-tools">
{% block welcome-msg %}
<span class="text-uppercase text-white">
Welcome,
<span class="fw-bold">{% firstof user.get_short_name user.get_username %}</span>.
</span>
{% endblock welcome-msg %}
{% block userlinks %}
{% if user.is_active and user.is_staff %}
{% url 'django-admindocs-docroot' as docsroot %}
{% if docsroot %}<a href="{{ docsroot }}">Documentation</a> /{% endif %}
{% endif %}
{% if user.has_usable_password %}
<a href="{% url 'admin:password_change' %}">Change password</a> /
{% endif %}
<img class="icon" width="15" height="15" src="{% static "img/icon/box-arrow-right.svg" %}" alt="" />
<form id="logout-form" method="post" action="{% url 'admin:logout' %}">
{% csrf_token %}
<button type="submit" class="border-0">Log out</button>
</form>
{% endblock userlinks %}
</div>
{% endif %}

0 comments on commit 6ee7e3c

Please sign in to comment.