mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 04:56:45 +00:00
pass through request data
This commit is contained in:
parent
23608e6933
commit
cced30c081
@ -32,7 +32,7 @@ class ActionPluginView(APIView):
|
|||||||
for plugin in action_plugins:
|
for plugin in action_plugins:
|
||||||
if plugin.action_name() == action:
|
if plugin.action_name() == action:
|
||||||
plugin.perform_action(request.user, data=data)
|
plugin.perform_action(request.user, data=data)
|
||||||
return Response(plugin.get_response())
|
return Response(plugin.get_response(request.user, data=data))
|
||||||
|
|
||||||
# If we got to here, no matching action was found
|
# If we got to here, no matching action was found
|
||||||
return Response({
|
return Response({
|
||||||
|
@ -35,7 +35,7 @@ class ActionMixin:
|
|||||||
Override this method to perform the action!
|
Override this method to perform the action!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_result(self):
|
def get_result(self, user=None, data=None):
|
||||||
"""
|
"""
|
||||||
Result of the action?
|
Result of the action?
|
||||||
"""
|
"""
|
||||||
@ -43,19 +43,19 @@ class ActionMixin:
|
|||||||
# Re-implement this for cutsom actions
|
# Re-implement this for cutsom actions
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_info(self):
|
def get_info(self, user=None, data=None):
|
||||||
"""
|
"""
|
||||||
Extra info? Can be a string / dict / etc
|
Extra info? Can be a string / dict / etc
|
||||||
"""
|
"""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_response(self):
|
def get_response(self, user=None, data=None):
|
||||||
"""
|
"""
|
||||||
Return a response. Default implementation is a simple response
|
Return a response. Default implementation is a simple response
|
||||||
which can be overridden.
|
which can be overridden.
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
"action": self.action_name(),
|
"action": self.action_name(),
|
||||||
"result": self.get_result(),
|
"result": self.get_result(user, data),
|
||||||
"info": self.get_info(),
|
"info": self.get_info(user, data),
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ class SimpleActionPlugin(ActionMixin, InvenTreePlugin):
|
|||||||
def perform_action(self):
|
def perform_action(self):
|
||||||
print("Action plugin in action!")
|
print("Action plugin in action!")
|
||||||
|
|
||||||
def get_info(self):
|
def get_info(self, user, data):
|
||||||
return {
|
return {
|
||||||
"user": self.user.username,
|
"user": user.username,
|
||||||
"hello": "world",
|
"hello": "world",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user