mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-24 16:57:30 +00:00
Add generic method for retriving GET or POST params
This commit is contained in:
1 parent
e5fc43a00f
commit
cd438f0569
3 files changed
+31
-9
No files matched your search
@@ -69,6 +69,22 @@ class AjaxMixin(object):
|
||||
ajax_form_action = ''
|
||||
ajax_form_title = ''
|
||||
|
||||
def get_param(self, name, method='GET'):
|
||||
""" Get a request query parameter value from URL e.g. ?part=3
|
||||
|
||||
Args:
|
||||
name: Variable name e.g. 'part'
|
||||
method: Request type ('GET' or 'POST')
|
||||
|
||||
Returns:
|
||||
Value of the supplier parameter or None if parameter is not available
|
||||
"""
|
||||
|
||||
if method == 'POST':
|
||||
return self.request.POST.get(name, None)
|
||||
else:
|
||||
return self.request.GET.get(name, None)
|
||||
|
||||
def get_data(self):
|
||||
""" Get extra context data (default implementation is empty dict)
|
||||
|
||||
|
||||
Reference in new issue
Block a user