# HG changeset patch # User Sverre Rabbelier # Date 1228662123 0 # Node ID 4e8eefe95748ae2095ea3eb71836c7f16b5b9ad6 # Parent a953f06766995d9baa8a2a3c535134dd9122c313 Add and use a placeholder for checkIsDocumentPublic We should somehow decide whether a document is publically viewable. This should of course be dependant on what the document is, e.g. the FAQ of a program should be allow(), whereas a student's application should be checkIsMentor(). Patch by: Sverre Rabbelier diff -r a953f0676699 -r 4e8eefe95748 app/soc/views/helper/access.py --- a/app/soc/views/helper/access.py Sun Dec 07 15:01:31 2008 +0000 +++ b/app/soc/views/helper/access.py Sun Dec 07 15:02:03 2008 +0000 @@ -207,7 +207,7 @@ checkIsUser(request) if accounts.isDeveloper(account=users.get_current_user()): - return None + return login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % { 'role': 'a site developer '} @@ -273,3 +273,15 @@ return raise out_of_band.LoginRequest(message_fmt=login_message_fmt) + + +def checkIsDocumentPublic(request): + """Checks whether a document is public + + Args: + request: a Django HTTP request + """ + + # TODO: A proper check needs to be done to see if the document + # is public or not, probably involving analysing it's scope or such. + allow(request) diff -r a953f0676699 -r 4e8eefe95748 app/soc/views/models/document.py --- a/app/soc/views/models/document.py Sun Dec 07 15:01:31 2008 +0000 +++ b/app/soc/views/models/document.py Sun Dec 07 15:02:03 2008 +0000 @@ -32,6 +32,7 @@ from soc.logic import validate from soc.logic.models import user as user_logic from soc.views import helper +from soc.views.helper import access from soc.views.models import base import soc.models.document @@ -94,8 +95,13 @@ params: a dict with params for this View """ + rights = {} + rights['any_access'] = [access.allow] + rights['public'] = [access.checkIsDocumentPublic] + new_params = {} new_params['logic'] = soc.logic.models.document.logic + new_params['rights'] = rights new_params['name'] = "Document" new_params['name_short'] = "Document"