Bugfix to enable/disable buttons; Also, include profile always in the context dictionary
This commit is contained in:
1 parent
42821ceb10
commit
7d99373d6b
2 files changed
+16
-19
No files matched your search
+11
-14
@@ -17,10 +17,16 @@ from OpenBench.utils import pagingContext
|
|||||||
|
|
||||||
import OpenBench.utils, datetime
|
import OpenBench.utils, datetime
|
||||||
|
|
||||||
|
|
||||||
# Wrap django.shortcuts.render to add framework settings
|
|
||||||
def render(request, template, data):
|
def render(request, template, data):
|
||||||
|
|
||||||
|
# Always provde the Configuration
|
||||||
data.update(FRAMEWORK_DEFAULTS)
|
data.update(FRAMEWORK_DEFAULTS)
|
||||||
|
|
||||||
|
# Send User data when logged in
|
||||||
|
if request.user.is_authenticated:
|
||||||
|
data.update({'profile' : Profile.objects.get(user=request.user)})
|
||||||
|
|
||||||
|
# Final wrap of Django's rendering funtion
|
||||||
return djangoRender(request, 'OpenBench/{0}'.format(template), data)
|
return djangoRender(request, 'OpenBench/{0}'.format(template), data)
|
||||||
|
|
||||||
def register(request):
|
def register(request):
|
||||||
@@ -81,9 +87,7 @@ def logout(request):
|
|||||||
@login_required(login_url='/login/')
|
@login_required(login_url='/login/')
|
||||||
def viewProfile(request):
|
def viewProfile(request):
|
||||||
|
|
||||||
# Build context dictionary for profile template
|
# render() gets the profile data for us
|
||||||
profile = Profile.objects.get(user=request.user)
|
|
||||||
data = {'profile' : profile}
|
|
||||||
return render(request, 'viewProfile.html', data)
|
return render(request, 'viewProfile.html', data)
|
||||||
|
|
||||||
@login_required(login_url='/login/')
|
@login_required(login_url='/login/')
|
||||||
@@ -111,10 +115,6 @@ def editProfile(request):
|
|||||||
|
|
||||||
def index(request, page=0, pageLength=25, greens=False, username=None, error=''):
|
def index(request, page=0, pageLength=25, greens=False, username=None, error=''):
|
||||||
|
|
||||||
# Get information about the logged in user
|
|
||||||
if not request.user.is_authenticated: profile = None
|
|
||||||
else: profile = Profile.objects.get(user=request.user)
|
|
||||||
|
|
||||||
# Get tests pending approval
|
# Get tests pending approval
|
||||||
pending = Test.objects.filter(approved=False)
|
pending = Test.objects.filter(approved=False)
|
||||||
pending = pending.exclude(finished=True)
|
pending = pending.exclude(finished=True)
|
||||||
@@ -173,7 +173,6 @@ def index(request, page=0, pageLength=25, greens=False, username=None, error='')
|
|||||||
# Build context dictionary for index template
|
# Build context dictionary for index template
|
||||||
data = {
|
data = {
|
||||||
'error' : error,
|
'error' : error,
|
||||||
'profile' : profile,
|
|
||||||
'pending' : pending,
|
'pending' : pending,
|
||||||
'active' : active,
|
'active' : active,
|
||||||
'completed' : completed[start:end],
|
'completed' : completed[start:end],
|
||||||
@@ -282,8 +281,7 @@ def newTest(request):
|
|||||||
|
|
||||||
# User trying to view the new test page
|
# User trying to view the new test page
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
profile = Profile.objects.get(user=request.user)
|
return render(request, 'newTest.html', {})
|
||||||
return render(request, 'newTest.html', {'profile' : profile})
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Throw out non-approved / disabled users
|
# Throw out non-approved / disabled users
|
||||||
@@ -311,8 +309,7 @@ def viewTest(request, id):
|
|||||||
# Build context dictionary for test template
|
# Build context dictionary for test template
|
||||||
test = Test.objects.get(id=id)
|
test = Test.objects.get(id=id)
|
||||||
results = Result.objects.all().filter(test=test)
|
results = Result.objects.all().filter(test=test)
|
||||||
profile = Profile.objects.get(user=request.user) if request.user.is_authenticated else None
|
data = {'test' : test, 'results' : results}
|
||||||
data = {'test' : test, 'results' : results, 'profile' : profile}
|
|
||||||
return render(request, 'viewTest.html', data)
|
return render(request, 'viewTest.html', data)
|
||||||
|
|
||||||
# Unable to find test
|
# Unable to find test
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
<h2>Actions</h2>
|
<h2>Actions</h2>
|
||||||
|
|
||||||
<!-- Approve Button: For Admins, or Cross-approvers -->
|
<!-- Approve Button: For Admins, or Cross-approvers -->
|
||||||
{% if not test.approved and profile.approver and profile.user.username is not test.author %}
|
{% if not test.approved and profile.approver and profile.user.username != test.author %}
|
||||||
<a class="anchorbutton" id="approvebutton" href="/approveTest/{{test.id}}/">Approve</a>
|
<a class="anchorbutton" id="approvebutton" href="/approveTest/{{test.id}}/">Approve</a>
|
||||||
{% elif not test.approved and request.user.is_superuser %}
|
{% elif not test.approved and request.user.is_superuser %}
|
||||||
<a class="anchorbutton" id="approvebutton" href="/approveTest/{{test.id}}/">Approve</a>
|
<a class="anchorbutton" id="approvebutton" href="/approveTest/{{test.id}}/">Approve</a>
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
<!-- Restart Button: For Approvers or Test Authors of finished tests -->
|
<!-- Restart Button: For Approvers or Test Authors of finished tests -->
|
||||||
{% if test.finished and profile.approver %}
|
{% if test.finished and profile.approver %}
|
||||||
<a class="anchorbutton" id="stopbutton" href="/restartTest/{{test.id}}/">Restart</a>
|
<a class="anchorbutton" id="stopbutton" href="/restartTest/{{test.id}}/">Restart</a>
|
||||||
{% elif test.finished and profile.user.username is test.author %}
|
{% elif test.finished and profile.user.username == test.author %}
|
||||||
<a class="anchorbutton" id="stopbutton" href="/restartTest/{{test.id}}/">Restart</a>
|
<a class="anchorbutton" id="stopbutton" href="/restartTest/{{test.id}}/">Restart</a>
|
||||||
{% elif test.finished %}
|
{% elif test.finished %}
|
||||||
<a class="anchorbutton deadbutton">Restart</a>
|
<a class="anchorbutton deadbutton">Restart</a>
|
||||||
@@ -109,14 +109,14 @@
|
|||||||
<!-- Stop Button: For Approvers or Test Authors of active tests -->
|
<!-- Stop Button: For Approvers or Test Authors of active tests -->
|
||||||
{% if not test.finished and profile.approver %}
|
{% if not test.finished and profile.approver %}
|
||||||
<a class="anchorbutton" id="restartbutton" href="/stopTest/{{test.id}}/">Stop</a>
|
<a class="anchorbutton" id="restartbutton" href="/stopTest/{{test.id}}/">Stop</a>
|
||||||
{% elif not test.finished and profile.user.username is test.author %}
|
{% elif not test.finished and profile.user.username == test.author %}
|
||||||
<a class="anchorbutton" id="restartbutton" href="/stopTest/{{test.id}}/">Stop</a>
|
<a class="anchorbutton" id="restartbutton" href="/stopTest/{{test.id}}/">Stop</a>
|
||||||
{% elif not test.finished %}
|
{% elif not test.finished %}
|
||||||
<a class="anchorbutton deadbutton">Stop</a>
|
<a class="anchorbutton deadbutton">Stop</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<!-- Delete Button: For Approvers or Test Authors -->
|
<!-- Delete Button: For Approvers or Test Authors -->
|
||||||
{% if profile.approver or profile.user.username is test.author %}
|
{% if profile.approver or profile.user.username == test.author %}
|
||||||
<a class="anchorbutton" id="deletebutton" href="/deleteTest/{{test.id}}/">Delete</a>
|
<a class="anchorbutton" id="deletebutton" href="/deleteTest/{{test.id}}/">Delete</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="anchorbutton deadbutton">Delete</a>
|
<a class="anchorbutton deadbutton">Delete</a>
|
||||||
@@ -136,7 +136,7 @@
|
|||||||
<input value="{{test.priority}}" name="priority"></br>
|
<input value="{{test.priority}}" name="priority"></br>
|
||||||
<label>Throughput</label>
|
<label>Throughput</label>
|
||||||
<input value="{{test.throughput}}" name="throughput"></br>
|
<input value="{{test.throughput}}" name="throughput"></br>
|
||||||
{% if profile.approver or profile.user.username is test.author %}
|
{% if profile.approver or profile.user.username == test.author %}
|
||||||
<input type="submit" name="submit" value="Modify">
|
<input type="submit" name="submit" value="Modify">
|
||||||
{% else %}
|
{% else %}
|
||||||
<input class="deadbutton" type="submit" name="submit" value="Modify">
|
<input class="deadbutton" type="submit" name="submit" value="Modify">
|
||||||
|
|||||||
Reference in new issue
Block a user