Skip to content

Commit

Permalink
release: push latest changes (#2620)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
5 people authored Sep 30, 2024
1 parent 2691034 commit 733d59c
Show file tree
Hide file tree
Showing 31 changed files with 1,077 additions and 810 deletions.
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

0 comments on commit 733d59c

Please sign in to comment.