Prepared Survey access controls to deal with multiple logics.
authorLennard de Rijk <ljvderijk@gmail.com>
Mon, 29 Jun 2009 15:44:33 +0200
changeset 2447 dae6715a2f19
parent 2446 0cf8f034f52d
child 2448 325e08ee9d25
Prepared Survey access controls to deal with multiple logics. Also added a TODO to move a method to another view.
app/soc/views/helper/access.py
app/soc/views/models/survey.py
--- a/app/soc/views/helper/access.py	Mon Jun 29 15:19:28 2009 +0200
+++ b/app/soc/views/helper/access.py	Mon Jun 29 15:44:33 2009 +0200
@@ -1512,7 +1512,7 @@
 
   @allowSidebar
   @allowDeveloper
-  def checkIsSurveyReadable(self, django_args, key_name_field=None):
+  def checkIsSurveyReadable(self, django_args, survey_logic, key_name_field=None):
     """Checks whether a survey is readable.
 
     Args:
@@ -1531,7 +1531,7 @@
 
   @denySidebar
   @allowDeveloper
-  def checkIsSurveyWritable(self, django_args, key_name_field=None):
+  def checkIsSurveyWritable(self, django_args, survey_logic, key_name_field=None):
     """Checks whether a survey is writable.
 
     Args:
--- a/app/soc/views/models/survey.py	Mon Jun 29 15:19:28 2009 +0200
+++ b/app/soc/views/models/survey.py	Mon Jun 29 15:44:33 2009 +0200
@@ -102,13 +102,12 @@
 
     rights = access.Checker(params)
     rights['any_access'] = ['allow']
-    rights['show'] = ['checkIsSurveyReadable']
+    rights['show'] = [('checkIsSurveyReadable', survey_logic)]
     rights['create'] = ['checkIsUser']
-    rights['edit'] = ['checkIsSurveyWritable']
-    rights['delete'] = ['checkIsSurveyWritable']
+    rights['edit'] = [('checkIsSurveyWritable', survey_logic)]
+    rights['delete'] = [('checkIsSurveyWritable', survey_logic)]
     rights['list'] = ['checkDocumentList']
     rights['pick'] = ['checkDocumentPick']
-    rights['grade'] = ['checkIsSurveyGradable']
 
     new_params = {}
     # TODO(ajaksu) pass logic in a way views can use them
@@ -720,6 +719,7 @@
       submenus.append(submenu)
     return submenus
 
+  # TODO the following two methods should move to GradingProjectSurvey
   def activate(self, request, **kwargs):
     """This is a hack to support the 'Enable grades' button.
     """