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

filter specific action on a per-record basis #1980

Closed
DavidGeismarLtd opened this issue May 9, 2021 · 2 comments
Closed

filter specific action on a per-record basis #1980

DavidGeismarLtd opened this issue May 9, 2021 · 2 comments

Comments

@DavidGeismarLtd
Copy link

  • What would you like to be able to do? Can you provide some examples?

At the moment if you want to filter out a specific action in the dashboards you can override valid_action?

    def valid_action?(name, resource = resource_class)
      %w[].exclude?(name.to_s) && super
    end

Is there a way to fine tune that on a per resource basis, say I only want record of a certain type to be editable.

  • How could we go about implementing that?
    Would be lovely to be able to write something like :
    def valid_action?(name, resource = resource_class)
      %w[ edit ].exclude?(name.to_s)  if resource.kind = 'non_editable'
      super
    end
  • Can you think of other approaches to the problem?
@pablobm
Copy link
Collaborator

pablobm commented May 13, 2021

Would show_action? work for you? It's different from valid_action?. See http://administrate-demo.herokuapp.com/authorization

To clarify:

  • valid_action?: tells if a route exists for the action. It probably should be a private method...
  • show_action?: controls authorization. For example, it's the one overriden by Punditize.

The names are a bit confusing. I'm currently working on a branch that should make this clearer.

@pablobm
Copy link
Collaborator

pablobm commented Apr 6, 2023

Should be fixed by #1941

@pablobm pablobm closed this as completed Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants