# Add a New Page Type to a Wagtail Site from a Linear Issue

An agent adds a WorkshopPage under the locations index of a Wagtail site, with a migration, two templates and ten new tests; 17 tests pass.

[Run this on Rush](https://cloud.getrush.ai/run/add-workshop-page/wagtail/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads `bakerydemo/locations/models.py`, where `LocationsIndexPage` allowed only `LocationPage`, and adds `"WorkshopPage"` to its `subpage_types`. The new `WorkshopPage` has an introduction, an image and one `details` StreamField built from a `WorkshopStreamBlock`: a `DateBlock`, a `DecimalBlock` price with `min_value=0`, and a repeating `SessionBlock` of date, start time, end time and topic. `block_counts` caps date and price at one each, and `SessionBlock.clean` refuses an end time before the start.

It generates `0012_workshoppage.py`, writes `locations/workshop_page.html` on the location detail layout plus `blocks/session_block.html`, and adds `locations/tests/test_workshop_page.py` with `WagtailPageTestCase` checks for allowed parents, rendering, the block limits, a negative price and a missing-migration check.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "A Linear issue labeled agent says: \"Add a New Page Type to a Wagtail Site. Add a WorkshopPage with a date, a price and a session schedule as StreamField blocks, allowed under the locations index, with a template and a migration.\" Do the work in this repository, add tests for it, run python manage.py test, and open a pull request that links back to the issue.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

Tried on wagtail/bakerydemo at c9b38d7: 6 files changed, 273 insertions(+), 1 deletion(-). `python manage.py test` passed on the untouched clone with 7 tests and after the change reported `Ran 17 tests in 1.948s` and `OK`; `makemigrations --check --dry-run` printed `No changes detected` and `ruff check bakerydemo/locations` printed `All checks passed!`. The agent installed `requirements/base.txt`, not `production.txt` (uWSGI needs a C compiler the sandbox lacked), installed `ruff` itself, and did not run `make lint`, so `djhtml` and `curlylint` never checked the new templates. The issue text was written into the request; no Linear issue ID was given, and no pull request was opened.

For the reviewer: date and price live inside the StreamField, so workshops cannot be filtered or ordered by them in the database; make them model fields if that matters. The price renders as a bare `45.50`, since the repo has no currency setting.

## Run it on every Linear issue labelled agent

An automation with a `linear` trigger on `linear.issue.labeled` and the label `agent` runs the Linear label to PR prompt with the labelled issue as context. A content-model issue like this one should name the parent page and which fields editors will want to sort by.

## Why run it on Rush?

The run left three things undone and said so: workshops do not appear on the locations index template, the hard-coded search models in `bakerydemo/search/views.py` do not include `WorkshopPage`, and the page was never opened in a browser, so the `workshop__*` classes have no styles.

## Frequently asked questions

### Can LocationPage still be added under the locations index?

Yes. `subpage_types` became `["LocationPage", "WorkshopPage"]`, and a test asserts both are allowed while `WorkshopPage` itself takes no children and cannot be created under the root page.

### How is a missing migration caught?

`WorkshopMigrationTest` calls `makemigrations locations` with `check=True`, so the suite fails if the model and `0012_workshoppage.py` drift apart. Its run printed `No changes detected in app 'locations'`.

## More Wagtail jobs

- [Fix N+1 Queries in a Wagtail Site](https://getrush.ai/run/fix-n-plus-one-queries/wagtail/)
- [Fix Wagtail Errors from Sentry Alerts](https://getrush.ai/run/fix-sentry-errors/wagtail/)
- [Review Pull Requests on a Wagtail Site](https://getrush.ai/run/review-pull-requests/wagtail/)

## More jobs like this: Turn a Linear label into a PR

- [Add X-Ray Tracing to an AWS CDK Stack from a Linear Issue](https://getrush.ai/run/add-xray-tracing/aws-cdk/)
- [Add X-Ray Tracing to a Serverless Framework API from a Linear Issue](https://getrush.ai/run/add-xray-tracing/serverless/)
- [Fix "[antd: Menu] `children` will be removed in next major version. Please use `items` instead"](https://getrush.ai/run/fix-antd-menu-children-will-be-removed-warning/antd/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
