diff --git a/tacc_stats/site/machine/views.py b/tacc_stats/site/machine/views.py index cb02d13..e24b14a 100644 --- a/tacc_stats/site/machine/views.py +++ b/tacc_stats/site/machine/views.py @@ -6,6 +6,8 @@ from django.db.models.functions import Cast from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django import forms +from django.shortcuts import get_object_or_404 +from django.contrib import messages import os,sys,pwd @@ -67,14 +69,22 @@ def search(request): job_objects = job_data.objects job = job_objects.get(jid = request.GET['jid']) return HttpResponseRedirect("/machine/job/"+str(job.jid)+"/") - except: pass + except: + messages.error(request, "No result found in search") + pass elif 'host' in request.GET and request.GET["host"]: - print("try to get host") - return host_detail(request) + try: + print("try to get host") + return host_detail(request) + except: + messages.error(request, "No result found in search") + pass else: - #try: - return index(request) - #except: pass + try: + return index(request) + except: + messages.error(request, "No result found in search") + pass return home(request, error = True) diff --git a/tacc_stats/site/tacc_stats_site/settings.py b/tacc_stats/site/tacc_stats_site/settings.py index aa81f0d..b45c705 100644 --- a/tacc_stats/site/tacc_stats_site/settings.py +++ b/tacc_stats/site/tacc_stats_site/settings.py @@ -4,6 +4,11 @@ import tacc_stats.site.tacc_stats_site as tacc_stats_site DIR = os.path.dirname(os.path.abspath(__file__)) +from django.contrib.messages import constants as messages +MESSAGE_TAGS = { + messages.ERROR: 'danger', +} + DEBUG = True ADMINS = ( diff --git a/tacc_stats/site/tacc_stats_site/templates/tacc_stats_site/base.html b/tacc_stats/site/tacc_stats_site/templates/tacc_stats_site/base.html index 1afc0c6..2a8d4d0 100644 --- a/tacc_stats/site/tacc_stats_site/templates/tacc_stats_site/base.html +++ b/tacc_stats/site/tacc_stats_site/templates/tacc_stats_site/base.html @@ -27,6 +27,16 @@ + {% if messages %} +
+ {% endif %} + + {% endfor %} +