Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #12 from DrClockwork/dev
Browse files Browse the repository at this point in the history
hotfix/superuser access in score management
  • Loading branch information
DrClockwork authored Jun 29, 2017
2 parents 3632325 + 334ad68 commit 43f6821
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions h5pp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def listView(request):

def scoreView(request, contentId):
owner = h5p_contents.objects.get(content_id=contentId)
if request.method == 'POST' and request.user.username == owner.author:
if request.method == 'POST' and (request.user.username == owner.author or request.user.is_superuser):
userData = h5p_content_user_data.objects.filter(content_main_id=contentId)
if userData:
userData.delete()
Expand All @@ -116,7 +116,7 @@ def scoreView(request, contentId):

return HttpResponseRedirect('/h5p/score/%s' % contentId, {'status': "Scores has been reset !"})

if 'user' in request.GET:
if 'user' in request.GET and (request.user.username == owner.author or request.user.is_superuser):
user = User.objects.get(username=request.GET['user'])
userData = h5p_content_user_data.objects.filter(user_id=user.id, content_main_id=contentId)
if userData:
Expand All @@ -128,14 +128,14 @@ def scoreView(request, contentId):
return HttpResponseRedirect('/h5p/score/%s' % contentId, {'status': "%s's score has been reset !" % user.username})

listScore = dict()
if request.user.username == owner.author:
if request.user.username == owner.author or request.user.is_superuser:
listScore['owner'] = True

listScore['data'] = getUserScore(contentId)
if listScore['data'] > 0:
return render(request, 'h5p/score.html', {'listScore': listScore, 'contentId': contentId})

return render(request, 'h5p/score.html', {'status': 'No score available yet.'})
return render(request, 'h5p/score.html', {'status': 'No score available yet.', 'contentId': contentId})

def embedView(request):
if 'contentId' in request.GET:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='H5PP',
version='0.1',
version='0.1.8',
packages=find_packages(),
include_package_data=True,
license='GPL License',
Expand Down

0 comments on commit 43f6821

Please sign in to comment.