# ATO page template — handover (20 Nov 2026, SAST)

**Status: the template is design-complete.** One template renders every school page: free, paid (Premium), gifted
and lapsed, with the Edit Premium kit and the write-a-review v2 fields. It is the design and the static page only.
The database and API work listed in [section 7](#7-what-codex-must-add-database-and-api) is still to be built.

- Branch: `codex/17-owner-decisions` (Codex's latest database line, which now carries the template).
  Merged by [PR #12](https://github.com/sdzrxwfxd2-cloud/go-around-launch-11nov/pull/12) (`45041b11`): `codex/14-master-rules-db` (PR #5)
  and PRs #6, #7 and #11 on top of Codex's `cff8053f`, with no conflicts.
- Live preview (design preview project only, not goaround.co.za): <https://ato-final.go-around-design-previews.pages.dev/>
- Editing rules page in Notion: [Edit Premium — ATO page editing](https://app.notion.com/p/41ee8f7324d9818b90cadc7acb3aec03)
- Generator README (every file, every rule, test list): [README.md](README.md)

---

## 1. Where everything lives

| What | Path |
|---|---|
| Generator (one command, one page per school) | `ato-generator/generator.py` |
| Page shell | `ato-generator/template/ato.html.j2` |
| Free page parts | `template/parts/hero.j2`, `bases_certificates.j2`, `about_contact.j2`, `courses.j2`, `ratings.j2`, `rating_categories.j2`, `reviews.j2`, `badges.j2` |
| Premium parts (paid or gifted only) | `template/parts/premium.j2` (fees, intakes, fleet, jobs, booking link), `premium_news.j2` (announcement), `premium_about.j2`, `premium_contact.j2` |
| Edit Premium kit (inert `<template>`) | `template/parts/edit_kit.j2` |
| Write-a-review v2 fields (inert `<template>`) | `template/parts/review_fields.j2` |
| Behaviour: pickers, edit kit, enquiry form, Open now, contact bar | `ato-generator/shared/page.js` |
| Styles for all of the above | `ato-generator/shared/page.css` |
| Shared top bar | `ato-generator/shared/topbar.css`, `topbar.js` (served once at `/ato/_shared/`) |
| Locked page look (v6.2) | `site/ato-v6/v6.css` |
| Theme colour tokens | `ato-generator/themes/{pearl,midnight,amethyst,champagne}.css` |
| Locked drawings (ticks, compass, stars) | `ato-generator/svg.py` |
| Rating summary arithmetic | `ato-generator/rating.py` |
| Example schools | `ato-generator/data/ato/example-*.json` (see the table below) |
| Member preview switch (design only, never shipped) | `ato-generator/preview-only/` |
| Tests | `ato-generator/tests/` (pytest), `tests/reviews/*.test.mjs` (Node) |

**Example schools**

| File | Status | What it shows |
|---|---|---|
| `example-air-school.json` | `verified` (free) | The free page. No gold tick, no Premium, no edit kit. |
| `example-flight-academy.json` | `paid`, nothing written yet | The page looks free to the public. Its team sees empty dashed slots in edit mode. |
| `example-premium-academy.json` | `paid` with its own `premium` and `profile` | The full Premium page, live with no flag. |
| `example-lapsed-school.json` | `lapsed` | The free page. Its team sees the "Premium has ended" bar. |

### Generator commands

```sh
cd ato-generator
pip install jinja2 pytest                                               # the only two dependencies
python3 generator.py --today 2026-11-20 --out out                       # the example schools, Midnight
python3 generator.py --theme pearl --out out-pearl                      # pearl | midnight | amethyst | champagne
python3 generator.py --premium-preview --out out-preview                 # SAMPLE Premium on paid schools that have none
python3 generator.py --master ../docs/ato-master/ato-master-10nov.json --out build   # all schools
python3 -m pytest -q                                                    # 200 tests
```

The output is `out/<slug>/index.html` plus `manifest.json`. Pages are never edited by hand.
To view one, serve a folder that holds `ato/` (the output), `ato-v6/` (from `site/ato-v6`) and `fonts/`.

### Preview flags (design previews only, never needed by real visitors)

| Flag | Effect |
|---|---|
| `?preview-premium=1` | Shows the SAMPLE Premium blocks drawn by `--premium-preview` (sets `html[data-premium-preview]`). A paid school with its own content needs no flag. |
| `?preview-edit=1&preview-role=owner` | Opens edit mode as the school owner |
| `?preview-edit=1&preview-role=staff` | Opens edit mode as a staff seat (same sections as the owner, no Hide) |
| `?preview-edit=1&preview-role=admin` | Opens edit mode as Super Admin (adds **Hide this section**) |
| `?preview-sun=day\|night` | Forces the day or night palette |
| `?preview-now=2026-11-20T10:00:00%2B02:00` | Fixes the clock for "Open now" and the pickers |

In production, edit mode starts only when the signed-in script fires `ga:can-edit` (detail: role), after
`GET /api/ato/{slug}/edit` says this viewer may edit. Saving fires `ga:edit-save` (detail: section and values). In a
preview it shows "Preview only. Nothing was saved."

---

## 2. Free, paid, gifted and lapsed

| School | Public page | Its own team (owner, staff, Super Admin) |
|---|---|---|
| Unclaimed / verified (free) | The free template, byte-for-byte unchanged by all Premium work. | No edit kit in the HTML at all |
| **Paid** (Premium) | Switches to the Premium layout the moment payment is confirmed. Each Premium section goes public as soon as it has content and is saved. Sections without content are not drawn. Gold tick. | Edit mode: an Edit pill on every filled section, and dashed slots for empty ones ("Only your team can see this until you save") |
| **Gifted** (a Founding gift from Go Around) | Exactly like paid | Exactly like paid |
| **Lapsed** (plan ended, or payment failed after the 7-day grace) | The free template. Premium content stays saved in the database and is never sent to the page. | A bar saying "Premium has ended. Your page content is saved and hidden. It comes back the moment you renew." with **Renew Premium**. No editing. |

Renewing brings back the saved content exactly as it was.

---

## 3. Edit Premium rules

1. **Content only.** Every section keeps its place, order, fonts, colours and theme. There are no design settings,
   and schools never get design controls (MT, 20 Nov 09:14).
2. **The school can edit:**
   - the announcement
   - About: lead line, two paragraphs, founded year, instructors, students trained, and the flight-line photo with its caption and alt text
   - fees and next intakes: the course comes from the school's own SACAA list, plus the fee in whole rand, places, what's included, and the next intake from our day picker
   - fleet: type, count from 1 to 200, and a note
   - jobs
   - one https booking link
   - contact: phone, email, WhatsApp, address, and opening hours per weekday (24-hour, half-hour steps, or closed)
3. **Locked for everyone, always:** the SACAA record (ATO number, certificates and bases), the course list, and ratings
   and reviews. Locked sections carry a lock tag such as "Locked · From the SACAA record". The school can never edit
   the review fields.
4. **Who edits:**
   - The **owner** edits their own school and takes one paid seat.
   - **Staff on a paid seat** edit the same sections. 2 seats means the owner plus 1 staff; 5 seats means the owner plus 4 staff.
   - **Super Admin** edits any school.
   - Members, guests and other schools' staff only read. They never see edit buttons, slots or drafts.
5. **Save and publish goes live at once** for the owner, staff and Super Admin. There's no pre-approval queue, and
   Go Around checks after (MT, 20 Nov 09:14).
6. **Super Admin is the only role that can hide** a section or a post (`.ek-hide`).
7. **Every save is logged:** who, role, section, before, after and time.
8. **Photos:** JPEG, PNG or WebP only, checked before they show.
9. **Lapsed:** content is kept but hidden, editing is off, and it all returns on renewal. See [section 2](#2-free-paid-gifted-and-lapsed).
10. **One template.** A design change is made once, on a branch, previewed, and after MT says merge it updates every school page.

---

## 4. Design rules (apply to every change)

- **Type:**
  - Clash Display 500 for display text and the About lead line
  - Satoshi 400 for body text
  - General Sans 500 and 600 for UI
  - JetBrains Mono with tabular numerals for every figure: rand, dates, counts and hours
  - Nippo for ICAO codes
- **Tokens:** colours come only from the theme files (`themes/*.css`). Base Pearl: background `#FAF9F5`, text
  `#141413` and `#5E5D59`, navy `#0019C9`. Don't hard-code colours in parts.
- **Four themes only:** Pearl, Midnight, Amethyst and Champagne. Every change is checked in all four.
- **Widths:** check every change at 320, 390, 820 and 1440 px. There must be no horizontal page scroll and no text
  overflowing its box. On a phone the edit sheet is a bottom sheet; on a tablet or desktop it's a right panel.
- **Clean CSS at the source.** Never add `!important`. The one in `shared/page.css` (`.ob-claim-invite` in the owner preview) predates this work.
- **Motion:** transform and opacity only, with ease `cubic-bezier(.16,1,.3,1)`. Every animation respects
  `prefers-reduced-motion`.
- **South African formats:** `12 Jan 2027`, `Mar 2025`, 24-hour times (`07:30`), `R 95,000`, and the
  Africa/Johannesburg clock. Never `mm/dd/yyyy`.
- **Our own pickers, never the browser's:** use `.ga-cal` (`data-cal="month"` or `"date"`) for months and days, and the
  `.ek-tsel` lists for hours. Native `type=date`, `type=month` and `type=time` fields aren't allowed.
- **Gender**, wherever a form asks: exactly **Male, Female, Rather not say**. Never write "Woman" or "Man".
- **Plan name:** "Premium", everywhere.
- **Anything missing is left out.** Nothing is invented. Sample content appears only with `--premium-preview` and says
  "Sample details".
- The free page must stay byte-identical when Premium work changes. The tests check this.

---

## 5. Write-a-review v2 fields (every member, all optional)

| Field | Rule |
|---|---|
| **Courses** (`courses`) | Multi-select from this school's own course list, grouped as Licences, Ratings and Other. Up to 6, no duplicates, with search when the school has more than 8. |
| **When you trained** | `trained_from` and `trained_to` (`YYYY-MM`), or `trained_from` plus **Still training here** (`still_training: true`). Month and year only. No future month. To can't be before From. From is needed for To or Still training, and Still training and To are never both set. Uses our month picker. |
| **Amount paid** (`cost`, stored as `amount_paid_cents`) | Total in whole rand, from 0 to 9,999,999, with commas as you type. JetBrains Mono, shown as `R 95,000`. |
| **Card line** | One quiet line, for example `Private Licence (A), Night rating · Mar 2025 – Jan 2026 · R 95,000` or `… · Mar 2025 – present · …`. Empty parts are left out. |
| **Anonymous** | Never shows courses, dates or amount. The form says so, and none of it is returned publicly. |

Codex's 1–5 star "Value for money" category stays as its own rating. Amount paid is a separate field.

---

## 6. Tests and the visual check

```sh
cd ato-generator && python3 -m pytest -q                 # 200 passed
cd .. && node --test tests/reviews/*.test.mjs            # 955: 951 pass, 3 fail (pre-existing secret_scan history tests), 1 skipped
```

The 3 `secret_scan` failures exist on `codex/17-owner-decisions` before this merge and aren't caused by the template.

Results of the browser check on 20 Nov, with Chrome and Playwright:
- **Pages:** the free, the paid with nothing written, the Premium and the lapsed school, each in all 4 themes at 4 widths
  (64 runs). There was no horizontal scroll, no overflowing text and no script errors.
- **Edit mode, owner (16 runs):**
  - The About, Fees, Announcement and Contact sheets open correctly, and the fee is typed as `165,000`.
  - The day picker greys out past days and gives `12 Jan 2027`.
  - Hours are on 24-hour lists, with Sunday closed.
  - "View as visitor" and "Done" leave a clean page.
- **Edit mode, staff and admin:** staff get 5 Edit pills and no Hide; admin gets Hide. The lapsed bar appears with Renew Premium.
- **Review form (16 runs):**
  - 2 courses become chips.
  - The months read Mar 2025 – Jan 2026; "To" before "From" shows an error; Still training disables To.
  - The amount reads `95,000`, and the card line is correct.
  - There's no overflow.

---

## 7. What Codex must add (database and API)

The template already renders all of the fields below. The data has to exist, and `/api/ato/{slug}/public` has to send it.

**Reviews.** Today migration 0063 adds one `course_id` and one `trained_month` on `reviews`, and there's no amount.

- Add a `review_courses` table (`review_id`, `course_id` from that school's `school_courses`) with a unique pair and up to 6
  rows per review. It replaces the single `course_id`.
- Add `trained_from` (YYYY-MM), `trained_to` (YYYY-MM or null), `still_training` (0/1) and `amount_paid_cents`
  (integer, 0 to 999,999,900). Check that there's no future month, that to ≥ from, that from is set for to or still, and that to and still aren't both set.
- Strip these fields on anonymous reviews, or never return them publicly.
- Update `projection.mjs` and `cloudflare/lib/ato_review_html.mjs`, which still print the single month and course.
- Extend Super Admin's switches (`ato_review_trained_month`, `_course`, `_value`) to cover the period, the courses and the amount.
- Give Super Admin a way to see and edit a review's courses, period and amount.
- Reject or strip an exact date or a rand amount typed into the review text.

**School About and Contact.** These are missing on `schools` (0002):

- `lead`, `para1`, `para2`
- `founded_year`, `instructor_count`, `students_trained`
- `whatsapp`, `address`
- `photo_file_id`, `photo_caption`, `photo_alt`
- `aerodrome_lat`, `aerodrome_lon`
- a `school_hours` table (`weekday` 0–6, `opens`, `closes`, `closed`)

**Premium content.** Fees rows (`course_id`, `amount_cents` > 0, `places`, `includes`, `next_intake`), fleet rows, jobs and the
https booking link can extend the `school_posts` modules. Add `hidden_by_admin`, `hidden_at` and `hidden_reason` on every section and post.

**Enquiries.** Add a `school_enquiries` table and `POST /api/ato/{slug}/enquiry`, with a rate limit and a school notification.

**Edit log.** Add `school_edit_log` (`school_id`, `user_id`, `role`, `section`, `before_json`, `after_json`, `created_at`).

**API endpoints:**
- `GET /api/ato/{slug}/edit` returns role and can-edit for a paid or gifted school, while it's active or in grace.
- `PUT /api/ato/{slug}/page/{section}` puts a save live at once and logs it.
- `POST /api/admin/ato/{slug}/page/{section}/hide` and `/unhide` are for Super Admin only.

**Rule mismatches in today's code:**
- **Approval:** `data_school.mjs` (suggestPage) makes staff edits wait for the owner, except fleet and announcement. The
  Premium rule is that every save goes live at once.
- **Super Admin:** `school_perms.mjs` only lets Super Admin approve or reject, with no direct edit and no hide.
- **Gifted:** `PAID_SCHOOL_EXTRAS` (`data_more.mjs`) needs `source='payment'`, so gifted Premium is shut out. Gifted
  has to count as paid.
- **Lapsed:** nothing keeps Premium content saved but hidden when a plan lapses, or returns it on renewal. `/public` must
  send Premium content only while the plan is active or in grace.

These parts of Codex's code are already right and stay as they are:
- the plan prices (Premium 2 seats R3,999, 5 seats R4,999, excl. VAT)
- the 7-day grace
- the layout lock (the `content_live` trigger)
- the single training month and course checks, as a base for the v2 fields

---

## 8. Questions

These were answered by MT on 20 Nov at 09:14:

1. **Seats:** they stay at 2 and 5, with no extra seats.
2. **Price:** it stays R3,999 and R4,999 excl. VAT. Founding caps stay at 10 ATOs and 50 members.
3. **Customisable design:** no. Schools edit content only.
4. **Owner seat:** yes, the owner takes a paid seat.
5. **Approval:** checks happen after. Saves go live at once, and Super Admin can hide.

Still open for MT:
- How strict the review-text check should be on dates and rand amounts: reject the review, or strip the value?
- Who moderates uploaded photos, and how fast.
- Should the Contact location tile become a true map once `aerodrome_lat` and `aerodrome_lon` exist?

---

## 9. History

| PR | What |
|---|---|
| [#5](https://github.com/sdzrxwfxd2-cloud/go-around-launch-11nov/pull/5) | Generator polish and write-a-review v2 (merged into `codex/14-master-rules-db`) |
| [#6](https://github.com/sdzrxwfxd2-cloud/go-around-launch-11nov/pull/6) | Paid page extras |
| [#7](https://github.com/sdzrxwfxd2-cloud/go-around-launch-11nov/pull/7) | Paid About and Contact, with the enquiry form and the pinned phone bar |
| [#11](https://github.com/sdzrxwfxd2-cloud/go-around-launch-11nov/pull/11) | Edit Premium kit, and our own day picker and hour lists |
| [#12](https://github.com/sdzrxwfxd2-cloud/go-around-launch-11nov/pull/12) | This merge: everything above onto `codex/17-owner-decisions` (`45041b11`) |
| [#13](https://github.com/sdzrxwfxd2-cloud/go-around-launch-11nov/pull/13) | This handover, linked from both READMEs |
