Let editors manage projects they created; add project created_by #118
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
qwc-open/asiakirjat!118
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/editor-manage-own-projects"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Two bugs reported by the user, plus a "created by" feature request — all one underlying gap: a non-admin editor could create a project but had no authority over it afterward.
requireAdmin, while create wasrequireEditorOrAdmin.requireAdmin, so a custom project an editor created was unusable (nobody could be granted access without an admin). The user reached for group mappings, which are correctly admin-only.created_bywas ever stored).Changes
projects.created_by(ON DELETE SET NULL, mirroringuploaded_byfrom 009) across sqlite/postgres/mysql.Projectstruct gainsCreatedBy;projects.Service.Createrecords the creator for all create paths (admin form, API, auto-create-on-upload).access.Checker.CanManage(user, project)— admins manage everything; everyone else only the projects they created. Pure (no store lookups)./admin/projects/{slug}/edit,/delete,/access/grant,/access/revokemove fromrequireAdmin→requireEditorOrAdmin; each handler now gates onCanManage. Non-admins still cannot promote a project to public (mirrorsErrPublicRequiresAdmin).roles-permissions,first-project) updated; unit tests forCanManage,created_bypersistence, and the editor edit / non-creator-403 / public-deny paths.Design note
Group-mapping management stays admin-only by design — it's a global LDAP/OAuth2 feature spanning all projects. The genuine gap it exposed (creators couldn't grant access to their own projects) is closed by the per-project access changes here.
Edit authority is creator + admins only (not any granted editor), per the chosen scope.
Testing
Full suite green under
go test -race ./...(exit 0).🤖 Generated with Claude Code
Editors could create projects (and were auto-granted editor access) but could not edit them or grant access to others — the edit, delete, and access routes were admin-only. Custom projects an editor created were thus unusable: nobody could be granted access to them without an admin. Changes: - Migration 010 adds a nullable projects.created_by (ON DELETE SET NULL, mirroring uploaded_by from 009) across sqlite/postgres/mysql. Project struct gains CreatedBy; projects.Service.Create records the creator for all create paths (admin form, API, auto-create). - access.Checker.CanManage(user, project): admins manage everything; everyone else only projects they created. Pure (no store lookups). - /admin/projects/{slug}/edit,/delete,/access/{grant,revoke} move from requireAdmin to requireEditorOrAdmin; each handler now gates on CanManage. Non-admins still cannot promote a project to public. - Manage-projects overview shows a "Created by" column; Edit/Delete render only on rows the user can manage. Edit page shows the creator and hides the public-visibility option from non-admins. - Built-in docs (roles-permissions, first-project) updated; unit tests for CanManage, created_by persistence, and the editor edit/grant/public-deny paths. Full suite green under -race. Group-mapping management stays admin-only by design (it's a global LDAP/OAuth2 feature); the real gap it exposed — creators having no way to grant access to their own projects — is closed by the per-project access changes above. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>