Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

activity: add PermListNotes to the activity #639

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions activity/model_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ func (amb *ModelBuilder) NewTimelineCompo(evCtx *web.EventContext, obj any, idSu
}
mb := amb.presetModel

if mb.Info().Verifier().Do(PermListNotes).ObjectOn(obj).WithReq(evCtx.R).IsAllowed() != nil {
return nil
}

injectorName := injectorName(mb)
dc := mb.GetPresetsBuilder().GetDependencyCenter()
modelName := ParseModelName(obj)
Expand Down
1 change: 1 addition & 0 deletions activity/perm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package activity

const (
PermAll = "activity:*"
PermListNotes = "activity:list_notes"
PermAddNote = "activity:add_note"
PermEditNote = "activity:edit_note"
PermDeleteNote = "activity:delete_note"
Expand Down
23 changes: 23 additions & 0 deletions docs/docsrc/examples/examples_admin/activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,29 @@ func TestActivity(t *testing.T) {
},
ExpectPortalUpdate0ContainsInOrder: []string{"WithActivityProduct 13", ">Add Note</v-btn>", "John", "Added a note", "The newest model of the off-legacy Air Jordans is ready to burst onto to the scene.", "John", "Created"},
},
{
Name: "Activity Model details (without PermListNotes)",
Debug: true,
HandlerMaker: func() http.Handler {
pb := presets.New()
pb.Permission(
perm.New().Policies(
perm.PolicyFor(perm.Anybody).WhoAre(perm.Allowed).ToDo(perm.Anything).On(perm.Anything),
perm.PolicyFor(perm.Anybody).WhoAre(perm.Denied).ToDo(activity.PermListNotes).On("*:presets:with_activity_products:*"),
),
)
activityExample(pb, TestDB, nil)
return pb
},
ReqFunc: func() *http.Request {
activityData.TruncatePut(dbr)
req := multipartestutils.NewMultipartBuilder().
PageURL("/with-activity-products?__execute_event__=presets_DetailingDrawer&id=13").
BuildEventFuncRequest()
return req
},
ExpectPortalUpdate0NotContains: []string{">Add Note</v-btn>", "Added a note", "The newest model of the off-legacy Air Jordans is ready to burst onto to the scene."},
},
{
Name: "view all (with admin used)",
Debug: true,
Expand Down
Loading