Skip to content

release: push latest changes #2620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ updates:
- 0.13.0
- 0.13.1
- 0.13.2
- dependency-name: "boto3"
- dependency-name: "boto3-stubs"
- dependency-name: "botocore"
- dependency-name: "botocore-stubs"
- dependency-name: lxml
versions:
- 4.6.2
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: CI
on: [push, pull_request]
jobs:
test:
# Avoid running CI more than once on pushes to main repo open PRs
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
services:
postgres:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Check collectstatic
on: [push, pull_request]
jobs:
test:
collectstatic:
# Avoid running CI more than once on pushes to main repo open PRs
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Check out repository
Expand Down
10 changes: 10 additions & 0 deletions Dockerfile.static
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM ruby:2.7.8-bullseye AS static

RUN mkdir /code
WORKDIR /code

COPY Gemfile Gemfile.lock /code/

RUN bundle install

COPY . /code
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
source "https://rubygems.org"

group :media do
gem "compass", "~>0.12.2"
gem "sass", "~>3.2.5"
gem "susy", "~>1.0.5"
gem "compass", "~>0.12.7"
gem "sass", "~>3.2.19"
gem "susy", "~>1.0.9"
end

group :development do
Expand Down
19 changes: 11 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
GEM
remote: https://rubygems.org/
specs:
chunky_png (1.2.7)
compass (0.12.2)
chunky_png (1.4.0)
compass (0.12.7)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
sass (~> 3.2.19)
foreman (0.61.0)
thor (>= 0.13.6)
fssm (0.2.10)
sass (3.2.6)
susy (1.0.5)
sass (3.2.19)
susy (1.0.9)
compass (>= 0.12.2)
sass (>= 3.2.0)
thor (0.17.0)
Expand All @@ -19,7 +19,10 @@ PLATFORMS
ruby

DEPENDENCIES
compass (~> 0.12.2)
compass (~> 0.12.7)
foreman (~> 0.61.0)
sass (~> 3.2.5)
susy (~> 1.0.5)
sass (~> 3.2.19)
susy (~> 1.0.9)

BUNDLED WITH
2.1.4
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ release: python manage.py migrate --noinput
web: bin/start-nginx gunicorn -c gunicorn.conf pydotorg.wsgi
worker: celery -A pydotorg worker -l INFO
worker-beat: celery -A pydotorg beat -l INFO --scheduler django_celery_beat.schedulers:DatabaseScheduler
postdeploy: python manage.py postdeploy
10 changes: 5 additions & 5 deletions base-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dj-database-url==0.5.0
django-pipeline==3.0.0 # 3.0.0 is first version that supports Django 4.2
django-pipeline==3.1.0 # 3.0.0 is first version that supports Django 4.2
django-sitetree==1.18.0 # >=1.17.1 is (?) first version that supports Django 4.2
django-apptemplates==1.5
django-admin-interface==0.24.2
django-admin-interface==0.28.9
django-translation-aliases==0.1.0
Django==4.2.16
docutils==0.21.2
Expand All @@ -11,10 +11,10 @@ cmarkgfm==0.6.0
Pillow==10.4.0
psycopg2-binary==2.9.9
python3-openid==3.2.0
python-decouple==3.4
python-decouple==3.8
# lxml used by BeautifulSoup.
lxml==5.2.2
cssselect==1.1.0
cssselect==1.2.0
feedparser==6.0.11
beautifulsoup4==4.12.3
icalendar==4.0.7
Expand All @@ -26,7 +26,7 @@ django-imagekit==5.0 # 5.0 is first version that supports Django 4.2
django-haystack==3.2.1
elasticsearch>=7,<8
# TODO: 0.14.0 only supports Django 1.8 and 1.11.
django-tastypie==0.14.6 # 0.14.6 is first version that supports Django 4.2
django-tastypie==0.14.7 # 0.14.6 is first version that supports Django 4.2

pytz==2021.1
python-dateutil==2.8.2
Expand Down
3 changes: 3 additions & 0 deletions bin/static
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
cd static
bundle exec sass --compass --scss -I $(dirname $(dirname $(gem which susy))) --trace --watch sass:sass
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Required for running tests

factory-boy==3.2.1
factory-boy==3.3.1
Faker==0.8.1
tblib==1.7.0
responses==0.13.3
Expand Down
9 changes: 7 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.9"

services:
postgres:
image: postgres:15.3-bullseye
Expand All @@ -22,6 +20,13 @@ services:
test: ["CMD", "redis-cli","ping"]
interval: 1s

static:
command: bin/static
build:
dockerfile: Dockerfile.static
volumes:
- .:/code

