feat(15-02): add Categories, Tags, and journal settings admin
Register the remaining YAML admin screens and the settings singleton so a host can boot Posts, Categories, Tags, and Code journal. Posts update and delete refuse other authors without access_other_posts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -174,9 +174,28 @@ func (c postsAdminController) FormBeforeUpdate(ctx context.Context, model any) e
|
||||
if !ok || post == nil {
|
||||
return errors.New("posts admin: form model is not a post")
|
||||
}
|
||||
if err := refuseOtherAuthor(ctx, post); err != nil {
|
||||
return err
|
||||
}
|
||||
return preparePostWrite(ctx, post)
|
||||
}
|
||||
|
||||
func (c postsAdminController) FormBeforeDelete(ctx context.Context, model any) error {
|
||||
post, ok := model.(*models.Post)
|
||||
if !ok || post == nil {
|
||||
return errors.New("posts admin: form model is not a post")
|
||||
}
|
||||
return refuseOtherAuthor(ctx, post)
|
||||
}
|
||||
|
||||
func refuseOtherAuthor(ctx context.Context, post *models.Post) error {
|
||||
principal, _ := bouncer.User(ctx)
|
||||
if post.CanEdit(principal) {
|
||||
return nil
|
||||
}
|
||||
return &cabana.ForbiddenError{Message: "golem15.journal::lang.journal.access_other_posts"}
|
||||
}
|
||||
|
||||
func preparePostWrite(ctx context.Context, post *models.Post) error {
|
||||
if err := refuseUnpublishedWrite(ctx, post); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user