Repository navigation
Add a /commitfests.ics feed #118
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| {%extends "base.html"%} | ||
| {%block contents%} | ||
| <p><a href="/commitfests.ics">Subscribe to Commitfest dates (ICS)</a></p> | ||
| <ul> | ||
| {%for c in commitfests%} | ||
| <li><a href="/{{c.id}}/">{{c}}</a> ({{c.statusstring}} - {{c.periodstring}})</li> | ||
| {%endfor%} | ||
| </ul> | ||
| <br/> | ||
| {%endblock%} | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| {%extends "base.html"%} | ||
| {%block contents%} | ||
| <p><a href="/commitfests.ics">Subscribe to Commitfest dates (ICS)</a></p> | ||
| <ul> | ||
| {%for c in commitfests%} | ||
| <li><a href="/{{c.id}}/">{{c}}</a> ({{c.statusstring}}{%if c.startdate%} - {{c.periodstring}}{%endif%})</li> | ||
| {%endfor%} | ||
| </ul> | ||
| {%endblock%} | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| """ | ||
| Tests for the /commitfests.ics calendar feed. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from datetime import timedelta | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| import pytest | ||
| from icalendar import Calendar | ||
|
|
||
| if TYPE_CHECKING: | ||
| from pgcommitfest.commitfest.models import CommitFest | ||
|
|
||
| pytestmark = pytest.mark.django_db | ||
|
|
||
|
|
||
| def test_commitfests_ics(client, commitfests: dict[str, CommitFest]): | ||
| """ | ||
| Every non-draft commitfest, regardless of status, shows up as an all-day | ||
| VEVENT with DTEND being the day after enddate (exclusive). | ||
| """ | ||
| commitfests = {k: cf for k, cf in commitfests.items() if not cf.draft} | ||
|
|
||
| response = client.get("/commitfests.ics") | ||
| assert response.status_code == 200 | ||
| assert response["Content-Type"] == "text/calendar; charset=utf-8" | ||
|
|
||
| events = Calendar.from_ical(response.content).walk("VEVENT") | ||
| assert len(events) == len(commitfests) | ||
| events_by_uid = {str(event.uid): event for event in events} | ||
|
|
||
| for cf in commitfests.values(): | ||
| event = events_by_uid[f"commitfest-{cf.name}@commitfest.postgresql.org"] | ||
| assert event.summary == f"Commitfest {cf.name}" | ||
| assert event.url == f"https://commitfest.postgresql.org/{cf.pk}/" | ||
| assert event.description == f"Status: {cf.statusstring}" | ||
| assert event.start == cf.startdate | ||
| assert event.end == cf.enddate + timedelta(days=1) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ readme = "README.md" | |
| license = "PostgreSQL" | ||
| dependencies = [ | ||
| "django>=5.2,<6.0", | ||
| "icalendar", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't actually use pyproject.toml dependencies in prod/staging. We'd need infra to install the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I requested this on the sysadmins list |
||
| "psycopg2", | ||
| "simplejson", | ||
| "requests", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does "all-day' have timezone? If so it should be UTC.