mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Cleanup for AjaxUpdateView
This commit is contained in:
parent
7708ffb069
commit
c0dd253137
@ -145,6 +145,20 @@ class AjaxCreateView(AjaxMixin, CreateView):
|
||||
|
||||
class AjaxUpdateView(AjaxMixin, UpdateView):
|
||||
|
||||
""" An 'AJAXified' UpdateView for updating an object in the db
|
||||
- Returns form in JSON format (for delivery to a modal window)
|
||||
- Handles repeated form validation (via AJAX) until the form is valid
|
||||
"""
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if request.is_ajax():
|
||||
form = self.form_class(instance=self.get_object())
|
||||
|
||||
return self.renderJsonResponse(request, form)
|
||||
|
||||
else:
|
||||
return super(UpdateView, self).post(request, *args, **kwargs)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
||||
form = self.form_class(instance=self.get_object(), data=request.POST, files=request.FILES)
|
||||
@ -165,14 +179,7 @@ class AjaxUpdateView(AjaxMixin, UpdateView):
|
||||
else:
|
||||
return response
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if request.is_ajax():
|
||||
form = self.form_class(instance=self.get_object())
|
||||
|
||||
return self.renderJsonResponse(request, form)
|
||||
|
||||
else:
|
||||
return super(UpdateView, self).post(request, *args, **kwargs)
|
||||
|
||||
|
||||
class AjaxDeleteView(AjaxMixin, DeleteView):
|
||||
|
Loading…
Reference in New Issue
Block a user