Skip to content

Introduce Drafts page and automatic CF creation #70

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
46 changes: 46 additions & 0 deletions pgcommitfest/commitfest/apiv1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from django.http import (
HttpResponse,
)

import json
from datetime import date, datetime, timedelta, timezone

from .models import (
CommitFest,
)


def datetime_serializer(obj):
if isinstance(obj, date):
return obj.isoformat()

if isinstance(obj, datetime):
return obj.replace(tzinfo=timezone.utc).isoformat()

if hasattr(obj, "to_json"):
return obj.to_json()

raise TypeError(f"Type {type(obj)} not serializable to JSON")


def api_response(payload, status=200, content_type="application/json"):
response = HttpResponse(
json.dumps(payload, default=datetime_serializer), status=status
)
response["Content-Type"] = content_type
response["Access-Control-Allow-Origin"] = "*"
return response


def commitfestst_that_need_ci(request):
cfs = CommitFest.relevant_commitfests()

# We continue to run CI on the previous commitfest for a week after it ends
# to give people some time to move patches over to the next one.
if cfs["previous"].enddate <= datetime.now(timezone.utc).date() - timedelta(days=7):
del cfs["previous"]

del cfs["next_open"]
del cfs["final"]

return api_response({"commitfests": cfs})
36 changes: 36 additions & 0 deletions pgcommitfest/commitfest/fixtures/auth_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,41 @@
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 6,
"fields": {
"password": "",
"last_login": null,
"is_superuser": false,
"username": "prolific-author",
"first_name": "Prolific",
"last_name": "Author",
"email": "",
"is_staff": false,
"is_active": true,
"date_joined": "2025-01-01T00:00:00",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 7,
"fields": {
"password": "",
"last_login": null,
"is_superuser": false,
"username": "prolific-reviewer",
"first_name": "Prolific",
"last_name": "Reviewer",
"email": "",
"is_staff": false,
"is_active": true,
"date_joined": "2025-01-01T00:00:00",
"groups": [],
"user_permissions": []
}
}
]
91 changes: 80 additions & 11 deletions pgcommitfest/commitfest/fixtures/commitfest_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,44 @@
"model": "commitfest.commitfest",
"pk": 1,
"fields": {
"name": "Sample Old Commitfest",
"name": "PG18-3",
"status": 4,
"startdate": "2024-05-01",
"enddate": "2024-05-31"
"startdate": "2024-11-01",
"enddate": "2024-11-30",
"draft": false
}
},
{
"model": "commitfest.commitfest",
"pk": 2,
"fields": {
"name": "Sample In Progress Commitfest",
"name": "PG18-4",
"status": 3,
"startdate": "2025-01-01",
"enddate": "2025-02-28"
"enddate": "2025-01-31",
"draft": false
}
},
{
"model": "commitfest.commitfest",
"pk": 3,
"fields": {
"name": "Sample Open Commitfest",
"name": "PG18-Final",
"status": 2,
"startdate": "2025-03-01",
"enddate": "2025-03-31"
"enddate": "2025-03-31",
"draft": false
}
},
{
"model": "commitfest.commitfest",
"pk": 4,
"fields": {
"name": "Sample Future Commitfest",
"status": 1,
"startdate": "2025-05-01",
"enddate": "2025-05-31"
"name": "PG18-Drafts",
"status": 2,
"startdate": "2024-03-01",
"enddate": "2025-02-28",
"draft": true
}
},
{
Expand Down Expand Up @@ -237,6 +241,33 @@
]
}
},
{
"model": "commitfest.patch",
"pk": 8,
"fields": {
"name": "Test DGJ Multi-Author and Reviewer",
"topic": 3,
"wikilink": "",
"gitlink": "",
"targetversion": 1,
"committer": 4,
"created": "2025-02-01T00:00:00",
"modified": "2025-02-01T00:00:00",
"lastmail": "2025-02-01T00:00:00",
"authors": [
3,
6
],
"reviewers": [
1,
7
],
"subscribers": [],
"mailthread_set": [
8
]
}
},
{
"model": "commitfest.patchoncommitfest",
"pk": 1,
Expand Down Expand Up @@ -325,6 +356,17 @@
"status": 1
}
},
{
"model": "commitfest.patchoncommitfest",
"pk": 9,
"fields": {
"patch": 8,
"commitfest": 4,
"enterdate": "2025-02-01T00:00:00",
"leavedate": null,
"status": 1
}
},
{
"model": "commitfest.patchhistory",
"pk": 1,
Expand Down Expand Up @@ -632,6 +674,33 @@
"latestmsgid": "example@message-31"
}
},
{
"model": "commitfest.mailthread",
"pk": 8,
"fields": {
"messageid": "dgj-example@message-08",
"subject": "Test DGJ Multi-Author and Reviewer",
"firstmessage": "2025-02-01T00:00:00",
"firstauthor": "[email protected]",
"latestmessage": "2025-02-01T00:00:00",
"latestauthor": "[email protected]",
"latestsubject": "Test DGJ Multi-Author and Reviewer",
"latestmsgid": "dgj-example@message-08"
}
},
{
"model": "commitfest.mailthreadattachment",
"pk": 8,
"fields": {
"mailthread": 8,
"messageid": "dgj-example@message-08",
"attachmentid": 1,
"filename": "v1-0001-content.patch",
"date": "2025-02-01T00:00:00",
"author": "[email protected]",
"ispatch": true
}
},
{
"model": "commitfest.patchstatus",
"pk": 1,
Expand Down
51 changes: 51 additions & 0 deletions pgcommitfest/commitfest/migrations/0011_add_draft_remove_future.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Generated by Django 4.2.19 on 2025-06-08 10:47

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("commitfest", "0010_add_failing_since_column"),
]

