Skip to content
Snippets Groups Projects
Commit f7bf9474 authored by Jaden Diefenbaugh's avatar Jaden Diefenbaugh
Browse files

finish pinning down permissions, add redirect

parent cffcf182
No related branches found
No related tags found
1 merge request!223Reports overhaul
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
# # # #
############################################################################### ###############################################################################
from django.shortcuts import render_to_response from django.shortcuts import render_to_response, redirect
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.template import RequestContext, Context from django.template import RequestContext, Context
from django.conf import settings from django.conf import settings
...@@ -85,20 +85,30 @@ def for_author(request, author_name, report_name): ...@@ -85,20 +85,30 @@ def for_author(request, author_name, report_name):
name = report_name) name = report_name)
isAuthor = request.user.username == obj.author.username isAuthor = request.user.username == obj.author.username
isEditable = obj.status == 'E'
if not isAuthor: isPublished = obj.status == 'P'
# return 404 isLocked = obj.status == 'L'
raise Http404('No %s matches the given query.' % Report._meta.object_name)
# if its the author and its locked, redirect to numbered url
return render_to_response('reports/report.html', # same if its published
{ if isPublished or (isAuthor and isLocked):
'author' : author_name, return redirect(obj)
'report_name' : report_name,
'owner' : (request.user == obj.author),
'report' : obj, # only valid when the author is accessing it and its editable
'USE_HTTPS_GRAVATAR': settings.USE_HTTPS_GRAVATAR, if isEditable and isAuthor:
}, return render_to_response('reports/report.html',
context_instance=RequestContext(request)) {
'author' : author_name,
'report_name' : report_name,
'owner' : (request.user == obj.author),
'report' : obj,
'USE_HTTPS_GRAVATAR': settings.USE_HTTPS_GRAVATAR,
},
context_instance=RequestContext(request))
# return 404
raise Http404('No %s matches the given query.' % Report._meta.object_name)
#------------------------------------------------ #------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment