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/account | |
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/account')
-rw-r--r-- | src/account/__init__.py | 2 | ||||
-rw-r--r-- | src/account/jira_util.py | 2 | ||||
-rw-r--r-- | src/account/models.py | 4 | ||||
-rw-r--r-- | src/account/tests/__init__.py | 2 | ||||
-rw-r--r-- | src/account/tests/test_general.py | 4 | ||||
-rw-r--r-- | src/account/urls.py | 13 | ||||
-rw-r--r-- | src/account/views.py | 15 |
7 files changed, 24 insertions, 18 deletions
diff --git a/src/account/__init__.py b/src/account/__init__.py index b5914ce..b6fef6c 100644 --- a/src/account/__init__.py +++ b/src/account/__init__.py @@ -6,5 +6,3 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - - diff --git a/src/account/jira_util.py b/src/account/jira_util.py index fdb87f7..18b0e26 100644 --- a/src/account/jira_util.py +++ b/src/account/jira_util.py @@ -62,4 +62,4 @@ def get_jira(user): 'key_cert': key_cert } - return JIRA(server=settings.JIRA_URL, oauth=oauth_dict)
\ No newline at end of file + return JIRA(server=settings.JIRA_URL, oauth=oauth_dict) diff --git a/src/account/models.py b/src/account/models.py index 18a8cbb..bfeead0 100644 --- a/src/account/models.py +++ b/src/account/models.py @@ -23,6 +23,7 @@ class LabStatus(object): def upload_to(object, filename): return object.user.username + '/' + filename + class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) timezone = models.CharField(max_length=100, blank=False, default='UTC') @@ -81,7 +82,6 @@ class VlanManager(models.Model): net = PublicNetwork.objects.get(lab=self.lab_set.first(), vlan=vlan) return not net.in_use - def is_available(self, vlans): """ 'vlans' is either a single vlan id integer or a list of integers @@ -139,7 +139,6 @@ class VlanManager(models.Model): self.save() - class Lab(models.Model): lab_user = models.OneToOneField(User, on_delete=models.CASCADE) name = models.CharField(max_length=200, primary_key=True, unique=True, null=False, blank=False) @@ -159,7 +158,6 @@ class Lab(models.Model): key += random.choice(alphabet) return key - def __str__(self): return self.name diff --git a/src/account/tests/__init__.py b/src/account/tests/__init__.py index b5914ce..b6fef6c 100644 --- a/src/account/tests/__init__.py +++ b/src/account/tests/__init__.py @@ -6,5 +6,3 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - - diff --git a/src/account/tests/test_general.py b/src/account/tests/test_general.py index e8f483b..57ad291 100644 --- a/src/account/tests/test_general.py +++ b/src/account/tests/test_general.py @@ -30,7 +30,7 @@ class AccountMiddlewareTestCase(TestCase): The timezone should be UTC for anonymous users, for authenticated users it should be set to user.userprofile.timezone """ - #default + # default self.assertEqual(timezone.get_current_timezone_name(), 'UTC') url = reverse('account:settings') @@ -56,5 +56,3 @@ class AccountMiddlewareTestCase(TestCase): self.client.login(username='user2', password='user2') self.client.get(url) self.assertTrue(user2.userprofile) - - diff --git a/src/account/urls.py b/src/account/urls.py index 6ce2115..85f0f1a 100644 --- a/src/account/urls.py +++ b/src/account/urls.py @@ -26,7 +26,18 @@ Including another URLconf """ from django.conf.urls import url -from account.views import * +from account.views import ( + AccountSettingsView, + JiraAuthenticatedView, + JiraLoginView, + JiraLogoutView, + UserListView, + account_resource_view, + account_booking_view, + account_images_view, + account_configuration_view, + account_detail_view +) app_name = "account" urlpatterns = [ diff --git a/src/account/views.py b/src/account/views.py index 04d21b8..09c5266 100644 --- a/src/account/views.py +++ b/src/account/views.py @@ -63,7 +63,7 @@ class JiraLoginView(RedirectView): # Step 1. Get a request token from Jira. try: resp, content = client.request(settings.OAUTH_REQUEST_TOKEN_URL, "POST") - except Exception as e: + except Exception: messages.add_message(self.request, messages.ERROR, 'Error: Connection to Jira failed. Please contact an Administrator') return '/' @@ -76,8 +76,8 @@ class JiraLoginView(RedirectView): self.request.session['request_token'] = dict(urllib.parse.parse_qsl(content.decode())) # Step 3. Redirect the user to the authentication URL. url = settings.OAUTH_AUTHORIZE_URL + '?oauth_token=' + \ - self.request.session['request_token']['oauth_token'] + \ - '&oauth_callback=' + settings.OAUTH_CALLBACK_URL + self.request.session['request_token']['oauth_token'] + \ + '&oauth_callback=' + settings.OAUTH_CALLBACK_URL return url @@ -99,7 +99,7 @@ class JiraAuthenticatedView(RedirectView): # Step 2. Request the authorized access token from Jira. try: resp, content = client.request(settings.OAUTH_ACCESS_TOKEN_URL, "POST") - except Exception as e: + except Exception: messages.add_message(self.request, messages.ERROR, 'Error: Connection to Jira failed. Please contact an Administrator') return '/' @@ -163,6 +163,7 @@ def account_detail_view(request): template = "account/details.html" return render(request, template) + def account_resource_view(request): """ gathers a users genericResoureBundles and @@ -175,6 +176,7 @@ def account_resource_view(request): context = {"resources": resources, "title": "My Resources"} return render(request, template, context=context) + def account_booking_view(request): if not request.user.is_authenticated: return render(request, "dashboard/login.html", {'title': 'Authentication Required'}) @@ -184,6 +186,7 @@ def account_booking_view(request): context = {"title": "My Bookings", "bookings": bookings, "collab_bookings": collab_bookings} return render(request, template, context=context) + def account_configuration_view(request): if not request.user.is_authenticated: return render(request, "dashboard/login.html", {'title': 'Authentication Required'}) @@ -192,12 +195,12 @@ def account_configuration_view(request): context = {"title": "Configuration List", "configurations": configs} return render(request, template, context=context) + def account_images_view(request): if not request.user.is_authenticated: return render(request, "dashboard/login.html", {'title': 'Authentication Required'}) template = "account/image_list.html" my_images = Image.objects.filter(owner=request.user) public_images = Image.objects.filter(public=True) - context = {"title": "Images", "images": my_images, "public_images": public_images } + context = {"title": "Images", "images": my_images, "public_images": public_images} return render(request, template, context=context) - |