Commit 943a9bd
authored
Wire up real Embassy backend: bookings, applications, admin CRUD, PDF (#14)
* Replace Embassy mock data with real backend
- Add Question, NotaryProfile, EmbassyBooking, EmbassyApplication, and
EmbassyApplicationAnswer models, with embassy_mode/embassy_capacity
columns on ScheduleItem.
- Seed 80 questions and 18 notaries from db/seeds/embassy_questions.rb
via idempotent EmbassyQuestionsSeed.import! (keyed by external_id).
- Wire EmbassyBookings, EmbassyApplications, and the Admin::* controllers
to real ActiveRecord queries in place of FakeEmbassy.
- Generate real PDF downloads with Prawn (PassportApplicationPdf, formal
tax-form aesthetic), replacing the browser-print HTML partial.
- Draw Section 3 questions and notary by least-used-first
(EmbassyApplicationDraw) for fair distribution across applicants.
- Enforce booking capacity inside a row-locked transaction; support
edit-while-draft on EmbassyApplication.
- Add Stimulus controller to toggle the embassy capacity/mode fields on
the admin schedule-item form when kind = embassy.
- Delete fake_embassy.rb, _pdf.html.erb, _expired.html.erb.
* Show "Submit Application" label on application submit button
Switch from f.submit (which renders <input type="submit"> where the value
attribute IS the displayed label) to <button type="submit"> elements with
separate inner text and submitted value. The button now shows "Submit
Application" instead of the literal "1" that was being submitted as the
form value. Renames the discriminator parameter from `submit` to `intent`
for clarity.
* Make "Save & Return Later" actually save the draft
Previously "Save & Return Later" was a link that navigated away without
saving any answers — confusing alongside a separate "Save draft" button
that did save. Removes the redundant Save draft button and converts
"Save & Return Later" into a submit button (intent=draft) that saves the
in-progress answers and redirects to /plan.
Extracts the shared "submit vs. draft" branch into finalize_or_redirect
so both create and update go through one path.
* Fix PDF layout: 2-column short fields, max_length, page numbers
PDF layout overhaul addressing five visual issues:
- Application now spans 2 pages instead of 8+. Short fields (Given Name +
GitHub handle, Pronouns + Age in Coding Years, etc.) render side-by-side
in two columns. Long answers get more vertical room sized from
question.max_length.
- Add max_length column on Question, surfaced on the admin form and as
HTML maxlength on the user-facing form. Defaults: 60 chars (short),
240 chars (long). Caps text so it always fits the printed PDF box.
- Page footer now uses pdf.repeat(:all, dynamic: true) inside pdf.canvas
so it renders in the bottom margin (not the content area) and shows
the actual page number on every page (was always "Page 2 of 2").
- Applicant signature + date side-by-side in fixed-position bounding
boxes — they now align horizontally (was vertically stacked due to
fragile move_up arithmetic).
- Notary printed name + date aligned the same way; signature + notary
ID below them no longer overlap.
Root-cause fix for the runaway pagination: boxed_text's inner
bounding_box had height < line height for short fields, which silently
triggered Prawn auto-pagination. Switched to draw_text/text_box for
single-line fields and made the inner-box height calculations safe.
* Compact PDF checkboxes, fill page 2 with ordinances, fix copy
PDF refinements:
- Render checkbox_group options inline with formatted_text fragments so
short option lists ("Learning / Networking / Vibes / Free coffee") fit
on one line; longer lists wrap naturally to 2 lines.
- Add INSTRUCTIONS TO THE APPLICANT (4 paragraphs) and EMBASSY
ORDINANCES (7 §-numbered clauses) after the signature block to fill
the otherwise mostly-blank page 2 with parodic legalese.
- Rename header subtitle from "United Embassy of Ruby" to
"Blue Ridge Ruby Embassy" on both application + notary pages.
Confirmation page:
- Reword photography etiquette to ask about consent for photographing
other attendees instead of the (fictional) Stamping Apparatus.
* Restore 2-column grid for Section 4 checkbox group on PDF
The inline checkbox rendering works well for short option lists like
Section 1.7 (Learning / Networking / Vibes / Free coffee) but turns
Section 4's longer affirmations into a hard-to-scan run-on. Branch
on a heuristic: 6+ options OR any option > 30 characters falls back
to the 2-column grid. Section 4 (7 options, ~50 chars each) now uses
the grid; Sections 1.7-1.9 keep the inline layout.
* Drop 'will be printed on official PDF' from max-length hint
* Force Section 5 onto its own page in the PDF
* PDF copy fixes: signature, §2, §5, instruction #2
- APPLICANT SIGNATURE box left blank for physical ink signing; caption
reads "Signature of Applicant" (drops "(typed)" — the typed name is
already captured above as 5.4).
- §2 Discretion: replaces "tabs over spaces" jab with "documented hatred
of the Ruby programming language" — fits the Embassy theme.
- §5 Right of Appeal: replaces /dev/null gag with noreply@blueridgeruby.com
so the appeal channel is at least nominally plausible.
- Instruction #2: rewritten generically ("Answer all questions as
printed...") to keep Section 3's randomization a surprise — attendees
comparing applications will see different questions and not realize
why.
Removes the now-unused PassportApplicationPdf#answer_text helper.
* Align checkbox options in fixed-column grid
The inline formatted_text path packed options as natural-width
fragments, so spacing varied between every option. Replaces it with a
universal grid layout that adapts column count from option width:
- Short options (max ~12 chars): 4 columns
- Medium phrases (max ~25 chars): 3 columns
- Long affirmations (Section 4): 2 columns
Each option gets a fixed-width slot, so they line up vertically within
a question — even across multiple rows. Drops the two_column_options?
branch since one grid path now handles all sizes.
* Add ridiculous legalese, increase section spacing on PDF
Section spacing:
- Bump pre-section padding from 5pt to 8pt and pre-questions padding
from 2pt to 3pt for more breathing room without forcing extra pages.
Legal text expansion (page 2 onward, ~2 pages of dense parody legalese):
- Add INSTRUCTION #5 about pens.
- Expand EMBASSY ORDINANCES from 7 § to 20 §, adding clauses on Decorum,
Documentation, Reciprocal Recognition, Jurisdiction, Force Majeure,
Amendments, Counterparts, No Third-Party Beneficiaries,
Indemnification, Survival, Entire Agreement, Conflict of Laws, Notices.
- Add SCHEDULE A — DEFINITIONS (Applicant, Attaché, Business Gem,
Embassy, Notary, Passport, Stamping, Vibe).
- Add SCHEDULE B — PROHIBITED ACTIVITIES (forgery, photography of the
Stamping Apparatus mid-impact, narrating proceedings, etc.).
- Add SCHEDULE C — RULES OF CONSTRUCTION (singular/plural, business gem
carve-outs, Schrödinger-cat gender clause).
- Add SCHEDULE D — REPRESENTATIONS AND WARRANTIES.
- Expand ACKNOWLEDGMENT to four paragraphs ending in "IN WITNESS
WHEREOF, the Applicant has caused this Application to be executed by
clicking a button on a website..."
Drop the cursor-based break guards in render_instructions so the legal
text now flows across page boundaries instead of being silently
truncated when a paragraph would orphan.
* Fix nil-kind crash on Plan page and harden destroy cascade
A handful of dev DB records had ScheduleItem#kind values (4, 5, 6) that
no longer exist in the model's enum, leftover from an earlier schema
that included additional kinds like meal/break/mystery. Reading the
enum returned nil, which then crashed item.kind.humanize on the Plan
and Admin Schedule Items pages.
- View guard: render the kind badge only when item.kind is present;
Admin shows "unknown (N)" so stale rows are visible.
- Add has_one :embassy_booking, dependent: :destroy on PlanItem so
destroying a plan item properly cascades to its booking + application
+ answers. Without this inverse the cascade chain went via
ScheduleItem and tried to delete plan_items before their referencing
bookings, raising PG::ForeignKeyViolation.
* Pack legal jargon into 3-column page-2 layout, polish copy
Layout:
- Use Prawn column_box(columns: 3) for INSTRUCTIONS / EMBASSY ORDINANCES /
SCHEDULES A-D in 5.5pt small print, leaving the page-bottom for
ACKNOWLEDGMENT full-width at 6pt. PDF is back to 3 pages: application
(p1), Section 5 + signature + all legal text (p2), notary (p3).
Copy edits:
- Reciprocal Recognition (§9): swap CoffeeScript/Crystal/Elixir name-drops
for generic "sister Ruby Embassies hosted at other regional and
international Ruby gatherings."
- Business Gem definition: now refers to three (3) ceremonial gemstones
used for symbolic Embassy purposes; "business gem" usage elsewhere
rephrased as "(3) event days."
- Drop Schedule B (b) (Stamping Apparatus photography prohibition) and
(d) (no narration / livestreaming) — attendees are free to photograph
and livestream.
- Drop Schedule C #8 (Schrödinger-cat gender clause) — keep wording
inclusive and avoid commentary on protected categories.
- Drop "and the open bar" from Schedule D (e).
* Fold ACKNOWLEDGMENT into 3-column flow, fix Business Gems pun
The ACKNOWLEDGMENT was rendering full-width below the column box and
overlapping the page footer divider. Putting it inside the column box
as just another section lets Prawn handle layout uniformly — no cursor
math, no overlap.
Also rewrites the "Business Gems" definition to actually be about
RubyGems (the package manager) instead of literal gemstones, since the
joke is meant to be coding-flavored not jewelry-flavored.
* Justify and even out spacing in PDF legalese columns
- Set align: :justify on all column-flow paragraphs so text reads
flush to both column edges (matches the formal-document register).
- Bump section-break gap from 4pt to 5pt for clearer separation
between sections.
- Bump post-divider gap from 1pt to 3pt so the first paragraph of
each section has visible breathing room below its header.
- Bump inter-paragraph gap from 1pt to 2pt for uniform rhythm
throughout each section.
* Force SCHEDULE C to start at the top of the third column
Prawn's column_box has no built-in column_break primitive, so simulate
one by overflowing the cursor past the bottom of the current column —
Prawn snaps to the top of the next one.
Tagging which sections want this in a small constant so it's data-
driven and easy to add other forced breaks if the layout shifts.
* Pass CI: rubocop autocorrect + clear unused fixtures
- Auto-corrected Layout/SpaceInsideArrayLiteralBrackets across migrations,
seed file, controllers, and PDF service to match the project's
rubocop-rails-omakase preference for [ ... ] over [...].
- Empty out the auto-generated test/fixtures/*.yml stubs for the new
Question, NotaryProfile, EmbassyBooking, EmbassyApplication, and
EmbassyApplicationAnswer models. The placeholder rows produced by
rails g model violated NOT NULL constraints (jsonb columns expect
[], not nil) and broke fixture loading in every test. No tests use
these fixtures yet; they can be filled in when real model tests are
written.1 parent 4b8c748 commit 943a9bd
4 files changed
Lines changed: 115 additions & 20 deletions
File tree
- app
- models
- services
- views
- admin/schedule_items
- plan
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
| 364 | + | |
| 365 | + | |
365 | 366 | | |
366 | 367 | | |
367 | 368 | | |
368 | 369 | | |
369 | 370 | | |
370 | | - | |
| 371 | + | |
371 | 372 | | |
372 | | - | |
| 373 | + | |
373 | 374 | | |
374 | | - | |
| 375 | + | |
375 | 376 | | |
376 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
377 | 448 | | |
378 | 449 | | |
379 | 450 | | |
380 | 451 | | |
381 | | - | |
382 | | - | |
| 452 | + | |
383 | 453 | | |
384 | | - | |
385 | | - | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
386 | 459 | | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
391 | 474 | | |
392 | | - | |
393 | | - | |
394 | | - | |
| 475 | + | |
| 476 | + | |
395 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
396 | 482 | | |
397 | 483 | | |
398 | 484 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
105 | 107 | | |
106 | 108 | | |
107 | 109 | | |
| |||
0 commit comments