app/soc/modules/gsoc/views/models/program.py
changeset 3043 187c1709756b
child 3067 371e1979ee6a
equal deleted inserted replaced
3042:72eec4d72471 3043:187c1709756b
       
     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 """Views for GSoCProgram.
       
    18 """
       
    19 
       
    20 __authors__ = [
       
    21     '"Sverre Rabbelier" <sverre@rabbelier.nl>',
       
    22   ]
       
    23 
       
    24 
       
    25 from soc.logic import dicts
       
    26 from soc.views.helper import decorators
       
    27 from soc.views.helper import access # TODO
       
    28 from soc.views.models import program
       
    29 
       
    30 from soc.logic.models.host import logic as host_logic
       
    31 from soc.modules.gsoc.logic.models.program import logic as program_logic
       
    32 from soc.modules.gsoc.logic.models.org_admin import logic as org_admin_logic
       
    33 
       
    34 
       
    35 class View(program.View):
       
    36   """View methods for the Program model.
       
    37   """
       
    38 
       
    39   def __init__(self, params=None):
       
    40     """Defines the fields and methods required for the base View class
       
    41     to provide the user with list, public, create, edit and delete views.
       
    42 
       
    43     Params:
       
    44       params: a dict with params for this View
       
    45     """
       
    46 
       
    47     rights = access.Checker(params)
       
    48     rights['any_access'] = ['allow']
       
    49     rights['show'] = ['allow']
       
    50     rights['create'] = [('checkSeeded', ['checkHasActiveRoleForScope',
       
    51         host_logic])]
       
    52     rights['edit'] = ['checkIsHostForProgram']
       
    53     rights['delete'] = ['checkIsDeveloper']
       
    54     rights['assign_slots'] = ['checkIsHostForProgram']
       
    55     rights['slots'] = ['checkIsHostForProgram']
       
    56     rights['show_duplicates'] = ['checkIsHostForProgram']
       
    57     rights['assigned_proposals'] = ['checkIsHostForProgram']
       
    58     rights['accepted_orgs'] = [('checkIsAfterEvent',
       
    59         ['accepted_organization_announced_deadline',
       
    60          '__all__', program_logic])]
       
    61     rights['list_projects'] = [('checkIsAfterEvent',
       
    62         ['accepted_students_announced_deadline',
       
    63          '__all__', program_logic])]
       
    64 
       
    65     new_params = {}
       
    66     new_params['logic'] = program_logic
       
    67     new_params['rights'] = rights
       
    68 
       
    69     new_params['name'] = "GSoC Program"
       
    70     new_params['module_name'] = "program"
       
    71     new_params['sidebar_grouping'] = 'Programs'
       
    72 
       
    73     new_params['module_package'] = 'soc.modules.gsoc.views.models'
       
    74     new_params['url_name'] = 'gsoc/program'
       
    75 
       
    76     params = dicts.merge(params, new_params, sub_merge=True)
       
    77 
       
    78     super(View, self).__init__(params)
       
    79 
       
    80 
       
    81 view = View()
       
    82 
       
    83 accepted_orgs = decorators.view(view.acceptedOrgs)
       
    84 list_projects = decorators.view(view.acceptedProjects)
       
    85 admin = decorators.view(view.admin)
       
    86 assign_slots = decorators.view(view.assignSlots)
       
    87 assigned_proposals = decorators.view(view.assignedProposals)
       
    88 create = decorators.view(view.create)
       
    89 delete = decorators.view(view.delete)
       
    90 edit = decorators.view(view.edit)
       
    91 list = decorators.view(view.list)
       
    92 public = decorators.view(view.public)
       
    93 export = decorators.view(view.export)
       
    94 show_duplicates = decorators.view(view.showDuplicates)
       
    95 slots = decorators.view(view.slots)
       
    96 home = decorators.view(view.home)
       
    97 pick = decorators.view(view.pick)