Skip to content

Commit 008839a

Browse files
committed
Merge branch 'main' into nav-active
2 parents 5b9545d + 873a048 commit 008839a

51 files changed

Lines changed: 527 additions & 519 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/skills/docs/SKILL.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: docs
33
description: Update, review, or build the Sphinx documentation for Democrasite
44
disable-model-invocation: true
5-
argument-hint: "[what to update or check, e.g. 'review for accuracy' or 'add activitypub section']"
5+
argument-hint: "[what to update or check, e.g. 'review for accuracy' or 'add social section']"
66
---
77

88
## Task
@@ -30,7 +30,7 @@ docs/
3030
├── democrasite.webiscite.views.rst
3131
├── democrasite.webiscite.api.rst
3232
├── democrasite.users.rst
33-
├── democrasite.activitypub.rst
33+
├── democrasite.social.rst
3434
└── … (one file per module)
3535
```
3636

@@ -41,14 +41,15 @@ All run from the `docs/` directory (or with `make -C docs <target>`):
4141
| Command | What it does |
4242
|---|---|
4343
| `make apidocs` | Regenerate all `docs/api/*.rst` from source using sphinx-apidoc. Run this whenever Python modules are added or removed. |
44-
| `make livehtml` | Build docs and serve with live reload at http://localhost:9000. Requires the docs Docker container (`docker compose -f docker-compose.docs.yml up`). |
44+
| `make livehtml` | Build docs and serve with live reload at http://localhost:9000. Run inside the `docs` service (started with `just up`; see `docker-compose.local.yml`). |
4545
| `make clean` | Remove `_build/` and `api/` directories for a fresh build. |
4646
| `make html` | One-off HTML build into `_build/html/`. |
4747

48-
To serve with live reload locally (in Docker):
48+
To serve with live reload locally (in Docker), start the stack so the `docs` service runs (from repo root):
4949
```
50-
docker compose -f docker-compose.docs.yml up
50+
just up
5151
```
52+
The `docs` container runs `make livehtml` via `compose/local/django/start-docs`.
5253

5354
To regenerate API docs locally (sphinx-apidoc must be installed):
5455
```
@@ -98,7 +99,7 @@ Line length: 88 characters (enforced by ruff). Wrap long docstring lines to stay
9899
- `:class:\`~democrasite.webiscite.models.Bill\`` — class link
99100
- `:func:\`~democrasite.webiscite.tasks.submit_bill\`` — function link
100101
- `:meth:\`~democrasite.webiscite.webhooks.PullRequestHandler.opened\`` — method link
101-
3. Verify the build: `docker compose -f docker-compose.docs.yml up`
102+
3. Verify the build: `just up` and open http://localhost:9000/
102103

103104
### Adding a new Python module
104105
1. Write a module-level docstring at the top of the file

CLAUDE.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ All development uses Docker. The `justfile` sets `COMPOSE_FILE=docker-compose.lo
2222
just build # Build Docker images
2323
just up # Start all containers
2424
just down # Stop containers
25-
just test # Run pytest suite
25+
just test <args> # Run pytest suite
2626
just lint # Run pre-commit hooks
2727
just typecheck # Run mypy
2828
just manage <args> # Run manage.py (e.g., just manage makemigrations)
@@ -31,16 +31,18 @@ just coverage # Run tests with coverage + open HTML report
3131
just shell # Bash shell in django container
3232
just pyshell # Django shell_plus (IPython)
3333
just run <cmd> # Execute arbitrary command in django container
34-
just loaddata # Load fixtures (democrasite + activitypub)
34+
just loaddata # Load fixtures (democrasite + social)
3535
```
3636

37-
To run a single test file or test:
37+
To run a single test:
3838

3939
```bash
40-
just run pytest democrasite/webiscite/tests/test_models.py
41-
just run pytest democrasite/webiscite/tests/test_models.py::TestBill::test_method_name -v
40+
just test democrasite/webiscite/tests/test_models.py::TestBill::test_method_name -v
4241
```
4342

43+
For any `just` command, prefer running outside the sandbox to avoid `docker.sock`
44+
permission errors. If `just` is not found, run `conda env democrasite` first.
45+
4446
Pytest is configured with `--ds=config.settings.test --reuse-db` in `pyproject.toml`.
4547

4648
## Architecture
@@ -49,7 +51,7 @@ Pytest is configured with `--ds=config.settings.test --reuse-db` in `pyproject.t
4951

5052
- **`democrasite/webiscite/`** — Core app. Models: `PullRequest`, `Bill`, `Vote`. Handles GitHub webhooks, voting logic, constitution enforcement, and Celery tasks for auto-merging.
5153
- **`democrasite/users/`** — Custom `User` model (extends `AbstractUser` with single `name` field instead of first/last). OAuth integration.
52-
- **`democrasite/activitypub/`**ActivityPub federation. Models: `Person` (linked to User with keypair), `Follow`.
54+
- **`democrasite/social/`**Social network for short notes. Models: `Person` (linked to User with keypair), `Follow`.
5355

5456
### Configuration
5557

@@ -60,9 +62,9 @@ Pytest is configured with `--ds=config.settings.test --reuse-db` in `pyproject.t
6062

6163
### Key Patterns
6264

63-
- **Constitution system** (`webiscite/constitution.py`, `constitution.json`): Maps files to protected line ranges. PRs touching protected code become "constitutional" bills requiring supermajority. Line numbers auto-update after merges.
64-
- **Bill lifecycle**: OPEN → APPROVED/REJECTED/FAILED/CLOSED. Each Bill has a OneToOne to a Celery `PeriodicTask` that runs `submit_bill()` at voting period end.
65-
- **Webhook flow** (`webiscite/webhooks.py`): GitHub push events → HMAC validation → create/update `PullRequest` → create `Bill`.
65+
- **Constitution system** (`democrasite/webiscite/constitution.py`, repo-root `constitution.json`): Maps files to protected line ranges. PRs touching protected code become "constitutional" bills requiring supermajority. Line numbers auto-update after merges.
66+
- **Bill lifecycle**: Draft PRs yield `DRAFT` bills until `ready_for_review`; then `OPEN` → APPROVED/REJECTED/FAILED/CLOSED (or `AMENDED` if the PR branch changes during voting). Each Bill has a OneToOne to a Celery Beat `PeriodicTask` that runs `submit_bill()` at voting period end.
67+
- **Webhook flow** (`democrasite/webiscite/webhooks.py`): GitHub `pull_request` webhooks (open, reopen, close, synchronize, ready_for_review, etc.) → HMAC validation → create/update `PullRequest` and `Bill` as appropriate. `push` and `ping` are accepted with minimal handling.
6668
- **Vote constraints**: One vote per user per bill (DB unique constraint). Votes can be changed.
6769
- **Audit trail**: `django-simple-history` tracks changes on key models.
6870

CONTRIBUTING.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ Creating a Webhook
120120

121121
:obj:`democrasite.webiscite` needs `webhooks`_ to find out about events on
122122
Github. `Create a webhook`_ in your fork of the repository, then generate a
123-
secret key for your hook and store it in your environment (either through your
124-
terminal or ``.env`` file) as ``GITHUB_SECRET_KEY``.
123+
secret key for your hook and store it in ``.envs/.local/.django`` (or your shell) as
124+
``GITHUB_WEBHOOK_SECRET`` so it matches the secret configured on GitHub.
125125

126126
To test your webhook, follow these `instructions`_. (If you have a preferred
127127
tool for exposing your local server, feel free to replace smee with it.) If you

README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Democrasite
1212
.. |Continuous integration| image:: https://github.com/mfosterw/cookiestocracy/actions/workflows/ci.yml/badge.svg
1313
:target: https://github.com/mfosterw/cookiestocracy/actions/workflows/ci.yml
1414

15-
.. |Coverage report| image:: https://codecov.io/gh/mfosterw/cookiestocracy/branch/master/graph/badge.svg?token=NPV1TLXZIW
15+
.. |Coverage report| image:: https://codecov.io/gh/mfosterw/cookiestocracy/graph/badge.svg?token=NPV1TLXZIW
1616
:target: https://codecov.io/gh/mfosterw/cookiestocracy
1717

1818
.. |Documentation status| image:: https://readthedocs.org/projects/cookiestocracy/badge/?version=latest
@@ -74,7 +74,7 @@ following the instructions in the guide.
7474
Understanding the repository
7575
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7676

77-
Check out ``repo_map.txt`` in the root of the repository for a display of the
77+
Check out ``repository_map.txt`` in the root of the repository for a display of the
7878
repository layout and brief explanations for the purpose of each non-obvious file and
7979
directory.
8080

@@ -94,7 +94,7 @@ Loading initial data
9494

9595
To load some initial sample data into the database, run::
9696

97-
$ python manage.py loaddata democrasite activitypub
97+
$ python manage.py loaddata democrasite social
9898

9999
Setting up your users
100100
^^^^^^^^^^^^^^^^^^^^^
@@ -114,8 +114,8 @@ Setting up your users
114114
how the site behaves for both kinds of users.
115115

116116
.. _`django-allauth`: https://docs.allauth.org/en/latest/introduction/index.html
117-
.. _`GitHub`: https://django-allauth.readthedocs.io/en/latest/providers.html#github
118-
.. _`Google`: https://docs.allauth.org/en/latest/socialaccount/providers/github.html
117+
.. _`GitHub`: https://docs.allauth.org/en/latest/socialaccount/providers/github.html
118+
.. _`Google`: https://docs.allauth.org/en/latest/socialaccount/providers/google.html
119119

120120
Linting
121121
^^^^^^^

config/settings/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
# Custom apps
103103
"democrasite.users",
104104
"democrasite.webiscite",
105-
"democrasite.activitypub",
105+
"democrasite.social",
106106
]
107107
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
108108
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS

config/urls.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
# User management
2424
path("users/", include("democrasite.users.urls", namespace="users")),
2525
path("accounts/", include("allauth.urls")),
26-
# ActivityPub
27-
path(
28-
"activitypub/", include("democrasite.activitypub.urls", namespace="activitypub")
29-
),
26+
# Social
27+
path("social/", include("democrasite.social.urls", namespace="social")),
3028
# webiscite
3129
path("", include("democrasite.webiscite.urls", namespace="webiscite")),
3230
# Media files

democrasite/activitypub/migrations/0001_initial.py

Lines changed: 0 additions & 117 deletions
This file was deleted.

democrasite/activitypub/migrations/0003_alter_person_following.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)