add checkIsHostForStudentProject checker
authorSverre Rabbelier <srabbelier@gmail.com>
Sun, 02 Aug 2009 02:52:48 -0700
changeset 2710 9a93624bd2d4
parent 2709 7a595f688ab5
child 2711 4df8c11c36cb
add checkIsHostForStudentProject checker
app/soc/views/helper/access.py
--- a/app/soc/views/helper/access.py	Sun Aug 02 15:19:50 2009 +0530
+++ b/app/soc/views/helper/access.py	Sun Aug 02 02:52:48 2009 -0700
@@ -1429,6 +1429,29 @@
     return
 
   @allowDeveloper
+  def checkIsHostForStudentProject(self, django_args):
+    """Checks whether the user is Host for the specified project.
+
+    Args:
+      django_args: a dictionary with django's arguments
+
+     Raises:
+       AccessViolationResponse:
+         - If there is no project found
+         - If the user is not a host for hte specified project
+    """
+
+    self.checkIsUser()
+
+    project_entity = student_project_logic.getFromKeyFieldsOr404(django_args)
+    program_entity = project_entity.program
+
+    new_args = {'scope_path': program_entity.scope_path }
+    self.checkHasActiveRoleForScope(new_args, host_logic)
+
+    return
+
+  @allowDeveloper
   def checkStudentProjectHasStatus(self, django_args, allowed_status):
     """Checks whether the Project has one of the given statuses.