|
| 1 | +{% extends "admin/base_site.html" %} |
| 2 | +{% load i18n %} |
| 3 | + |
| 4 | +{% block branding %} |
| 5 | +<h1 id="site-name"> |
| 6 | + <a href="{% url 'admin:index' %}"> |
| 7 | + {% trans 'Django administration' %} |
| 8 | + <span id="impersonation-notice" style="display: none;"> |
| 9 | + - Impersonating (return to codecov.io and log out) |
| 10 | + </span> |
| 11 | + </a> |
| 12 | +</h1> |
| 13 | +{% endblock %} |
| 14 | + |
| 15 | +{% block extrahead %} |
| 16 | +{{ block.super }} |
| 17 | +<style> |
| 18 | + /* Custom styling when cookie is present */ |
| 19 | + html[data-theme="light"].impersonation, :root.impersonation { |
| 20 | + --primary: #ff9800; |
| 21 | + --secondary: #ff9800; |
| 22 | + --link-fg: #ff9800; |
| 23 | + --link-selected-fg: #ff9800; |
| 24 | + } |
| 25 | + |
| 26 | + #header.impersonation { |
| 27 | + background-color: #ff9800 !important; |
| 28 | + } |
| 29 | +</style> |
| 30 | +<script> |
| 31 | + document.addEventListener('DOMContentLoaded', function() { |
| 32 | + function getCookie(name) { |
| 33 | + const value = `; ${document.cookie}`; |
| 34 | + const parts = value.split(`; ${name}=`); |
| 35 | + if (parts.length === 2) return parts.pop().split(';').shift(); |
| 36 | + return null; |
| 37 | + } |
| 38 | + |
| 39 | + // Check for the "staff_user" cookie |
| 40 | + const staffUserCookie = getCookie('staff_user'); |
| 41 | + |
| 42 | + if (staffUserCookie) { |
| 43 | + // Modify the header appearance |
| 44 | + const headerElement = document.querySelector('#header'); |
| 45 | + if (headerElement) { |
| 46 | + headerElement.classList.add('impersonation'); |
| 47 | + } |
| 48 | + |
| 49 | + // Add class to html element for theme variables |
| 50 | + document.documentElement.classList.add('impersonation'); |
| 51 | + |
| 52 | + // Show the impersonation notice |
| 53 | + const impersonationNotice = document.getElementById('impersonation-notice'); |
| 54 | + if (impersonationNotice) { |
| 55 | + impersonationNotice.style.display = 'inline'; |
| 56 | + } |
| 57 | + } |
| 58 | + }); |
| 59 | +</script> |
| 60 | +{% endblock %} |
0 commit comments