Skip to content

Commit f31e05e

Browse files
authored
Add testimonials (#2069)
1 parent 077b6c5 commit f31e05e

21 files changed

Lines changed: 514 additions & 17 deletions

File tree

ak/views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from libraries.constants import LATEST_RELEASE_URL_PATH_STR
1212
from libraries.mixins import ContributorMixin
1313
from news.models import Entry
14+
from testimonials.models import Testimonial
1415

1516

1617
logger = structlog.get_logger()
@@ -27,6 +28,9 @@ def get_context_data(self, **kwargs):
2728
context = super().get_context_data(**kwargs)
2829
context["entries"] = Entry.objects.published().order_by("-publish_at")[:3]
2930
context["events"] = self.get_events()
31+
context["testimonial"] = (
32+
Testimonial.objects.live().filter(pull_quote__gt="").last()
33+
)
3034
if context["events"]:
3135
context["num_months"] = len(context["events"])
3236
else:

config/settings.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"reports",
121121
"core",
122122
"slack",
123+
"testimonials",
123124
"asciidoctor_sandbox",
124125
]
125126

@@ -644,6 +645,18 @@
644645
"xlsx",
645646
"zip",
646647
]
648+
RICH_TEXT_FEATURES = [
649+
"h1",
650+
"h2",
651+
"h3",
652+
"bold",
653+
"italic",
654+
"link",
655+
"ol",
656+
"ul",
657+
"code",
658+
"blockquote",
659+
]
647660
WAGTAILMARKDOWN = {
648661
"autodownload_fontawesome": True,
649662
"allowed_tags": [], # optional. a list of HTML tags. e.g. ['div', 'p', 'a']

config/urls.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@
409409
# Wagtail stuff
410410
path("cms/", include(wagtailadmin_urls)),
411411
path("documents/", include(wagtaildocs_urls)),
412-
path("outreach/", include(wagtail_urls)),
412+
# Custom Django views (must come before Wagtail catch-all)
413+
path("testimonials/", include("testimonials.urls")),
413414
]
414415
+ [
415416
re_path(
@@ -480,14 +481,18 @@
480481
ImageView.as_view(),
481482
name="images-page",
482483
),
483-
# Static content
484+
# Static content (exclude Wagtail paths)
484485
re_path(
485-
r"^(?!__debug__)(?P<content_path>.+)/?",
486+
r"^(?!__debug__|outreach/|testimonials/)(?P<content_path>.+)/?",
486487
StaticContentTemplateView.as_view(),
487488
name="static-content-page",
488489
),
489490
]
490491
+ djdt_urls
492+
+ [
493+
# Wagtail catch-all (must be last!)
494+
path("", include(wagtail_urls)),
495+
]
491496
)
492497

493498
handler404 = "ak.views.custom_404_view"

