|
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 GSoCMentor. |
|
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.models import mentor |
|
28 |
|
29 from soc.modules.gsoc.logic.models.mentor import logic as mentor_logic |
|
30 from soc.modules.gsoc.logic.models.org_admin import logic as org_admin_logic |
|
31 from soc.modules.gsoc.logic.models.organization import logic as org_logic |
|
32 from soc.modules.gsoc.logic.models.student import logic as student_logic |
|
33 from soc.modules.gsoc.views.models import organization as org_view |
|
34 from soc.views.helper import access # TODO |
|
35 |
|
36 |
|
37 class View(mentor.View): |
|
38 """View methods for the GSoCMentor model. |
|
39 """ |
|
40 |
|
41 def __init__(self, params=None): |
|
42 """Defines the fields and methods required for the base View class |
|
43 to provide the user with list, public, create, edit and delete views. |
|
44 |
|
45 Params: |
|
46 params: a dict with params for this View |
|
47 """ |
|
48 |
|
49 rights = access.Checker(params) |
|
50 rights['create'] = ['checkIsDeveloper'] |
|
51 rights['edit'] = [('checkIsMyActiveRole', mentor_logic)] |
|
52 rights['delete'] = ['checkIsDeveloper'] |
|
53 rights['invite'] = [('checkHasActiveRoleForScope', org_admin_logic)] |
|
54 rights['accept_invite'] = [('checkCanCreateFromRequest', 'mentor'), |
|
55 ('checkIsNotStudentForProgramOfOrg', [org_logic, |
|
56 student_logic])] |
|
57 rights['request'] = [ |
|
58 ('checkIsNotStudentForProgramOfOrg', |
|
59 [org_logic, student_logic]), |
|
60 ('checkCanMakeRequestToGroup', org_logic)] |
|
61 rights['process_request'] = [ |
|
62 ('checkHasActiveRoleForScope', org_admin_logic), |
|
63 ('checkCanProcessRequest', 'mentor')] |
|
64 rights['manage'] = [ |
|
65 ('checkIsAllowedToManageRole', [mentor_logic, org_admin_logic])] |
|
66 |
|
67 new_params = {} |
|
68 new_params['logic'] = mentor_logic |
|
69 new_params['group_logic'] = org_logic |
|
70 new_params['group_view'] = org_view.view |
|
71 new_params['rights'] = rights |
|
72 |
|
73 new_params['scope_view'] = org_view |
|
74 |
|
75 new_params['name'] = "GSoC Mentor" |
|
76 new_params['module_name'] = "mentor" |
|
77 new_params['sidebar_grouping'] = 'Organizations' |
|
78 |
|
79 new_params['module_package'] = 'soc.modules.gsoc.views.models' |
|
80 new_params['url_name'] = 'gsoc/mentor' |
|
81 |
|
82 new_params['role'] = 'gsoc/mentor' |
|
83 |
|
84 params = dicts.merge(params, new_params, sub_merge=True) |
|
85 |
|
86 super(View, self).__init__(params) |
|
87 |
|
88 |
|
89 view = View() |
|
90 |
|
91 accept_invite = decorators.view(view.acceptInvite) |
|
92 admin = decorators.view(view.admin) |
|
93 create = decorators.view(view.create) |
|
94 delete = decorators.view(view.delete) |
|
95 edit = decorators.view(view.edit) |
|
96 invite = decorators.view(view.invite) |
|
97 list = decorators.view(view.list) |
|
98 manage = decorators.view(view.manage) |
|
99 process_request = decorators.view(view.processRequest) |
|
100 role_request = decorators.view(view.request) |
|
101 public = decorators.view(view.public) |
|
102 export = decorators.view(view.export) |
|
103 pick = decorators.view(view.pick) |