app/soc/modules/ghop/views/models/org_admin.py
changeset 2887 a63cfe4f4b12
child 2919 cb677410c0f1
equal deleted inserted replaced
2886:52f9b098a6da 2887:a63cfe4f4b12
       
     1 #!/usr/bin/python2.5
       
     2 #
       
     3 # Copyright 2009 the Melange authors.
       
     4 #
       
     5 # Licensed under the Apache License, Version 2.0 (the "License");
       
     6 # you may not use this file except in compliance with the License.
       
     7 # You may obtain a copy of the License at
       
     8 #
       
     9 #   http://www.apache.org/licenses/LICENSE-2.0
       
    10 #
       
    11 # Unless required by applicable law or agreed to in writing, software
       
    12 # distributed under the License is distributed on an "AS IS" BASIS,
       
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    14 # See the License for the specific language governing permissions and
       
    15 # limitations under the License.
       
    16 
       
    17 """GHOP specific views for Org Admins.
       
    18 """
       
    19 
       
    20 __authors__ = [
       
    21     '"Madhusudan.C.S" <madhusudancs@gmail.com>'
       
    22   ]
       
    23 
       
    24 
       
    25 from soc.logic import dicts
       
    26 from soc.views.helper import decorators
       
    27 from soc.views.models import org_admin
       
    28 
       
    29 from soc.modules.ghop.logic.models import organization as ghop_org_logic
       
    30 from soc.modules.ghop.logic.models import org_admin as ghop_org_admin_logic
       
    31 from soc.modules.ghop.logic.models import student as ghop_student_logic
       
    32 from soc.modules.ghop.views.helper import access as ghop_access
       
    33 from soc.modules.ghop.views.models import organization as ghop_org_view
       
    34 
       
    35 import soc.modules.ghop.logic.models.org_admin
       
    36 
       
    37 
       
    38 class View(org_admin.View):
       
    39   """View methods for the GHOP OrgAdmin model.
       
    40   """
       
    41 
       
    42   def __init__(self, params=None):
       
    43     """Defines the fields and methods required for the org_admin View class
       
    44     to provide the user with list, public, create, edit and delete views.
       
    45 
       
    46     Params:
       
    47       params: a dict with params for this View
       
    48     """
       
    49 
       
    50     rights = ghop_access.GHOPChecker(params)
       
    51     rights['create'] = ['checkIsDeveloper']
       
    52     rights['edit'] = [
       
    53         ('checkHasActiveRoleForScope', ghop_org_admin_logic.logic),
       
    54         ('checkIsMyEntity', [ghop_org_admin_logic.logic, 'user', True])]
       
    55     rights['delete'] = ['checkIsDeveloper']
       
    56     rights['invite'] = [('checkHasActiveRoleForScope',
       
    57                          ghop_org_admin_logic.logic)]
       
    58     rights['accept_invite'] = [('checkCanCreateFromRequest', 'ghop/org_admin'),
       
    59         ('checkIsNotStudentForProgramOfOrg', 
       
    60          [ghop_org_logic.logic, ghop_student_logic.logic])]
       
    61     rights['process_request'] = [
       
    62         ('checkHasActiveRoleForScope', ghop_org_admin_logic.logic),
       
    63         ('checkCanProcessRequest', 'ghop/org_admin')]
       
    64     rights['manage'] = [
       
    65         ('checkIsAllowedToManageRole', [ghop_org_admin_logic.logic,
       
    66              ghop_org_admin_logic.logic])]
       
    67 
       
    68     new_params = {}
       
    69     new_params['logic'] = soc.modules.ghop.logic.models.org_admin.logic
       
    70     new_params['group_logic'] = ghop_org_logic.logic
       
    71     new_params['group_view'] = ghop_org_view.view
       
    72     new_params['rights'] = rights
       
    73 
       
    74     new_params['scope_view'] = ghop_org_view
       
    75 
       
    76     new_params['name'] = "GHOP Organization Admin"
       
    77     new_params['module_name'] = "org_admin"
       
    78     new_params['sidebar_grouping'] = 'Organizations'
       
    79 
       
    80     new_params['module_package'] = 'soc.modules.ghop.views.models'
       
    81     new_params['url_name'] = 'ghop/org_admin'
       
    82 
       
    83     new_params['role'] = 'ghop/org_admin'
       
    84 
       
    85     params = dicts.merge(params, new_params, sub_merge=True)
       
    86 
       
    87     super(View, self).__init__(params=params)
       
    88 
       
    89 
       
    90 view = View()
       
    91 
       
    92 accept_invite = decorators.view(view.acceptInvite)
       
    93 admin = decorators.view(view.admin)
       
    94 create = decorators.view(view.create)
       
    95 delete = decorators.view(view.delete)
       
    96 edit = decorators.view(view.edit)
       
    97 invite = decorators.view(view.invite)
       
    98 list = decorators.view(view.list)
       
    99 manage = decorators.view(view.manage)
       
   100 process_request = decorators.view(view.processRequest)
       
   101 public = decorators.view(view.public)
       
   102 export = decorators.view(view.export)