summaryrefslogtreecommitdiffstats
path: root/dashboard/src/notifier
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2018-11-20 11:19:55 -0500
committerParker Berberian <pberberian@iol.unh.edu>2018-11-26 14:07:15 -0500
commitf2bbdbbf7e03be031723a9680aa9deaf80e4a99c (patch)
tree54086b0ae60b65da0905e3b51c922934247b5370 /dashboard/src/notifier
parent674812a20f6804c287e1355ec8a1adf907798a94 (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 'dashboard/src/notifier')
-rw-r--r--dashboard/src/notifier/manager.py74
-rw-r--r--dashboard/src/notifier/tests/test_dispatcher.py4
-rw-r--r--dashboard/src/notifier/tests/test_models.py3
-rw-r--r--dashboard/src/notifier/urls.py6
4 files changed, 46 insertions, 41 deletions
diff --git a/dashboard/src/notifier/manager.py b/dashboard/src/notifier/manager.py
index cc1aa16..a754241 100644
--- a/dashboard/src/notifier/manager.py
+++ b/dashboard/src/notifier/manager.py
@@ -36,23 +36,29 @@ class NotificationHandler(object):
the last is the title for the collaborators'
"""
owner_notif = Notification.objects.create(
- title=titles[0],
- content=render_to_string(template, context={
+ title=titles[0],
+ content=render_to_string(
+ template,
+ context={
"booking": booking,
"owner": True
- })
- )
+ }
+ )
+ )
owner_notif.recipients.add(booking.owner)
if not booking.collaborators.all().exists():
return # no collaborators - were done
collab_notif = Notification.objects.create(
- title=titles[-1],
- content=render_to_string(template, context={
+ title=titles[-1],
+ content=render_to_string(
+ template,
+ context={
"booking": booking,
"owner": False
- })
- )
+ }
+ )
+ )
for c in booking.collaborators.all():
collab_notif.recipients.add(c)
@@ -67,28 +73,30 @@ class NotificationHandler(object):
# gather up all the relevant messages from the lab
for task in all_tasks:
if (not hasattr(task, "user")) or task.user == user:
- user_tasklist.append({
- "title": task.type_str + " Message: ",
- "content": task.message
- })
+ user_tasklist.append(
+ {
+ "title": task.type_str + " Message: ",
+ "content": task.message
+ }
+ )
# gather up all the other needed info
context = {
- "user_name": user.userprofile.full_name,
- "messages": user_tasklist,
- "booking_url": os.environ.get("DASHBOARD_URL", "<Dashboard url>") + "/booking/detail/" + str(job.booking.id) + "/"
- }
+ "user_name": user.userprofile.full_name,
+ "messages": user_tasklist,
+ "booking_url": os.environ.get("DASHBOARD_URL", "<Dashboard url>") + "/booking/detail/" + str(job.booking.id) + "/"
+ }
# render email template
message = render_to_string(template_name, context)
# finally, send the email
send_mail(
- "Your Booking is Ready",
- message,
- os.environ.get("DEFAULT_FROM_EMAIL", "opnfv@pharos-dashboard"),
- user.userprofile.email_addr,
- fail_silently=False
- )
+ "Your Booking is Ready",
+ message,
+ os.environ.get("DEFAULT_FROM_EMAIL", "opnfv@pharos-dashboard"),
+ user.userprofile.email_addr,
+ fail_silently=False
+ )
@classmethod
def email_booking_over(cls, booking):
@@ -98,21 +106,21 @@ class NotificationHandler(object):
users.append(booking.owner)
for user in users:
context = {
- "user_name": user.userprofile.full_name,
- "booking": booking,
- "hosts": hostnames,
- "booking_url": os.environ.get("DASHBOARD_URL", "<Dashboard url>") + "/booking/detail/" + str(booking.id) + "/"
- }
+ "user_name": user.userprofile.full_name,
+ "booking": booking,
+ "hosts": hostnames,
+ "booking_url": os.environ.get("DASHBOARD_URL", "<Dashboard url>") + "/booking/detail/" + str(booking.id) + "/"
+ }
message = render_to_string(template_name, context)
send_mail(
- "Your Booking has Expired",
- message,
- os.environ.get("DEFAULT_FROM_EMAIL", "opnfv@pharos-dashboard"),
- user.userprofile.email_addr,
- fail_silently=False
- )
+ "Your Booking has Expired",
+ message,
+ os.environ.get("DEFAULT_FROM_EMAIL", "opnfv@pharos-dashboard"),
+ user.userprofile.email_addr,
+ fail_silently=False
+ )
@classmethod
def task_updated(cls, task):
diff --git a/dashboard/src/notifier/tests/test_dispatcher.py b/dashboard/src/notifier/tests/test_dispatcher.py
index 07d8387..086f621 100644
--- a/dashboard/src/notifier/tests/test_dispatcher.py
+++ b/dashboard/src/notifier/tests/test_dispatcher.py
@@ -7,10 +7,8 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
from django.test import TestCase
-from notifier.models import *
-from django.contrib.auth.models import User
+
class DispatchTestCase(TestCase):
# This is a stub, it will be filled out as this feature is remade with saner practices.
diff --git a/dashboard/src/notifier/tests/test_models.py b/dashboard/src/notifier/tests/test_models.py
index 10aec3e..d332254 100644
--- a/dashboard/src/notifier/tests/test_models.py
+++ b/dashboard/src/notifier/tests/test_models.py
@@ -9,9 +9,10 @@
from django.test import TestCase
-from notifier.models import *
+from notifier.models import Notifier
from django.contrib.auth.models import User
+
class NotifierTestCase(TestCase):
def test_valid_notifier_saves(self):
diff --git a/dashboard/src/notifier/urls.py b/dashboard/src/notifier/urls.py
index 9bbc3bf..fedb9e8 100644
--- a/dashboard/src/notifier/urls.py
+++ b/dashboard/src/notifier/urls.py
@@ -10,12 +10,10 @@
from django.conf.urls import url
-from notifier.views import *
+from notifier.views import InboxView, NotificationView
app_name = "notifier"
urlpatterns = [
-
-
url(r'^$', InboxView, name='messages'),
- url(r'^notification/(?P<notification_id>[0-9]+)/$', NotificationView, name='notifier_single')
+ url(r'^notification/(?P<notification_id>[0-9]+)/$', NotificationView, name='notifier_single')
]