frontend/styles.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,11 @@ html:has(#docsiframe) .version_alert {
173173
.version_alert a {
174174
@apply font-semibold underline dark:text-white text-charcoal;
175175
}
176+
177+
.testimonials blockquote {
178+
font-style: italic;
179+
}
180+
181+
.testimonials a {
182+
@apply text-sky-600 dark:text-sky-300 hover:text-orange dark:hover:text-orange;
183+
}

marketing/models.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django import forms
2+
from django.conf import settings
23
from django.contrib import messages
34
from django.db import models
45
from django.http import Http404
@@ -10,19 +11,6 @@
1011
from wagtail.url_routing import RouteResult
1112
from wagtailmarkdown.blocks import MarkdownBlock
1213

13-
RICH_TEXT_FEATURES = [
14-
"h1",
15-
"h2",
16-
"h3",
17-
"bold",
18-
"italic",
19-
"link",
20-
"ol",
21-
"ul",
22-
"code",
23-
"blockquote",
24-
]
25-
2614

2715
class CapturedEmail(models.Model):
2816
email = models.EmailField()
@@ -76,7 +64,10 @@ class EmailCapturePage(Page):
7664
)
7765
body = StreamField(
7866
[
79-
("rich", RichTextBlock(features=RICH_TEXT_FEATURES, label="Rich text")),
67+
(
68+
"rich",
69+
RichTextBlock(features=settings.RICH_TEXT_FEATURES, label="Rich text"),
70+
),
8071
("md", MarkdownBlock(label="Markdown")),
8172
],
8273
use_json_field=True,

static/css/testimonial-style.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
hr {margin:2rem auto; width: 150px;}
2+
p {padding-top: 0.5rem; padding-bottom: 0.5rem;}
3+
a {color:#0284c7;}
4+
a:hover, a:active {color:darkblue}
5+
a:visited {color:#0284c7;}
6+
h1 {font-size: 1.44rem; font-weight:700;}
7+
h2 {font-size: 1rem; font-weight:600; text-transform: uppercase;}
8+
h3 {font-size: 1.1rem; font-weight:700;}
9+
h4 {font-size: 0.95rem; font-weight:700;}
10+
h5 {font-size: 0.69rem; font-weight:700;}
11+
ul, ol {margin: 1rem 0; padding-left: 2rem;}
12+
ul {list-style-type: disc;}
13+
ol {list-style-type: decimal;}
14+
li {padding: 0.25rem 0;}
15+
ul ul, ol ul {list-style-type: circle;}
16+
ol ol, ul ol {list-style-type: lower-alpha;}

templates/homepage.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ <h4 class="mb-3 text-5xl">165+</h4>
5959
</div>
6060
</div>
6161

62+
{% if testimonial %}
63+
<div class="testimonials my-12 mb-3 md:mb-6 space-y-4 lg:mt-16 lg:mb-4 lg:space-y-0 lg:space-x-4 md:shadow-lg">
64+
<div class="testimonial p-6 dark:text-white text-slate bg-white md:rounded-lg dark:bg-charcoal dark:bg-neutral-700 md:shadow-lg">
65+
<h5 class="text-3xl leading-tight mb-2">Testimonials</h5>
66+
<div class="flex items-end gap-4">
67+
<div class="flex-grow">
68+
{{ testimonial.pull_quote }}
69+
</div>
70+
<a href="{% url 'testimonial-detail' testimonial.author_slug %}" class="flex-shrink-0 mb-4">
71+
<button class="py-2 px-3 text-sm text-white rounded bg-orange">Read&nbsp;More</button>
72+
</a>
73+
</div>
74+
</div>
75+
</div>
76+
{% endif %}
77+
6278
{% if events %}
6379
<div class="my-12 mb-3 md:mb-6 space-y-4 lg:flex lg:mt-16 lg:mb-4 lg:space-y-0 lg:space-x-4 md:shadow-lg">
6480
<div class="p-6 relative bg-white md:rounded-lg md:p-11 w-full dark:bg-charcoal">
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{% extends "base.html" %}
2+
{% load static wagtailcore_tags %}
3+
4+
{% block title %}
5+
{{ page.author }} - Testimonial
6+
{% endblock %}
7+
8+
{% block css %}
9+
<link rel="stylesheet" href="{% static 'css/testimonial-style.css' %}" />
10+
{% endblock %}
11+
12+
{% block content %}
13+
<div class="py-0 px-3 mb-3 md:py-6 md:px-0">
14+
<div class="py-8 md:mx-auto md:w-3/4">
15+
<h1 class="text-3xl mb-4">{{ page.title }}</h1>
16+
<h3 class="text-xl mb-6 text-gray-600 dark:text-gray-400">
17+
By
18+
{% if page.author_url %}
19+
<a href="{{ page.author_url }}" class="text-orange hover:underline">{{ page.author }}</a>
20+
{% else %}
21+
{{ page.author }}
22+
{% endif %}
23+
</h3>
24+
25+
<div class="bg-white dark:bg-charcoal rounded-lg p-6">
26+
<div class="prose dark:prose-invert max-w-none">
27+
{{ page.body }}
28+
</div>
29+
</div>
30+
</div>
31+
</div>
32+
{% endblock %}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{% extends '_base.html' %}
2+
{% load i18n %}
3+
4+
{% block title %}
5+
Testimonials
6+
{% endblock %}
7+
8+
{% block content %}
9+
<div class="py-0 px-3 mb-3 md:py-6 md:px-0">
10+
<div class="py-8 md:mx-auto md:w-3/4">
11+
<h1 class="text-3xl mb-6">Testimonials</h1>
12+
13+
<div class="space-y-6">
14+
{% for testimonial in testimonials %}
15+
<div class="bg-white dark:bg-charcoal rounded-lg p-6">
16+
<h2 class="text-2xl mb-3">
17+
<a href="{{ testimonial.url }}" class="text-orange hover:text-orange/75">
18+
{{ testimonial.author }}
19+
</a>
20+
</h2>
21+
22+
{% if testimonial.pull_quote %}
23+
<blockquote class="text-lg italic text-gray-700 dark:text-gray-300 border-l-4 border-orange pl-4 mb-3">
24+
"{{ testimonial.pull_quote }}"
25+
</blockquote>
26+
{% endif %}
27+
28+
<a href="{{ testimonial.url }}" class="text-sky-600 dark:text-sky-300 hover:text-orange dark:hover:text-orange">
29+
Read more &rarr;
30+
</a>
31+
</div>
32+
{% empty %}
33+
<p class="text-gray-600 dark:text-gray-400">No testimonials yet.</p>
34+
{% endfor %}
35+
</div>
36+
</div>
37+
</div>
38+
{% endblock %}

testimonials/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)