Skip to content

Commit 733d59c

Browse files
JacobCoffeeewdurbindependabot[bot]mikethemanalvindera97
authored
release: push latest changes (#2620)
* fix: display active events, fix time not displaying for some events (#2556) * fix: display active events, fix time not displaying for some events * test: passing events view tests * style: different icon * Update views.py Co-authored-by: Ee Durbin <[email protected]> --------- Co-authored-by: Ee Durbin <[email protected]> * Bump django-admin-interface from 0.24.2 to 0.28.9 (#2589) Bumps [django-admin-interface](https://github.com/fabiocaccamo/django-admin-interface) from 0.24.2 to 0.28.9. - [Release notes](https://github.com/fabiocaccamo/django-admin-interface/releases) - [Changelog](https://github.com/fabiocaccamo/django-admin-interface/blob/main/CHANGELOG.md) - [Commits](fabiocaccamo/django-admin-interface@0.24.2...0.28.9) --- updated-dependencies: - dependency-name: django-admin-interface dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jacob Coffee <[email protected]> * Bump django-pipeline from 3.0.0 to 3.1.0 (#2549) Bumps [django-pipeline](https://github.com/jazzband/django-pipeline) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/jazzband/django-pipeline/releases) - [Changelog](https://github.com/jazzband/django-pipeline/blob/master/HISTORY.rst) - [Commits](jazzband/django-pipeline@3.0.0...3.1.0) --- updated-dependencies: - dependency-name: django-pipeline dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump factory-boy from 3.2.1 to 3.3.1 (#2548) Bumps [factory-boy](https://github.com/FactoryBoy/factory_boy) from 3.2.1 to 3.3.1. - [Changelog](https://github.com/FactoryBoy/factory_boy/blob/master/docs/changelog.rst) - [Commits](FactoryBoy/factory_boy@3.2.1...3.3.1) --- updated-dependencies: - dependency-name: factory-boy dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix(frontend): add help text to story form (#2594) * fix(frontend): add help text to story form Closes #2364 * chore: source migration * fix: use meta class overrides instead * feat: linkify * Bump python-decouple from 3.4 to 3.8 (#2596) Bumps [python-decouple](https://github.com/henriquebastos/python-decouple) from 3.4 to 3.8. - [Release notes](https://github.com/henriquebastos/python-decouple/releases) - [Changelog](https://github.com/HBNetwork/python-decouple/blob/master/CHANGELOG.md) - [Commits](HBNetwork/python-decouple@v3.4...v3.8) --- updated-dependencies: - dependency-name: python-decouple dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jacob Coffee <[email protected]> * deps: no mo boto (#2598) * Bump django-tastypie from 0.14.6 to 0.14.7 (#2602) Bumps [django-tastypie](https://github.com/django-tastypie/django-tastypie) from 0.14.6 to 0.14.7. - [Release notes](https://github.com/django-tastypie/django-tastypie/releases) - [Commits](django-tastypie/django-tastypie@v0.14.6...v0.14.7) --- updated-dependencies: - dependency-name: django-tastypie dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump cssselect from 1.1.0 to 1.2.0 (#2606) Bumps [cssselect](https://github.com/scrapy/cssselect) from 1.1.0 to 1.2.0. - [Changelog](https://github.com/scrapy/cssselect/blob/master/CHANGES) - [Commits](scrapy/cssselect@v1.1.0...v1.2.0) --- updated-dependencies: - dependency-name: cssselect dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chores & docs: clean up some inaccuracies in getting started (#2600) * chore: remove obsolete version entry from compose Currently raises a warning: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion Signed-off-by: Mike Fiedler <[email protected]> * docs: staging site does not exist Signed-off-by: Mike Fiedler <[email protected]> * docs: format the link to be clickable Signed-off-by: Mike Fiedler <[email protected]> * docs: use what's currently in docker-compose.yml Signed-off-by: Mike Fiedler <[email protected]> * docs: remove version specificity Signed-off-by: Mike Fiedler <[email protected]> --------- Signed-off-by: Mike Fiedler <[email protected]> * fix(#1701): Events page displays year for events scheduled to start or end at a future year (#2500) * Add Methods To Check If Event Starts And Ends This Year * Set Up Templates For Querying Start And End Years Passed variables to the time_tag template [time_tag.html] that checks if an event was scheduled to start or end with the current year. * Insert New Test Data And Update test_views.py More events are created to test particular scenarios of events especially events set to start or end at a future year. * Time Tag Now Shows Year For Events With Details Not Within The Current Year The time tag now displays the year when an event will occur. This is only for events that have been scheduled to start or end in at a future year. The accompanying functional tests have also been included. * Move All Test Data To Functional Test All test data concerning the provision of data to serve the functional tests have been moved to the functional test. As it improves readability. All other test data at test_views.py was reset to accommodate for the reduction in number of test data instances. * Functional Test For Displaying Year Of Event For Future Events Now Implemented With Unit Tests * Remove Functional Test For Displaying Year Of Future Event Since the current CI at the main branch does not support selenium [web driver] operations, the functional test which depends on selenium to run has been removed. * Handle Case When Call To Next Event Returns None * Fix Erroneous Addition To Dev Requirements This error was introduced in 115af08 * Refactor Tests For Relevant Year String Rendering At Events Page - Updated the test methods `test_scheduled_to_start_this_year_method` and `test_scheduled_to_end_this_year_method` to better reflect event scheduling edge cases. - Added assertions to verify when events are not scheduled to start or end within the current year. - Utilize `unittest.mock` to clamp down datetime-sensitive tests. --------- Co-authored-by: Jacob Coffee <[email protected]> * infra: enable the waf (#2613) * fix(infra): use new site names (#2614) * chore: avoid running Actions twice on PR (#2615) * chore: avoid running Actions twice on PR Refs: https://github.com/orgs/community/discussions/57827#discussioncomment-6579237 * chore: run once * add a static container for handling local frontend dev (#2619) * add a static container for handling local frontend dev * resulting css files * Improve static deploy (#2609) * Add a utility for purging Fastly by Surrogate-Key * add a postdeploy step to purge surroage-keys for static files --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Mike Fiedler <[email protected]> Co-authored-by: Ee Durbin <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mike Fiedler <[email protected]> Co-authored-by: Nwokolo Godwin Chidera <[email protected]>
1 parent 2691034 commit 733d59c

31 files changed

+1077
-810
lines changed

.github/dependabot.yml

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ updates:
1616
- 0.13.0
1717
- 0.13.1
1818
- 0.13.2
19+
- dependency-name: "boto3"
20+
- dependency-name: "boto3-stubs"
21+
- dependency-name: "botocore"
22+
- dependency-name: "botocore-stubs"
1923
- dependency-name: lxml
2024
versions:
2125
- 4.6.2

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: CI
22
on: [push, pull_request]
33
jobs:
44
test:
5+
# Avoid running CI more than once on pushes to main repo open PRs
6+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
57
runs-on: ubuntu-latest
68
services:
79
postgres:

.github/workflows/static.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
name: Check collectstatic
22
on: [push, pull_request]
33
jobs:
4-
test:
4+
collectstatic:
5+
# Avoid running CI more than once on pushes to main repo open PRs
6+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
57
runs-on: ubuntu-latest
68
steps:
79
- name: Check out repository

Dockerfile.static

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM ruby:2.7.8-bullseye AS static
2+
3+
RUN mkdir /code
4+
WORKDIR /code
5+
6+
COPY Gemfile Gemfile.lock /code/
7+
8+
RUN bundle install
9+
10+
COPY . /code

Gemfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
source "https://rubygems.org"
22

33
group :media do
4-
gem "compass", "~>0.12.2"
5-
gem "sass", "~>3.2.5"
6-
gem "susy", "~>1.0.5"
4+
gem "compass", "~>0.12.7"
5+
gem "sass", "~>3.2.19"
6+
gem "susy", "~>1.0.9"
77
end
88

99
group :development do

Gemfile.lock

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
chunky_png (1.2.7)
5-
compass (0.12.2)
4+
chunky_png (1.4.0)
5+
compass (0.12.7)
66
chunky_png (~> 1.2)
77
fssm (>= 0.2.7)
8-
sass (~> 3.1)
8+
sass (~> 3.2.19)
99
foreman (0.61.0)
1010
thor (>= 0.13.6)
1111
fssm (0.2.10)
12-
sass (3.2.6)
13-
susy (1.0.5)
12+
sass (3.2.19)
13+
susy (1.0.9)
1414
compass (>= 0.12.2)
1515
sass (>= 3.2.0)
1616
thor (0.17.0)
@@ -19,7 +19,10 @@ PLATFORMS
1919
ruby
2020

2121
DEPENDENCIES
22-
compass (~> 0.12.2)
22+
compass (~> 0.12.7)
2323
foreman (~> 0.61.0)
24-
sass (~> 3.2.5)
25-
susy (~> 1.0.5)
24+
sass (~> 3.2.19)
25+
susy (~> 1.0.9)
26+
27+
BUNDLED WITH
28+
2.1.4

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ release: python manage.py migrate --noinput
22
web: bin/start-nginx gunicorn -c gunicorn.conf pydotorg.wsgi
33
worker: celery -A pydotorg worker -l INFO
44
worker-beat: celery -A pydotorg beat -l INFO --scheduler django_celery_beat.schedulers:DatabaseScheduler
5+
postdeploy: python manage.py postdeploy

base-requirements.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
dj-database-url==0.5.0
2-
django-pipeline==3.0.0 # 3.0.0 is first version that supports Django 4.2
2+
django-pipeline==3.1.0 # 3.0.0 is first version that supports Django 4.2
33
django-sitetree==1.18.0 # >=1.17.1 is (?) first version that supports Django 4.2
44
django-apptemplates==1.5
5-
django-admin-interface==0.24.2
5+
django-admin-interface==0.28.9
66
django-translation-aliases==0.1.0
77
Django==4.2.16
88
docutils==0.21.2
@@ -11,10 +11,10 @@ cmarkgfm==0.6.0
1111
Pillow==10.4.0
1212
psycopg2-binary==2.9.9
1313
python3-openid==3.2.0
14-
python-decouple==3.4
14+
python-decouple==3.8
1515
# lxml used by BeautifulSoup.
1616
lxml==5.2.2
17-
cssselect==1.1.0
17+
cssselect==1.2.0
1818
feedparser==6.0.11
1919
beautifulsoup4==4.12.3
2020
icalendar==4.0.7
@@ -26,7 +26,7 @@ django-imagekit==5.0 # 5.0 is first version that supports Django 4.2
2626
django-haystack==3.2.1
2727
elasticsearch>=7,<8
2828
# TODO: 0.14.0 only supports Django 1.8 and 1.11.
29-
django-tastypie==0.14.6 # 0.14.6 is first version that supports Django 4.2
29+
django-tastypie==0.14.7 # 0.14.6 is first version that supports Django 4.2
3030

3131
pytz==2021.1
3232
python-dateutil==2.8.2

bin/static

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
cd static
3+
bundle exec sass --compass --scss -I $(dirname $(dirname $(gem which susy))) --trace --watch sass:sass

dev-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Required for running tests
44

5-
factory-boy==3.2.1
5+
factory-boy==3.3.1
66
Faker==0.8.1
77
tblib==1.7.0
88
responses==0.13.3

docker-compose.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.9"
2-
31
services:
42
postgres:
53
image: postgres:15.3-bullseye
@@ -22,6 +20,13 @@ services:
2220
test: ["CMD", "redis-cli","ping"]
2321
interval: 1s
2422

23+
static:
24+
command: bin/static
25+
build:
26+
dockerfile: Dockerfile.static
27+
volumes:
28+
- .:/code
29+
2530
web:
2631
build: .
2732
image: pythondotorg:docker-compose

docs/source/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ General information
1010
:Issue tracker: https://github.com/python/pythondotorg/issues
1111
:Mailing list: pydotorg-www_
1212
:IRC: ``#pydotorg`` on Freenode
13-
:Staging site: https://staging.python.org/ (``main`` branch)
1413
:Production configuration: https://github.com/python/psf-salt
1514
:GitHub Actions:
1615
.. image:: https://github.com/python/pythondotorg/actions/workflows/ci.yml/badge.svg

docs/source/install.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ web_1 | Starting development server at http://0.0.0.0:8000/
5555
web_1 | Quit the server with CONTROL-C.
5656
```
5757

58-
You can view these results in your local web browser at: `http://localhost:8000`
58+
You can view these results in your local web browser at: <http://localhost:8000>
5959

6060
To reset your local environment, run:
6161

@@ -88,7 +88,7 @@ This is a simple wrapper around running `python manage.py` in the container, all
8888
Manual setup
8989
------------
9090

91-
First, install [PostgreSQL](https://www.postgresql.org/download/) on your machine and run it. *pythondotorg* currently uses Postgres 10.21.
91+
First, install [PostgreSQL](https://www.postgresql.org/download/) on your machine and run it. *pythondotorg* currently uses Postgres 15.x.
9292

9393
Then clone the repository:
9494

@@ -99,7 +99,7 @@ $ git clone git://github.com/python/pythondotorg.git
9999
Then create a virtual environment:
100100

101101
```
102-
$ python3.9 -m venv venv
102+
$ python3 -m venv venv
103103
```
104104

105105
And then you'll need to install dependencies. You don't need to use `pip3` inside a Python 3 virtual environment:

events/models.py

+23-2
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,20 @@ def next_time(self):
181181
except IndexError:
182182
return None
183183

184+
def is_scheduled_to_start_this_year(self) -> bool:
185+
if self.next_time:
186+
current_year: int = timezone.now().year
187+
if self.next_time.dt_start.year == current_year:
188+
return True
189+
return False
190+
191+
def is_scheduled_to_end_this_year(self) -> bool:
192+
if self.next_time:
193+
current_year: int = timezone.now().year
194+
if self.next_time.dt_end.year == current_year:
195+
return True
196+
return False
197+
184198
@property
185199
def previous_time(self):
186200
now = timezone.now()
@@ -211,8 +225,15 @@ def previous_time(self):
211225
return None
212226

213227
@property
214-
def next_or_previous_time(self):
215-
return self.next_time or self.previous_time
228+
def next_or_previous_time(self) -> models.Model:
229+
"""Return the next or previous time of the event OR the occurring rule."""
230+
if next_time := self.next_time:
231+
return next_time
232+
233+
if previous_time := self.previous_time:
234+
return previous_time
235+
236+
return self.occurring_rule if hasattr(self, "occurring_rule") else None
216237

217238
@property
218239
def is_past(self):

events/tests/test_models.py

+60-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import datetime
2+
from types import SimpleNamespace
3+
from unittest.mock import patch
24

35
from django.contrib.auth import get_user_model
46
from django.test import TestCase
@@ -62,7 +64,6 @@ def test_recurring_event(self):
6264
self.assertEqual(self.event.next_time.dt_start, recurring_time_dtstart)
6365
self.assertTrue(rt.valid_dt_end())
6466

65-
6667
rt.begin = now - datetime.timedelta(days=5)
6768
rt.finish = now - datetime.timedelta(days=3)
6869
rt.save()
@@ -186,3 +187,61 @@ def test_event_previous_event(self):
186187
# 'Event.previous_event' can return None if there is no
187188
# OccurringRule or RecurringRule found.
188189
self.assertIsNone(self.event.previous_event)
190+
191+
def test_scheduled_to_start_this_year_method(self):
192+
test_datetime = SimpleNamespace(
193+
now=lambda: timezone.datetime(timezone.now().year,
194+
6, 1, tzinfo=timezone.now().tzinfo)
195+
)
196+
197+
with patch("django.utils.timezone", new=test_datetime) as mock_timezone:
198+
with patch("events.models.timezone", new=test_datetime):
199+
now = seconds_resolution(mock_timezone.now())
200+
201+
occurring_time_dtstart = now + datetime.timedelta(days=1)
202+
OccurringRule.objects.create(
203+
event=self.event,
204+
dt_start=occurring_time_dtstart,
205+
dt_end=occurring_time_dtstart + datetime.timedelta(days=3)
206+
)
207+
self.assertTrue(self.event.is_scheduled_to_start_this_year())
208+
209+
OccurringRule.objects.get(event=self.event).delete()
210+
211+
event_not_scheduled_to_start_this_year_occurring_time_dtstart = now + datetime.timedelta(days=365)
212+
OccurringRule.objects.create(
213+
event=self.event,
214+
dt_start=event_not_scheduled_to_start_this_year_occurring_time_dtstart,
215+
dt_end=event_not_scheduled_to_start_this_year_occurring_time_dtstart + datetime.timedelta(days=3)
216+
)
217+
218+
self.assertFalse(self.event.is_scheduled_to_start_this_year())
219+
220+
def test_scheduled_to_end_this_year_method(self):
221+
test_datetime = SimpleNamespace(
222+
now=lambda: timezone.datetime(timezone.now().year,
223+
6, 1, tzinfo=timezone.now().tzinfo)
224+
)
225+
226+
with patch("django.utils.timezone", new=test_datetime) as mock_timezone:
227+
with patch("events.models.timezone", new=test_datetime):
228+
now = seconds_resolution(mock_timezone.now())
229+
occurring_time_dtstart = now + datetime.timedelta(days=1)
230+
231+
OccurringRule.objects.create(
232+
event=self.event,
233+
dt_start=occurring_time_dtstart,
234+
dt_end=occurring_time_dtstart
235+
)
236+
237+
self.assertTrue(self.event.is_scheduled_to_end_this_year())
238+
239+
OccurringRule.objects.get(event=self.event).delete()
240+
241+
OccurringRule.objects.create(
242+
event=self.event,
243+
dt_start=now,
244+
dt_end=now + datetime.timedelta(days=365)
245+
)
246+
247+
self.assertFalse(self.event.is_scheduled_to_end_this_year())

0 commit comments

Comments
 (0)