diff options
author | Parker Berberian <pberberian@iol.unh.edu> | 2018-11-20 11:19:55 -0500 |
---|---|---|
committer | Parker Berberian <pberberian@iol.unh.edu> | 2018-11-26 14:07:15 -0500 |
commit | b7c4d286ffa618be0e95b15f3883e2f6920a3fb1 (patch) | |
tree | 930e9b9282b8f50e671844b2a1e7f39dc5d6035d /src/workflow/booking_workflow.py | |
parent | 6a90796de1df8d74c79415c39c867ffe6cd80fd0 (diff) |
Fix all flake8 errors
The flake8 command in test.sh finds no longer finds any errors.
This may form a basis of a jenkins verify job as a sort of 'weak compile-time checks'
The flake8 command will not complain about line length, and will not complain about
django's manage.py file
Change-Id: Ic47cb4fc7ada55e64485661ab6881aef475018ff
Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'src/workflow/booking_workflow.py')
-rw-r--r-- | src/workflow/booking_workflow.py | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/workflow/booking_workflow.py b/src/workflow/booking_workflow.py index 213b9e6..cd12ab6 100644 --- a/src/workflow/booking_workflow.py +++ b/src/workflow/booking_workflow.py @@ -15,12 +15,12 @@ from django.utils import timezone import json from datetime import timedelta -from account.models import UserProfile from booking.models import Booking from workflow.models import WorkflowStep -from workflow.forms import ResourceSelectorForm, SWConfigSelectorForm, BookingMetaForm, ConfirmationForm +from workflow.forms import ResourceSelectorForm, SWConfigSelectorForm, BookingMetaForm from resource_inventory.models import GenericResourceBundle, ResourceBundle, ConfigBundle + class Resource_Select(WorkflowStep): template = 'booking/steps/resource_select.html' title = "Select Resource" @@ -62,14 +62,14 @@ class Resource_Select(WorkflowStep): edit = self.repo_get(self.repo.EDIT, False) user = self.repo_get(self.repo.SESSION_USER) context['form'] = ResourceSelectorForm( - data={"user": user}, - chosen_resource=default, - bundle=bundle, - edit=edit - ) + data={"user": user}, + chosen_resource=default, + bundle=bundle, + edit=edit + ) return context - def post_render(self, request): + def post_render(self, request): form = ResourceSelectorForm(request.POST) context = self.get_context() if form.is_valid(): @@ -86,11 +86,14 @@ class Resource_Select(WorkflowStep): gresource_bundle = GenericResourceBundle.objects.get(id=selected_id) except ValueError: # we want the bundle in the repo - gresource_bundle = self.repo_get(self.repo.GRESOURCE_BUNDLE_MODELS,{}).get("bundle", GenericResourceBundle()) + gresource_bundle = self.repo_get( + self.repo.GRESOURCE_BUNDLE_MODELS, + {} + ).get("bundle", GenericResourceBundle()) self.repo_put( - self.repo_key, - gresource_bundle - ) + self.repo_key, + gresource_bundle + ) confirm = self.repo_get(self.repo.CONFIRMATION) if self.confirm_key not in confirm: confirm[self.confirm_key] = {} @@ -104,6 +107,7 @@ class Resource_Select(WorkflowStep): self.metastep.set_invalid("Please complete the fields highlighted in red to continue") return render(request, self.template, context) + class Booking_Resource_Select(Resource_Select): def __init__(self, *args, **kwargs): @@ -119,7 +123,7 @@ class Booking_Resource_Select(Resource_Select): try: config_bundle = self.repo_get(self.repo.BOOKING_MODELS)['booking'].config_bundle if default: - return default # select created grb, even if preselected config bundle + return default # select created grb, even if preselected config bundle return config_bundle.bundle except: pass @@ -145,6 +149,7 @@ class Booking_Resource_Select(Resource_Select): self.repo_put(self.repo.BOOKING_MODELS, models) return response + class SWConfig_Select(WorkflowStep): template = 'booking/steps/swconfig_select.html' title = "Select Software Configuration" @@ -186,7 +191,6 @@ class SWConfig_Select(WorkflowStep): return self.render(request) - def get_context(self): context = super(SWConfig_Select, self).get_context() default = [] @@ -197,7 +201,7 @@ class SWConfig_Select(WorkflowStep): try: chosen_bundle = booking.config_bundle default.append(chosen_bundle.id) - bundle=chosen_bundle + bundle = chosen_bundle except: if created_bundle: default.append("repo bundle") @@ -208,6 +212,7 @@ class SWConfig_Select(WorkflowStep): context['form'] = SWConfigSelectorForm(chosen_software=default, bundle=bundle, edit=edit, resource=grb) return context + class Booking_Meta(WorkflowStep): template = 'booking/steps/booking_meta.html' title = "Extra Info" @@ -231,7 +236,7 @@ class Booking_Meta(WorkflowStep): users = models.get("collaborators", []) for user in users: default.append(user.id) - except Exception as e: + except Exception: pass default_user = self.repo_get(self.repo.SESSION_USER) @@ -271,7 +276,7 @@ class Booking_Meta(WorkflowStep): user_data = form.cleaned_data['users'] confirm['booking']['collaborators'] = [] - user_data = user_data[2:-2] #fixes malformed string from querydict + user_data = user_data[2:-2] # fixes malformed string from querydict if user_data: form_users = json.loads(user_data) for user_json in form_users: |