Add greens view

This commit is contained in:
AndyGrant committed 2018-06-26 20:53:37 -04:00
1 parent 425f43603a
commit 0bde403f61
4 files changed
+27 -9

No files matched your search

+4 -1
View File
@@ -12,9 +12,12 @@ urlpatterns = [
path(r'index/', OpenBench.views.index), path(r'index/', OpenBench.views.index),
path(r'index/<int:page>/', OpenBench.views.index), path(r'index/<int:page>/', OpenBench.views.index),
path(r'users/', OpenBench.views.users), path(r'greens/', OpenBench.views.greens),
path(r'greens/<int:page>/', OpenBench.views.greens),
path(r'viewUser/<str:username>/', OpenBench.views.viewUser), path(r'viewUser/<str:username>/', OpenBench.views.viewUser),
path(r'viewUser/<str:username>/<int:page>/', OpenBench.views.viewUser), path(r'viewUser/<str:username>/<int:page>/', OpenBench.views.viewUser),
path(r'users/', OpenBench.views.users),
path(r'machines/', OpenBench.views.machines), path(r'machines/', OpenBench.views.machines),
path(r'eventLog/', OpenBench.views.eventLog), path(r'eventLog/', OpenBench.views.eventLog),
path(r'eventLog/<int:page>/', OpenBench.views.eventLog), path(r'eventLog/<int:page>/', OpenBench.views.eventLog),
+21 -7
View File
@@ -107,7 +107,7 @@ def editProfile(request):
# Send back to see the changes # Send back to see the changes
return HttpResponseRedirect('/viewProfile/') return HttpResponseRedirect('/viewProfile/')
def index(request, page=0, pageLength=25, username=None, error=''): def index(request, page=0, pageLength=25, greens=False, username=None, error=''):
# Get tests pending approval # Get tests pending approval
pending = Test.objects.filter(approved=False) pending = Test.objects.filter(approved=False)
@@ -139,12 +139,20 @@ def index(request, page=0, pageLength=25, username=None, error=''):
machineCount, threadCount, round(npsTotal, 2) machineCount, threadCount, round(npsTotal, 2)
) )
# Index is wrapped for just viewing passed tests
if greens == True:
pending = active = []
completed = completed.filter(passed=True)
source = 'greens'
# Index is wrapped just to view one user # Index is wrapped just to view one user
if username != None: elif username != None:
pending = pending.filter(author=username) pending = pending.filter(author=username)
active = active.filter(author=username) active = active.filter(author=username)
completed = completed.filter(author=username) completed = completed.filter(author=username)
source = "viewUser/{0}".format(username) source = "viewUser/{0}".format(username)
# Index is normal, not wrapped for any views
else: else:
source = "index" source = "index"
@@ -163,22 +171,28 @@ def index(request, page=0, pageLength=25, username=None, error=''):
'active' : active, 'active' : active,
'completed' : completed[start:end], 'completed' : completed[start:end],
'status' : workerData, 'status' : workerData,
'greens' : greens,
'paging' : paging, 'paging' : paging,
} }
return render(request, 'index.html', data) return render(request, 'index.html', data)
def greens(request, page=0):
# Index but with only passed tests
return index(request, page, greens=True)
def viewUser(request, username, page=0):
# Index but with only username's tests
return index(request, page, username=username)
def users(request): def users(request):
# Build context dictionary for template # Build context dictionary for template
data = {'profiles' : Profile.objects.order_by('-games')} data = {'profiles' : Profile.objects.order_by('-games')}
return render(request, 'users.html', data) return render(request, 'users.html', data)
def viewUser(request, username, page=0):
# Index but with only username's tests
return index(request, page, username=username)
def machines(request): def machines(request):
# Build context dictionary for machine template with machines updated recently # Build context dictionary for machine template with machines updated recently
+1
View File
@@ -28,6 +28,7 @@
<ul> <ul>
<li class="header"> CONTENT</li> <li class="header"> CONTENT</li>
<li><a href="/index">Index</a></li> <li><a href="/index">Index</a></li>
<li><a href="/greens">Greens</a></li>
<li><a href="/users">Users</a></li> <li><a href="/users">Users</a></li>
<li><a href="/machines">Machines</a></li> <li><a href="/machines">Machines</a></li>
<li><a href="/eventLog">Events</a></li> <li><a href="/eventLog">Events</a></li>
+1 -1
View File
@@ -2,7 +2,7 @@
{% load mytags %} {% load mytags %}
{% block content %} {% block content %}
<table class="datatable"> <table class="datatable">
{% if paging.page == 0 %} {% if paging.page == 0 and greens == False %}
<tr><td class="embedded" colspan='7'><h2>Pending</h2></td></tr> <tr><td class="embedded" colspan='7'><h2>Pending</h2></td></tr>
{% if pending %} {% if pending %}
<tr> <tr>