operations = [
migrations.AddField(
model_name="commitfest",
name="draft",
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name="commitfest",
name="status",
field=models.IntegerField(
choices=[(2, "Open"), (3, "In Progress"), (4, "Closed")], default=2
),
),
migrations.AlterField(
model_name="commitfest",
name="enddate",
field=models.DateField(),
),
migrations.AlterField(
model_name="commitfest",
name="startdate",
field=models.DateField(),
),
migrations.AlterField(
model_name="patchoncommitfest",
name="status",
field=models.IntegerField(
choices=[
(1, "Needs review"),
(2, "Waiting on Author"),
(3, "Ready for Committer"),
(4, "Committed"),
(5, "Moved to different CF"),
(6, "Rejected"),
(7, "Returned with feedback"),
(8, "Withdrawn"),
],
default=1,
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("commitfest", "0011_add_draft_remove_future"),
]
operations = [
migrations.RunSQL(
"""
CREATE UNIQUE INDEX cf_enforce_maxoneopen_idx
ON commitfest_commitfest (status, draft)
WHERE status not in (1,4);
""",
reverse_sql="""
DROP INDEX IF EXISTS cf_enforce_maxoneopen_idx;
""",
),
migrations.RunSQL(
"""
CREATE UNIQUE INDEX poc_enforce_maxoneoutcome_idx
ON commitfest_patchoncommitfest (patch_id)
WHERE status not in (5);
""",
reverse_sql="""
DROP INDEX IF EXISTS poc_enforce_maxoneoutcome_idx;
""",
),
migrations.RunSQL(
"""
ALTER TABLE commitfest_patchoncommitfest
ADD CONSTRAINT status_and_leavedate_correlation
CHECK ((status IN (4,5,6,7,8)) = (leavedate IS NOT NULL));
""",
reverse_sql="""
ALTER TABLE commitfest_patchoncommitfest
DROP CONSTRAINT IF EXISTS status_and_leavedate_correlation;
""",
),
migrations.RunSQL(
"""
COMMENT ON COLUMN commitfest_patchoncommitfest.leavedate IS
$$A leave date is recorded in two situations, both of which
means this particular patch-cf combination became inactive
on the corresponding date. For status 5 the patch was moved
to some other cf. For 4,6,7, and 8, this was the final cf.
$$
""",
reverse_sql="""
COMMENT ON COLUMN commitfest_patchoncommitfest.leavedate IS NULL;
""",
),
migrations.RunSQL(
"""
COMMENT ON TABLE commitfest_patchoncommitfest IS
$$This is a re-entrant table: patches may become associated
with a given cf multiple times, resetting the entrydate and clearing
the leavedate each time. Non-final statuses never have a leavedate
while final statuses always do. The final status of 5 (moved) is
special in that all but one of the rows a patch has in this table
must have it as the status.
$$
""",
reverse_sql="""
COMMENT ON TABLE commitfest_patchoncommitfest IS NULL;
""",
),
]
Loading