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
|
||||
|
||||
|
||||
# Wrap django.shortcuts.render to add framework settings
|
||||
def render(request, template, data):
|
||||
|
||||
# Always provde the Configuration
|
||||
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)
|
||||
|
||||
def register(request):
|
||||
@@ -81,9 +87,7 @@ def logout(request):
|
||||
@login_required(login_url='/login/')
|
||||
def viewProfile(request):
|
||||
|
||||
# Build context dictionary for profile template
|
||||
profile = Profile.objects.get(user=request.user)
|
||||
data = {'profile' : profile}
|
||||
# render() gets the profile data for us
|
||||
return render(request, 'viewProfile.html', data)
|
||||
|
||||
@login_required(login_url='/login/')
|
||||
@@ -111,10 +115,6 @@ def editProfile(request):
|
||||
|
||||
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
|
||||
pending = Test.objects.filter(approved=False)
|
||||
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
|
||||
data = {
|
||||
'error' : error,
|
||||
'profile' : profile,
|
||||
'pending' : pending,
|
||||
'active' : active,
|
||||
'completed' : completed[start:end],
|
||||
@@ -282,8 +281,7 @@ def newTest(request):
|
||||
|
||||
# User trying to view the new test page
|
||||
if request.method == 'GET':
|
||||
profile = Profile.objects.get(user=request.user)
|
||||
return render(request, 'newTest.html', {'profile' : profile})
|
||||
return render(request, 'newTest.html', {})
|
||||
|
||||
try:
|
||||
# Throw out non-approved / disabled users
|
||||
@@ -311,8 +309,7 @@ def viewTest(request, id):
|
||||
# Build context dictionary for test template
|
||||
test = Test.objects.get(id=id)
|
||||
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, 'profile' : profile}
|
||||
data = {'test' : test, 'results' : results}
|
||||
return render(request, 'viewTest.html', data)
|
||||
|
||||
# Unable to find test
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
<h2>Actions</h2>
|
||||
|
||||
<!-- 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>
|
||||
{% elif not test.approved and request.user.is_superuser %}
|
||||
<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 -->
|
||||
{% if test.finished and profile.approver %}
|
||||
<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>
|
||||
{% elif test.finished %}
|
||||
<a class="anchorbutton deadbutton">Restart</a>
|
||||
@@ -109,14 +109,14 @@
|
||||
<!-- Stop Button: For Approvers or Test Authors of active tests -->
|
||||
{% if not test.finished and profile.approver %}
|
||||
<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>
|
||||
{% elif not test.finished %}
|
||||
<a class="anchorbutton deadbutton">Stop</a>
|
||||
{% endif %}
|
||||
|
||||
<!-- 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>
|
||||
{% else %}
|
||||
<a class="anchorbutton deadbutton">Delete</a>
|
||||
@@ -136,7 +136,7 @@
|
||||
<input value="{{test.priority}}" name="priority"></br>
|
||||
<label>Throughput</label>
|
||||
<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">
|
||||
{% else %}
|
||||
<input class="deadbutton" type="submit" name="submit" value="Modify">
|
||||
|
||||
Reference in new issue
Block a user