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

Chore: extract common Admin overrides #2430

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 %}
angela-tran marked this conversation as resolved.
Show resolved Hide resolved

{% 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" />
Copy link
Member

@machikoyasuda machikoyasuda Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe need a future ticket: The favicon doesn't show up on the superuser homepage, but it does for the other admin pages: log in, log out, in-person flow pages.

image

cc @indexing - Just to confirm, do we want Admin to have the same favicon as Benefits (digital flow)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @machikoyasuda! I'm looking into this to see where favicon gets set in the index admin page that we see when we log in as a superuser.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes @machikoyasuda. Let's use the same favicon.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! I'll create a separate ticket to fix this favicon issue.

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
Loading