diff --git a/manager/templatetags/notifications.py b/manager/templatetags/notifications.py
index 753c5f2..9e62410 100644
--- a/manager/templatetags/notifications.py
+++ b/manager/templatetags/notifications.py
@@ -7,5 +7,12 @@ register = template.Library()
@register.inclusion_tag('manager/notifications.html', takes_context=True)
def getNotifications(context, login=False):
- return { 'notifications': [notification for notification in Notification.objects.filter(Q(expiry__gte = timezone.now()) | Q(expiry = None)) if (notification.on_login or (not login)) ] }
-
+ notifications = [notification for notification in Notification.objects.filter(Q(expiry__gte = timezone.now()) | Q(expiry = None)) if (notification.on_login or (not login)) ]
+ if context.dicts[3]["exception"]:
+ exception = Notification()
+ exception.status = 2
+ exception.text = context.dicts[3]["exception"].human
+ if context.dicts[3]["user"].is_superuser:
+ exception.text += "" + str(context.dicts[3]["exception"]) + "
"
+ notifications = [ exception ] + notifications
+ return { 'notifications': notifications }
diff --git a/manager/views.py b/manager/views.py
index d17b5c0..6524da2 100644
--- a/manager/views.py
+++ b/manager/views.py
@@ -135,8 +135,8 @@ def ping(request, device_id):
return HttpResponse(ajax, content_type="application/json")
@login_required
-def devices(request):
- return render(request, "manager/index.html", {"title": "Device Administration"})
+def devices(request, code=200, exception=None):
+ return render(request, "manager/index.html", {"title": "Device Administration", "exception": exception}, status=code)
@login_required
def editdevice(request, device_id):
@@ -479,3 +479,26 @@ def saveUserStatus(sender, instance, **kwargs):
except:
UserStatus.objects.create(user=instance)
+def errorhandler(request, code, exception):
+ if code == 403:
+ exception.human = "You have no permission to access the requested page."
+ elif code == 400:
+ exception.human = "Something seems to be wrong with the request you sent. Please try again."
+ elif code == 404:
+ exception.human = "Sorry, we were unable to find the page you requested. Please check the address and try again."
+ elif code == 500:
+ exception.human = "Sorry, something seems to be wrong on our end. Please try again later or contact support if the problem persists."
+
+ return devices(request, code=code, exception=exception)
+
+def handler400(request, exception):
+ return errorhandler(request, 400, exception)
+
+def handler403(request, exception):
+ return errorhandler(request, 403, exception)
+
+def handler404(request, exception):
+ return errorhandler(request, 404, exception)
+
+def handler500(request):
+ return errorhandler(request, 500, Exception("Please check the server logs for additional information."))
diff --git a/templates/manager/index.html b/templates/manager/index.html
index b866f8e..8debfee 100644
--- a/templates/manager/index.html
+++ b/templates/manager/index.html
@@ -15,8 +15,10 @@
‐ Organizations
{% endif %}
-
+