Skip to content

Commit 3cd3954

Browse files
Merge branch 'main' into new2
2 parents c09dfff + 8ef4db8 commit 3cd3954

31 files changed

+559
-168
lines changed

.github/workflows/docker-publish.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ jobs:
1919
- name: Checkout repository
2020
uses: actions/checkout@v4
2121

22-
- name: Set up Docker Buildx
23-
uses: docker/setup-buildx-action@v3
24-
2522
- name: Log in to the Container registry
2623
uses: docker/login-action@v3
2724
with:
@@ -47,5 +44,3 @@ jobs:
4744
push: true
4845
tags: ${{ steps.meta.outputs.tags }}
4946
labels: ${{ steps.meta.outputs.labels }}
50-
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-buildcache:bc-publish-${{ github.ref_name }}
51-
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-buildcache:bc-publish-${{ github.ref_name }},mode=max

.github/workflows/docker-test-build.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,12 @@ name: Docker test build
33
on:
44
pull_request:
55

6-
env:
7-
REGISTRY: ghcr.io
8-
IMAGE_NAME: ${{ github.repository }}
9-
106
concurrency:
117
group: ${{ github.workflow }}-${{ github.ref }}
128
cancel-in-progress: true
139

1410
permissions:
1511
contents: read
16-
packages: write
1712

1813
jobs:
1914
build-image:
@@ -30,22 +25,10 @@ jobs:
3025
- name: Checkout repository
3126
uses: actions/checkout@v4
3227

33-
- name: Set up Docker Buildx
34-
uses: docker/setup-buildx-action@v3
35-
36-
- name: Log in to the Container registry
37-
uses: docker/login-action@v3
38-
with:
39-
registry: ${{ env.REGISTRY }}
40-
username: ${{ github.actor }}
41-
password: ${{ secrets.GITHUB_TOKEN }}
42-
4328
- name: Test docker image build (local development)
4429
uses: docker/build-push-action@v6
4530
with:
4631
context: .
4732
push: false
4833
build-args: |
4934
REQ_FILE=requirements/${{ matrix.req_file }}
50-
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-buildcache:bc-test-build-${{ matrix.req_file }}
51-
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-buildcache:bc-test-build-${{ matrix.req_file }},mode=max

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
uses: actions/setup-python@v5
3434
with:
3535
python-version: ${{ env.PYTHON_VERSION }}
36+
- name: Install gettext
37+
run: sudo apt-get update && sudo apt-get install -y gettext
3638
- name: Install dependencies
3739
run: |
3840
python -m pip install --upgrade pip setuptools

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ repos:
3333
- id: pyupgrade
3434
args: [--py312]
3535
- repo: https://github.com/adamchainz/django-upgrade
36-
rev: "1.25.0"
36+
rev: "1.28.0"
3737
hooks:
3838
- id: django-upgrade
3939
args: [--target-version, "5.2"]
4040
- repo: https://github.com/psf/black
41-
rev: 25.1.0
41+
rev: 25.9.0
4242
hooks:
4343
- id: black
4444
exclude: '(\/migrations\/)'
@@ -57,7 +57,7 @@ repos:
5757
hooks:
5858
- id: flake8
5959
- repo: https://github.com/rtts/djhtml
60-
rev: "3.0.8"
60+
rev: "3.0.9"
6161
hooks:
6262
- id: djhtml
6363
files: .*/templates/.*\.html$

Dockerfile

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ENV PYTHONDONTWRITEBYTECODE=1
99
ENV PYTHONUNBUFFERED=1
1010

1111
# install deb packages
12+
# PostgreSQL dependencies are needed for dbshell and backup process
1213
RUN apt-get update \
1314
&& apt-get install --assume-yes --no-install-recommends \
1415
gettext \
@@ -23,23 +24,14 @@ RUN apt-get update \
2324
&& apt-get distclean
2425

2526
ARG REQ_FILE=requirements/prod.txt
27+
ARG BUILD_DEPENDENCIES="g++ gcc libc6-dev libpq-dev zlib1g-dev"
2628

