Skip to content
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

Jelte's not-yet-deployed commits #7

Open
wants to merge 12 commits into
base: prod-mirror
Choose a base branch
from
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# top-most EditorConfig file
root = true

# basic rules for all files
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{py,js}]
indent_style = space
indent_size = 4

[*.html]
indent_style = space
indent_size = 1
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ A commitfest is a collection of patches and reviews for a project and is part of

## The Application

This is a Django 3.2 application backed by PostgreSQL and running on Python 3.x.
This is a Django 4.2 application backed by PostgreSQL and running on Python 3.x.

## Getting Started

### Ubuntu instructions

#### Install Dependencies / Configure Environment

First, prepare your development environment by installing pip, virtualenv, and postgresql-server-dev-X.Y.

```bash
Expand Down Expand Up @@ -45,12 +47,24 @@ be provided.
./manage.py migrate
```

You'll need either a database dump of the actual server's data or else to create a superuser:
#### Load data
For a quick start, you can load some dummy data into the database. Here's how you do that:

```
./manage.py loaddata auth_data.json
./manage.py loaddata commitfest_data.json
```

If you do this, the admin username and password are `admin` and `admin`.

On the other hand, if you'd like to start from scratch instead, you can run the following command to create
a super user:

```bash
./manage.py createsuperuser
```

#### Start application
Finally, you're ready to start the application:

```bash
Expand All @@ -69,3 +83,11 @@ codestyle.
ln -s ../../tools/githook/pre-commit .git/hooks/

```

If you'd like to regenerate the database dump files, you can run the following commands:
```
./manage.py dumpdata auth --format=json --indent=4 --exclude=auth.permission > pgcommitfest/commitfest/fixtures/auth_data.json
./manage.py dumpdata commitfest --format=json --indent=4 > pgcommitfest/commitfest/fixtures/commitfest_data.json
```

If you want to reload data from dump file, you can run `drop owned by postgres;` in the `pgcommitfest` database first.
8 changes: 8 additions & 0 deletions media/commitfest/css/commitfest.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@ div.form-group div.controls input.threadpick-input {
#annotateMessageBody.loading * {
display: none;
}

.cfbot-summary img {
margin-top: -3px;
}

.github-logo {
height: 20px;
}
1 change: 1 addition & 0 deletions media/commitfest/github-mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion media/commitfest/js/commitfest.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ function flagCommitted(committer) {


function sortpatches(sortby) {
$('#id_sortkey').val(sortby);
if ($('#id_sortkey').val() == sortby) {
$('#id_sortkey').val(0);
} else {
$('#id_sortkey').val(sortby);
}
$('#filterform').submit();

return false;
Expand Down Expand Up @@ -306,3 +310,10 @@ function searchUserListChanged() {
$('#doSelectUserButton').addClass('disabled');
}
}

function addGitCheckoutToClipboard(patchId) {
navigator.clipboard.writeText(`git remote add commitfest https://github.com/postgresql-cfbot/postgresql.git
git fetch commitfest cf/${patchId}
git checkout commitfest/cf/${patchId}
`);
}
4 changes: 4 additions & 0 deletions media/commitfest/needs_rebase_success.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions media/commitfest/new_failure.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions media/commitfest/new_success.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions media/commitfest/old_failure.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions media/commitfest/old_success.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions media/commitfest/running.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions media/commitfest/waiting_to_start.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions pgcommitfest/commitfest/ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import requests
import json
import textwrap
import re

from pgcommitfest.auth import user_search
from .models import CommitFest, Patch, MailThread, MailThreadAttachment
Expand All @@ -23,7 +24,26 @@ class Http503(Exception):
pass


def mockArchivesAPI(path):
with open(settings.MOCK_ARCHIVE_DATA, 'r', encoding='utf-8') as file:
data = json.load(file)
for message in data:
message['atts'] = []

message_pattern = re.compile(r"^/message-id\.json/(?P<message_id>[^/]+)$")

message_match = message_pattern.match(path)
if message_match:
message_id = message_match.group("message_id")
return [message for message in data if message['msgid'] == message_id]
else:
return data


def _archivesAPI(suburl, params=None):
if getattr(settings, 'MOCK_ARCHIVES', False) and getattr(settings, 'MOCK_ARCHIVE_DATA'):
return mockArchivesAPI(suburl)

try:
resp = requests.get(
"http{0}://{1}:{2}{3}".format(settings.ARCHIVES_PORT == 443 and 's' or '',
Expand Down
Loading