web:
build: .
image: pythondotorg:docker-compose
Expand Down
1 change: 0 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ General information
:Issue tracker: https://github.com/python/pythondotorg/issues
:Mailing list: pydotorg-www_
:IRC: ``#pydotorg`` on Freenode
:Staging site: https://staging.python.org/ (``main`` branch)
:Production configuration: https://github.com/python/psf-salt
:GitHub Actions:
.. image:: https://github.com/python/pythondotorg/actions/workflows/ci.yml/badge.svg
Expand Down
6 changes: 3 additions & 3 deletions docs/source/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ web_1 | Starting development server at http://0.0.0.0:8000/
web_1 | Quit the server with CONTROL-C.
```

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

To reset your local environment, run:

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

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

Then clone the repository:

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

```
$ python3.9 -m venv venv
$ python3 -m venv venv
```

And then you'll need to install dependencies. You don't need to use `pip3` inside a Python 3 virtual environment:
Expand Down
25 changes: 23 additions & 2 deletions events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@ def next_time(self):
except IndexError:
return None

def is_scheduled_to_start_this_year(self) -> bool:
if self.next_time:
current_year: int = timezone.now().year
if self.next_time.dt_start.year == current_year:
return True
return False

def is_scheduled_to_end_this_year(self) -> bool:
if self.next_time:
current_year: int = timezone.now().year
if self.next_time.dt_end.year == current_year:
return True
return False

@property
def previous_time(self):
now = timezone.now()
Expand Down Expand Up @@ -211,8 +225,15 @@ def previous_time(self):
return None

@property
def next_or_previous_time(self):
return self.next_time or self.previous_time
def next_or_previous_time(self) -> models.Model:
"""Return the next or previous time of the event OR the occurring rule."""
if next_time := self.next_time:
return next_time

if previous_time := self.previous_time:
return previous_time

return self.occurring_rule if hasattr(self, "occurring_rule") else None

@property
def is_past(self):
Expand Down
61 changes: 60 additions & 1 deletion events/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import datetime
from types import SimpleNamespace
from unittest.mock import patch

from django.contrib.auth import get_user_model
from django.test import TestCase
Expand Down Expand Up @@ -62,7 +64,6 @@ def test_recurring_event(self):
self.assertEqual(self.event.next_time.dt_start, recurring_time_dtstart)
self.assertTrue(rt.valid_dt_end())


rt.begin = now - datetime.timedelta(days=5)
rt.finish = now - datetime.timedelta(days=3)
rt.save()
Expand Down Expand Up @@ -186,3 +187,61 @@ def test_event_previous_event(self):
# 'Event.previous_event' can return None if there is no
# OccurringRule or RecurringRule found.
self.assertIsNone(self.event.previous_event)

def test_scheduled_to_start_this_year_method(self):
test_datetime = SimpleNamespace(
now=lambda: timezone.datetime(timezone.now().year,
6, 1, tzinfo=timezone.now().tzinfo)
)

with patch("django.utils.timezone", new=test_datetime) as mock_timezone:
with patch("events.models.timezone", new=test_datetime):
now = seconds_resolution(mock_timezone.now())

occurring_time_dtstart = now + datetime.timedelta(days=1)
OccurringRule.objects.create(
event=self.event,
dt_start=occurring_time_dtstart,
dt_end=occurring_time_dtstart + datetime.timedelta(days=3)
)
self.assertTrue(self.event.is_scheduled_to_start_this_year())

OccurringRule.objects.get(event=self.event).delete()

event_not_scheduled_to_start_this_year_occurring_time_dtstart = now + datetime.timedelta(days=365)
OccurringRule.objects.create(
event=self.event,
dt_start=event_not_scheduled_to_start_this_year_occurring_time_dtstart,
dt_end=event_not_scheduled_to_start_this_year_occurring_time_dtstart + datetime.timedelta(days=3)
)

self.assertFalse(self.event.is_scheduled_to_start_this_year())

def test_scheduled_to_end_this_year_method(self):
test_datetime = SimpleNamespace(
now=lambda: timezone.datetime(timezone.now().year,
6, 1, tzinfo=timezone.now().tzinfo)
)

with patch("django.utils.timezone", new=test_datetime) as mock_timezone:
with patch("events.models.timezone", new=test_datetime):
now = seconds_resolution(mock_timezone.now())
occurring_time_dtstart = now + datetime.timedelta(days=1)

OccurringRule.objects.create(
event=self.event,
dt_start=occurring_time_dtstart,
dt_end=occurring_time_dtstart
)

self.assertTrue(self.event.is_scheduled_to_end_this_year())

OccurringRule.objects.get(event=self.event).delete()

OccurringRule.objects.create(
event=self.event,
dt_start=now,
dt_end=now + datetime.timedelta(days=365)
)

self.assertFalse(self.event.is_scheduled_to_end_this_year())
Loading