From 101ce53cd30106956860d8e67805276121f41074 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 28 Apr 2019 10:46:07 +1000 Subject: [PATCH] Update docstrings for InvenTree/views.py --- InvenTree/InvenTree/views.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index e7dad657ba..21adcd0021 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -160,10 +160,9 @@ class AjaxCreateView(AjaxMixin, CreateView): def post(self, request, *args, **kwargs): """ Responds to form POST. Validates POST data and returns status info. - Steps: - 1. Validate POST form data - 2. If valid, save form - 3. Return status info (success / failure) + - Validate POST form data + - If valid, save form + - Return status info (success / failure) """ form = self.get_form() @@ -190,6 +189,11 @@ class AjaxUpdateView(AjaxMixin, UpdateView): """ 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) @@ -199,6 +203,13 @@ class AjaxUpdateView(AjaxMixin, UpdateView): return self.renderJsonResponse(request, form) 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) @@ -226,6 +237,11 @@ class AjaxDeleteView(AjaxMixin, DeleteView): """ 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) @@ -242,6 +258,11 @@ class AjaxDeleteView(AjaxMixin, DeleteView): return JsonResponse(data) 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() pk = obj.id @@ -253,7 +274,7 @@ class AjaxDeleteView(AjaxMixin, DeleteView): } return self.renderJsonResponse(request, data=data) - + class IndexView(TemplateView): """ View for InvenTree index page """