Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
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
4 changes: 3 additions & 1 deletion codecov/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"DIRS": [
"templates",
],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
Expand Down
60 changes: 60 additions & 0 deletions templates/admin/base_site.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{% extends "admin/base_site.html" %}
{% load i18n %}

{% block branding %}
<h1 id="site-name">
<a href="{% url 'admin:index' %}">
{% trans 'Django administration' %}
<span id="impersonation-notice" style="display: none;">
- Impersonating (return to codecov.io and log out)
</span>
</a>
</h1>
{% endblock %}

{% block extrahead %}
{{ block.super }}
<style>
/* Custom styling when cookie is present */
html[data-theme="light"].impersonation, :root.impersonation {
--primary: #ff9800;
--secondary: #ff9800;
--link-fg: #ff9800;
--link-selected-fg: #ff9800;
}

#header.impersonation {
background-color: #ff9800 !important;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function() {
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
return null;
}

// Check for the "staff_user" cookie
const staffUserCookie = getCookie('staff_user');

if (staffUserCookie) {
// Modify the header appearance
const headerElement = document.querySelector('#header');
if (headerElement) {
headerElement.classList.add('impersonation');
}

// Add class to html element for theme variables
document.documentElement.classList.add('impersonation');

// Show the impersonation notice
const impersonationNotice = document.getElementById('impersonation-notice');
if (impersonationNotice) {
impersonationNotice.style.display = 'inline';
}
}
});
</script>
{% endblock %}
Loading