2729
# install python dependencies
2830
COPY ./requirements ./requirements
2931
RUN apt-get update \
30-
&& apt-get install --assume-yes --no-install-recommends \
31-
g++ \
32-
gcc \
33-
libc6-dev \
34-
libpq-dev \
35-
zlib1g-dev \
32+
&& apt-get install --assume-yes --no-install-recommends ${BUILD_DEPENDENCIES} \
3633
&& python3 -m pip install --no-cache-dir -r ${REQ_FILE} \
37-
&& apt-get purge --assume-yes --auto-remove \
38-
g++ \
39-
gcc \
40-
libc6-dev \
41-
libpq-dev \
42-
zlib1g-dev \
34+
&& apt-get purge --assume-yes --auto-remove ${BUILD_DEPENDENCIES} \
4335
&& apt-get distclean
4436

4537
# copy project

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ APP_LIST ?= accounts aggregator blog contact dashboard djangoproject docs founda
44
SCSS = djangoproject/scss
55
STATIC = djangoproject/static
66

7-
ci: test
7+
ci: compilemessages test
88
@python -m coverage report
99

10+
compilemessages:
11+
python -m manage compilemessages
12+
1013
collectstatics: compile-scss
1114
python -m manage collectstatic --noinput
1215

blog/tests.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
from io import StringIO
44

55
import time_machine
6+
from django.conf import settings
67
from django.contrib.auth.models import Permission, User
78
from django.contrib.contenttypes.models import ContentType
89
from django.core.files.base import ContentFile
910
from django.test import TestCase
11+
from django.test.utils import override_settings
1012
from django.urls import reverse
1113
from django.utils import timezone, translation
1214

@@ -407,6 +409,77 @@ def test_user_cannot_see_unpublished_entries(self):
407409
self.assertEqual(response.status_code, 200)
408410

409411

