Update docstrings for InvenTree/views.py

This commit is contained in:
Oliver Walters 2019-04-28 10:46:07 +10:00
parent ff068de16d
commit 101ce53cd3

View File

@ -160,10 +160,9 @@ class AjaxCreateView(AjaxMixin, CreateView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
""" Responds to form POST. Validates POST data and returns status info. """ Responds to form POST. Validates POST data and returns status info.
Steps: - Validate POST form data
1. Validate POST form data - If valid, save form
2. If valid, save form - Return status info (success / failure)
3. Return status info (success / failure)
""" """
form = self.get_form() form = self.get_form()
@ -190,6 +189,11 @@ class AjaxUpdateView(AjaxMixin, UpdateView):
""" """
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
""" Respond to GET request.
- Populates form with object data
- Renders form to JSON and returns to client
"""
super(UpdateView, self).get(request, *args, **kwargs) super(UpdateView, self).get(request, *args, **kwargs)
@ -199,6 +203,13 @@ class AjaxUpdateView(AjaxMixin, UpdateView):
return self.renderJsonResponse(request, form) return self.renderJsonResponse(request, form)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
""" Respond to POST request.
- Updates model with POST field data
- Performs form and object validation
- If errors exist, re-render the form
- Otherwise, return sucess status
"""
super(UpdateView, self).post(request, *args, **kwargs) super(UpdateView, self).post(request, *args, **kwargs)
@ -226,6 +237,11 @@ class AjaxDeleteView(AjaxMixin, DeleteView):
""" """
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
""" Respond to GET request
- Render a DELETE confirmation form to JSON
- Return rendered form to client
"""
super(DeleteView, self).get(request, *args, **kwargs) super(DeleteView, self).get(request, *args, **kwargs)
@ -242,6 +258,11 @@ class AjaxDeleteView(AjaxMixin, DeleteView):
return JsonResponse(data) return JsonResponse(data)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
""" Respond to POST request
- DELETE the object
- Render success message to JSON and return to client
"""
obj = self.get_object() obj = self.get_object()
pk = obj.id pk = obj.id