mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-17 19:36:28 +02:00
feat(projects): URL field + cover photo on project cards (#1155)
Two new project fields: a free-text URL rendered as a one-click
external-link button beside the project name on every card (opens in a
new tab, click is e.stopPropagation()-guarded so it doesn't enter the
project), and a cover photo that replaces the status-icon box with a
square thumbnail.
URL is plumbed through ProjectCreate/Update/Response/ListResponse,
including from-template + create-template flows so it inherits between
a project and its template. Cover photo is not inherited because the
file would be shared on disk between source and copy.
Schema validator rejects anything other than http:// or https://
prefixes -- <a href> rendering would otherwise execute javascript:
/ data: / file: URLs even with React's default escaping. PATCH uses
model_fields_set for the URL field so users can clear it by sending
{"url": null}.
Cover image storage: Project.cover_image_filename references a file
Cover image storage: Project.cover_image_filename references a file
inside the existing archives/projects/{id}/attachments/ dir, but it's
tracked separately from the attachments JSON list so swap/delete on
the cover doesn't perturb the user's other attachments. Three routes
(POST/GET/DELETE /projects/{id}/cover-image) accept only .jpg/.jpeg/
.png/.gif/.webp (no SVG -- SVG can carry script payloads), replace in
place (prior file deleted before the new one lands so repeat uploads
can't accumulate orphans), and self-heal when a DB reference points at
a vanished disk file by clearing the column and 404'ing.
GET cover-image is gated by RequireCameraStreamTokenIfAuthEnabled
(accepts ?token=... query string) -- not the bearer-token gate -- so
<img src> requests work in both auth-on and auth-off configurations.
The frontend wraps getProjectCoverImageUrl with withStreamToken(),
matching the existing pattern from getArchiveThumbnail.
Permissions: PROJECTS_UPDATE for upload/delete/PATCH, PROJECTS_READ
gate is implicit via the stream-token credential. Migration: 2
idempotent ALTER TABLE projects ADD COLUMN. Localised across all 8
UI languages.
This commit is contained in:
@@ -640,6 +640,13 @@ async def run_migrations(conn):
|
||||
# Migration: Add target_parts_count column to projects for tracking total parts needed
|
||||
await _safe_execute(conn, "ALTER TABLE projects ADD COLUMN target_parts_count INTEGER")
|
||||
|
||||
# Migration: Add url + cover_image_filename columns to projects (#1155).
|
||||
# url: external link rendered next to the project name on the card.
|
||||
# cover_image_filename: filename of the project's hero image inside the
|
||||
# existing attachments dir; rendered as a thumbnail on the card.
|
||||
await _safe_execute(conn, "ALTER TABLE projects ADD COLUMN url VARCHAR(2048)")
|
||||
await _safe_execute(conn, "ALTER TABLE projects ADD COLUMN cover_image_filename VARCHAR(255)")
|
||||
|
||||
# Migration: Make printer_id nullable in print_queue for unassigned queue items
|
||||
# SQLite doesn't support ALTER COLUMN, so we need to recreate the table
|
||||
# PostgreSQL gets the correct schema from create_all(), so skip this
|
||||
|
||||
Reference in New Issue
Block a user