412+
@override_settings(
413+
# Caching middleware is added in the production settings file;
414+
# simulate that here for the tests.
415+
MIDDLEWARE=(
416+
["django.middleware.cache.UpdateCacheMiddleware"]
417+
+ settings.MIDDLEWARE
418+
+ ["django.middleware.cache.FetchFromCacheMiddleware"]
419+
),
420+
)
421+
class ViewsCachingTestCase(DateTimeMixin, TestCase):
422+
def test_drafts_have_no_cache_headers(self):
423+
"""
424+
Draft (unpublished) entries have no-cache headers.
425+
"""
426+
user = User.objects.create(username="staff", is_staff=True)
427+
content_type = ContentType.objects.get_for_model(Entry)
428+
change_permission = Permission.objects.get(
429+
content_type=content_type, codename="change_entry"
430+
)
431+
user.user_permissions.add(change_permission)
432+
self.client.force_login(user)
433+
434+
unpublished_entry = Entry.objects.create(
435+
pub_date=self.tomorrow,
436+
is_active=True,
437+
headline="unpublished",
438+
slug="unpublished",
439+
)
440+
unpublished_url = reverse(
441+
"weblog:entry",
442+
kwargs={
443+
"year": unpublished_entry.pub_date.year,
444+
"month": unpublished_entry.pub_date.strftime("%b").lower(),
445+
"day": unpublished_entry.pub_date.day,
446+
"slug": unpublished_entry.slug,
447+
},
448+
)
449+
450+
response = self.client.get(unpublished_url)
451+
452+
self.assertEqual(response.status_code, 200)
453+
self.assertIn("Cache-Control", response.headers)
454+
self.assertEqual(
455+
response.headers["Cache-Control"],
456+
"max-age=0, no-cache, no-store, must-revalidate, private",
457+
)
458+
459+
def test_published_blogs_have_cache_control_headers(self):
460+
"""
461+
Published blog posts has Cache-Control header.
462+
"""
463+
entry = Entry.objects.create(
464+
pub_date=self.yesterday,
465+
is_active=True,
466+
headline="published",
467+
slug="published",
468+
)
469+
url = reverse(
470+
"weblog:entry",
471+
kwargs={
472+
"year": entry.pub_date.year,
473+
"month": entry.pub_date.strftime("%b").lower(),
474+
"day": entry.pub_date.day,
475+
"slug": entry.slug,
476+
},
477+
)
478+
response = self.client.get(url)
479+
self.assertEqual(response.status_code, 200)
480+
self.assertEqual(response.headers["Cache-Control"], "max-age=300")
481+
482+
410483
class SitemapTests(DateTimeMixin, TestCase):
411484
def test_sitemap(self):
412485
entry = Entry.objects.create(

blog/views.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.utils.cache import add_never_cache_headers
12
from django.views.generic.dates import (
23
ArchiveIndexView,
34
DateDetailView,
@@ -58,3 +59,9 @@ def get_queryset(self):
5859
return Entry.objects.all()
5960
else:
6061
return super().get_queryset()
62+
63+
def get(self, request, *args, **kwargs):
64+
response = super().get(request, *args, **kwargs)
65+
if not self.object.is_published():
66+
add_never_cache_headers(response)
67+
return response

djangoproject/scss/_style.scss

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CSS rendered with Libsass 0.7.0
1313

1414
//------------------- Globals
1515
body {
16-
@include serif;
16+
@include sans-serif;
1717
@include font-size(18);
1818
background: var(--sidebar-bg);
1919
color: var(--body-fg);
@@ -636,7 +636,6 @@ header {
636636
}
637637

638638
p {
639-
@include serif;
640639
@include font-size(18);
641640
color: var(--white-color);
642641
left: -9999px;
@@ -1345,6 +1344,18 @@ label[for] {
13451344
margin: 10px 0;
13461345
}
13471346

1347+
.cta.arrow {
1348+
height: auto;
1349+
&::after {
1350+
content: "" / "";
1351+
}
1352+
&:dir(rtl) {
1353+
&::after {
1354+
content: "" / "";
1355+
}
1356+
}
1357+
}
1358+
13481359
.callout-right {
13491360
@include respond-min(768px) {
13501361
float: right;
@@ -2518,14 +2529,48 @@ dl.data {
25182529
white-space: normal;
25192530
}
25202531

2532+
table {
2533+
th {
2534+
background: var(--sidebar-bg);
2535+
font-weight: bold;
2536+
text-align: left;
2537+
}
2538+
2539+
td {
2540+
border-bottom: 1px solid var(--hairline-color);
2541+
}
2542+
2543+
td,
2544+
th {
2545+
padding: 0.5em 1em;
2546+
}
2547+
}
2548+
25212549
table.foundation td {
2522-
border-bottom: 1px solid var(--hairline-color);
25232550
padding: 0 5px;
25242551
}
25252552

2526-
table.docutils td,
2527-
table.docutils th {
2528-
border-bottom: 1px solid var(--hairline-color);
2553+
table.django-supported-versions,
2554+
table.django-unsupported-versions {
2555+
border: 1px solid var(--hairline-color);
2556+
color: var(--table-color);
2557+
2558+
th,
2559+
td {
2560+
border-bottom: none;
2561+
padding: 5px;
2562+
text-align: center;
2563+
}
2564+
}
2565+
2566+
table.django-supported-versions th,
2567+
table.django-supported-versions tr {
2568+
background-color: var(--secondary-accent);
2569+
}
2570+
2571+
table.django-unsupported-versions th,
2572+
table.django-unsupported-versions tr {
2573+
background-color: var(--error-light);
25292574
}
25302575

25312576
.list-links {
@@ -3409,26 +3454,6 @@ form .footnote {
34093454
}
34103455
}
34113456

3412-
table.django-supported-versions,
3413-
table.django-unsupported-versions {
3414-
border: 1px solid black;
3415-
text-align: center;
3416-
color: var(--table-color);
3417-
3418-
th,
3419-
td {
3420-
padding: 5px;
3421-
}
3422-
}
3423-
3424-
table.django-supported-versions tr {
3425-
background-color: var(--secondary-accent);
3426-
}
3427-
3428-
table.django-unsupported-versions tr {
3429-
background-color: var(--error-light);
3430-
}
3431-
34323457
/* Corporate membership list page */
34333458

34343459
ul.corporate-members li {

djangoproject/scss/_utils.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ $logo-bg-dark: #272c27;
114114
}
115115

116116
// Font Family Mixins
117-
@mixin serif {
118-
font-family: Palatino, "Palatino Linotype", "Book Antiqua", "Hoefler Text", Georgia, "Lucida Bright", Cambria, Times, "Times New Roman", serif;
119-
}
120-
121117
@mixin sans-serif {
122118
font-family: "Roboto", Corbel, Avenir, "Lucida Grande", "Lucida Sans", sans-serif;
123119
}

0 commit comments

Comments
 (0)