summaryrefslogtreecommitdiff
path: root/djangoproject
diff options
context:
space:
mode:
authorNatalia <124304+nessita@users.noreply.github.com>2026-04-08 12:07:49 -0300
committernessita <124304+nessita@users.noreply.github.com>2026-04-14 22:40:39 -0300
commitab5429a66410966cebbce2616e216abf02f50b32 (patch)
treed5154931e216047fb616204b378505d6aa8d5aaa /djangoproject
parent858167b78fad97ec2aa3ef5a84de730a41135e5c (diff)
Allowed creation of site-wide banners via the admin interface.
Fixes #1550. A banner requires a title, and optionally HTML body and CTA label/URL. A banner can be active or inactive, and only one can be active at a time. Banners can be previewed from the admin via the "View on site" options on a Banner's detail page. This initial implementation is intentionally minimal to provide a robust but flexible MVP, with the goal to gather feedback for future iterations. Future improvements could include: - Active since and until dates. - Flexible CTA URL handling, such as URL names or local URLs. Thanks to Sarahs for the reviews.
Diffstat (limited to 'djangoproject')
-rw-r--r--djangoproject/scss/_style.scss6
-rw-r--r--djangoproject/templates/base.html4
-rw-r--r--djangoproject/templates/foundation/banner.html9
-rw-r--r--djangoproject/templates/foundation/banner_preview.html9
-rw-r--r--djangoproject/templates/fundraising/index.html2
-rw-r--r--djangoproject/urls/www.py7
6 files changed, 34 insertions, 3 deletions
diff --git a/djangoproject/scss/_style.scss b/djangoproject/scss/_style.scss
index 6a8565d9..be2c29de 100644
--- a/djangoproject/scss/_style.scss
+++ b/djangoproject/scss/_style.scss
@@ -711,6 +711,12 @@ header {
}
}
+ .banner-preview-notice {
+ background-color: $warning-bg;
+ text-align: center;
+ margin: 0;
+ padding: 0;
+ }
a, h1 a {
color: $black;
diff --git a/djangoproject/templates/base.html b/djangoproject/templates/base.html
index ec6d3399..d6860ff8 100644
--- a/djangoproject/templates/base.html
+++ b/djangoproject/templates/base.html
@@ -1,4 +1,4 @@
-{% load static %}<!DOCTYPE html>
+{% load static banner %}<!DOCTYPE html>
<html lang="{% block html_language_code %}en{% endblock %}">
<head>
<meta charset="utf-8">
@@ -59,7 +59,7 @@
</section>
<div id="billboard">
- {% block billboard %}{% endblock %}
+ {% block billboard %}{% active_banner %}{% endblock %}
</div>
<div class="container {% block layout_class %}{% endblock %}">
diff --git a/djangoproject/templates/foundation/banner.html b/djangoproject/templates/foundation/banner.html
new file mode 100644
index 00000000..a412845f
--- /dev/null
+++ b/djangoproject/templates/foundation/banner.html
@@ -0,0 +1,9 @@
+{% if banner %}
+ <div class="banner">
+ <h2>{{ banner.title }}</h2>
+ {% if banner.body %}{{ banner.body|safe }}{% endif %}
+ {% if banner.cta_url and banner.cta_label %}
+ <a id="banner-cta" class="cta" href="{{ banner.cta_url }}">{{ banner.cta_label }}</a>
+ {% endif %}
+ </div>
+{% endif %}
diff --git a/djangoproject/templates/foundation/banner_preview.html b/djangoproject/templates/foundation/banner_preview.html
new file mode 100644
index 00000000..ff3a4894
--- /dev/null
+++ b/djangoproject/templates/foundation/banner_preview.html
@@ -0,0 +1,9 @@
+{% extends "homepage.html" %}
+
+{% block billboard %}
+ <p class="banner-preview-notice">
+ <strong>Preview!</strong>
+ (last updated by {{ banner.updated_by }} on {{ banner.updated_at|date:"N j, Y, P" }})
+ </p>
+ {% include "foundation/banner.html" %}
+{% endblock %}
diff --git a/djangoproject/templates/fundraising/index.html b/djangoproject/templates/fundraising/index.html
index fe3d19e4..6cc16d09 100644
--- a/djangoproject/templates/fundraising/index.html
+++ b/djangoproject/templates/fundraising/index.html
@@ -15,6 +15,8 @@
</p>
{% endblock %}
+{% block billboard %}{% endblock %}
+
{% block messages %}
{% if messages %}
diff --git a/djangoproject/urls/www.py b/djangoproject/urls/www.py
index de4f1818..33fb8edc 100644
--- a/djangoproject/urls/www.py
+++ b/djangoproject/urls/www.py
@@ -15,7 +15,7 @@ from blog.feeds import WeblogEntryFeed
from blog.sitemaps import WeblogSitemap
from djangoproject.sitemaps import TemplateViewSitemap
from foundation.feeds import FoundationMinutesFeed
-from foundation.views import CoreDevelopers
+from foundation.views import BannerPreview, CoreDevelopers
admin.autodiscover()
@@ -98,6 +98,11 @@ urlpatterns = [
),
path("checklists/", include("checklists.urls")),
path("contact/", include("contact.urls")),
+ path(
+ "foundation/banners/<int:pk>/preview/",
+ BannerPreview.as_view(),
+ name="foundation_banner_preview",
+ ),
path("foundation/django_core/", CoreDevelopers.as_view()),
path("foundation/minutes/", include("foundation.urls.meetings")),
path("foundation/", include("members.urls")),