-
Notifications
You must be signed in to change notification settings - Fork 179
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
Enable custom actions. #113
base: master
Are you sure you want to change the base?
Conversation
def get_actions(self): | ||
return ( | ||
('delete', {'url': '/delete/', 'title': 'Delete'}), | ||
('export', {'url': '/export/', 'title': 'Export'}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not (self.delete, {'url': '/delete/', 'title': 'Delete'})
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, since the "string" name of the view is pretty important, a 3-tuple:
(self.delete, 'delete', {'url': '/delete/', 'title': 'Delete'})
I've typically preferred to point directly to the function on the view class, rather than relying on a name/getattr. Aside from that it looks good. Do all tests pass, and do you think it is worthwhile to add any new tests? |
Hi Charles! I agree with your considerations, I'll rewrite the code with more explicit 3-tuple logic and I think it would be right to add tests for registering actions urls. |
+1 for this PR |
Hi Charles! I've updated actions definitions to point directly to methods, but I still use 2-tuple. All tests pass. Looks ok? |
This looks fantastic. Do you mind adding tests for the new behaviors? Perhaps a custom action and then testing to ensure it works correctly? |
Well, I believe most cases are covered by existing tests, because delete and export actions are defined in the new generic way. Custom actions have no difference with export and delete actions. But I don't mind if we add extra tests, I just need some hints how to setup test case. I took a look at existing tests and failed to find the most appropriate place to insert new one for this case :) |
Hello, Charles! I'm currently using flask-pewee in production and found custom actions feature would be very useful, e.g. content moderation, users blocking etc. I've made a simple implementation, how do you like it?