Skip to content

Commit 960df12

Browse files
Added banner to differentiate preview.djangoproject.com (#2052)
1 parent 511e142 commit 960df12

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

djangoproject/context_processors.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from django.conf import settings
2+
3+
4+
def display_preview_banner(request):
5+
"""
6+
Determines if a banner should be displayed to help the website teams
7+
distinguish between the preview and production sites. The banner is
8+
based on the domain name configured in settings, if any, and will
9+
appear on https://*.preview.djangoproject.com/ (but not
10+
https://*.djangoproject.com/ nor in local development).
11+
"""
12+
production_tld = "djangoproject.com"
13+
# Note: DOMAIN_NAME is not defined in local development
14+
domain_name = getattr(settings, "DOMAIN_NAME", production_tld)
15+
return {
16+
"DISPLAY_PREVIEW_BANNER": domain_name != production_tld,
17+
}

djangoproject/settings/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@
209209
"docs.context_processors.docs_version",
210210
"releases.context_processors.django_version",
211211
"aggregator.context_processors.community_stats",
212+
"djangoproject.context_processors.display_preview_banner",
212213
"django.template.context_processors.request",
213214
],
214215
},

djangoproject/templates/includes/header.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{% if DISPLAY_PREVIEW_BANNER %}
2+
<div class="copy-banner" style="background: #fff78e; padding: 10px;"></div>
3+
{% endif %}
14
<header id="top">
25
<div class="container container--flex--wrap--mobile">
36
<a class="logo" href="{% url 'homepage' %}">Django</a>

0 commit comments

Comments
 (0)