Skip to content

Commit

Permalink
Chore: extract common Admin overrides (#2430)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalver1 authored Oct 9, 2024
2 parents 58e3cfd + 4cbc4a2 commit 889e4d8
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 66 deletions.
67 changes: 21 additions & 46 deletions benefits/templates/admin/agency-base.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
{% endblock dark-mode-vars %}

{% block extrastyle %}
<link href="{% static "img/favicon.ico" %}" rel="icon" type="image/x-icon" />
{% include "admin/includes/favicon.html" %}
<script nonce="{{ request.csp_nonce }}"
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"
integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ="
crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous">
<link href="{% static "css/admin/styles.css" %}" rel="stylesheet">
{% include "admin/includes/bootstrap.html" %}
{% include "admin/includes/style-admin.html" %}
{% include "core/includes/analytics.html" with api_key=analytics.api_key uid=analytics.uid did=analytics.did %}
{% endblock extrastyle %}

Expand All @@ -31,50 +28,28 @@ <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 %}
{% endblock usertools %}
{% include "admin/includes/usertools.html" %}
{% endblock usertools %}

{% block coltype %}
w-100
{% endblock coltype %}
{% block coltype %}
w-100
{% endblock coltype %}

{% block bodyclass %}
{{ block.super }} dashboard
{% endblock bodyclass %}
{% block bodyclass %}
{{ block.super }} dashboard
{% endblock bodyclass %}

{% block nav-breadcrumbs %}
{% endblock nav-breadcrumbs %}
{% block nav-breadcrumbs %}
{% endblock nav-breadcrumbs %}

{% block nav-sidebar %}
{% endblock nav-sidebar %}
{% block nav-sidebar %}
{% endblock nav-sidebar %}

{% block content_title %}
{% endblock content_title %}
{% block content_title %}
{% endblock content_title %}

{% block content %}
{% endblock content %}
{% block content %}
{% endblock content %}

{% block sidebar %}
{% endblock sidebar %}
{% block sidebar %}
{% endblock sidebar %}
4 changes: 4 additions & 0 deletions benefits/templates/admin/includes/bootstrap.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous">
9 changes: 9 additions & 0 deletions benefits/templates/admin/includes/branding-login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% load i18n static %}

<div class="d-flex justify-content-center w-100 bg-primary">
<img class="my-3" src="{% static "img/logo-lg.svg" %}" width="220" height="50" alt="California Integrated Travel Project: Benefits logo (large)" />
</div>

<div id="site-name">
<h1 class="text-center text-white fs-3 py-3 m-0">{{ site_header }}</h1>
</div>
3 changes: 3 additions & 0 deletions benefits/templates/admin/includes/favicon.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% load i18n static %}

<link href="{% static "img/favicon.ico" %}" rel="icon" type="image/x-icon" />
3 changes: 3 additions & 0 deletions benefits/templates/admin/includes/style-admin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% load i18n static %}

<link href="{% static "css/admin/styles.css" %}" rel="stylesheet">
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 %}
17 changes: 4 additions & 13 deletions benefits/templates/admin/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,11 @@

{% block extrastyle %}
{% comment %} Overriding instead of extending agency-base here to remove jQuery declaration, which admin/login.html includes on its own {% endcomment %}
<link href="{% static "img/favicon.ico" %}" rel="icon" type="image/x-icon" />
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous">
<link href="{% static "css/admin/styles.css" %}" rel="stylesheet">
{% include "admin/includes/favicon.html" %}
{% include "admin/includes/bootstrap.html" %}
{% include "admin/includes/style-admin.html" %}
{% endblock extrastyle %}

{% block branding %}
<div class="d-flex justify-content-center w-100 bg-primary">
<img class="my-3" src="{% static "img/logo-lg.svg" %}" width="220" height="50" alt="California Integrated Travel Project: Benefits logo (large)" />
</div>

<div id="site-name">
<h1 class="text-center text-white fs-3 py-3 m-0">{{ site_header }}</h1>
</div>
{% include "admin/includes/branding-login.html" %}
{% endblock branding %}
8 changes: 1 addition & 7 deletions benefits/templates/registration/logged_out.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
{% endblock bodyclass %}

{% block branding %}
<div class="d-flex justify-content-center w-100 bg-primary">
<img class="my-3" src="{% static "img/logo-lg.svg" %}" width="220" height="50" alt="California Integrated Travel Project: Benefits logo (large)" />
</div>

<div id="site-name">
<h1 class="text-center text-white fs-3 py-3 m-0">{{ site_header }}</h1>
</div>
{% include "admin/includes/branding-login.html" %}
{% endblock branding %}

{% block content %}
Expand Down

0 comments on commit 889e4d8

Please sign in to comment.