|
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 GSoCOrganization. |
|
18 """ |
|
19 |
|
20 __authors__ = [ |
|
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
|
22 ] |
|
23 |
|
24 |
|
25 from soc.logic import dicts |
|
26 from soc.logic.models.org_app import logic as org_app_logic |
|
27 from soc.views.helper import decorators |
|
28 from soc.views.models import organization |
|
29 from soc.views.helper import access # TODO |
|
30 from soc.views.models import group |
|
31 |
|
32 from soc.modules.gsoc.logic.models.mentor import logic as mentor_logic |
|
33 from soc.modules.gsoc.logic.models.org_admin import logic as org_admin_logic |
|
34 from soc.modules.gsoc.logic.models.organization import logic as org_logic |
|
35 from soc.modules.gsoc.views.models import program as program_view |
|
36 |
|
37 |
|
38 class View(organization.View): |
|
39 """View methods for the Organization model. |
|
40 """ |
|
41 |
|
42 def __init__(self, params=None): |
|
43 """Defines the fields and methods required for the base 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 = access.Checker(params) |
|
51 rights['any_access'] = ['allow'] |
|
52 rights['show'] = ['allow'] |
|
53 rights['create'] = ['checkIsDeveloper'] |
|
54 rights['edit'] = [('checkHasActiveRoleForKeyFieldsAsScope', |
|
55 org_admin_logic), |
|
56 ('checkGroupIsActiveForLinkId', org_logic)] |
|
57 rights['delete'] = ['checkIsDeveloper'] |
|
58 rights['home'] = ['allow'] |
|
59 rights['public_list'] = ['allow'] |
|
60 rights['apply_mentor'] = ['checkIsUser'] |
|
61 rights['list_requests'] = [('checkHasActiveRoleForKeyFieldsAsScope', |
|
62 org_admin_logic)] |
|
63 rights['list_roles'] = [('checkHasActiveRoleForKeyFieldsAsScope', |
|
64 org_admin_logic)] |
|
65 rights['applicant'] = [('checkIsApplicationAccepted', |
|
66 org_app_logic)] |
|
67 rights['list_proposals'] = [('checkHasAny', [ |
|
68 [('checkHasActiveRoleForKeyFieldsAsScope', [org_admin_logic]), |
|
69 ('checkHasActiveRoleForKeyFieldsAsScope', [mentor_logic])] |
|
70 ])] |
|
71 |
|
72 new_params = {} |
|
73 new_params['logic'] = org_logic |
|
74 new_params['rights'] = rights |
|
75 |
|
76 new_params['scope_view'] = program_view |
|
77 |
|
78 new_params['name'] = "GSoC Organization" |
|
79 new_params['module_name'] = "organization" |
|
80 new_params['sidebar_grouping'] = 'Organizations' |
|
81 |
|
82 new_params['module_package'] = 'soc.modules.gsoc.views.models' |
|
83 new_params['url_name'] = 'gsoc/org' |
|
84 new_params['document_prefix'] = 'gsoc_org' |
|
85 |
|
86 new_params['mentor_role_name'] = 'gsoc_mentor' |
|
87 |
|
88 params = dicts.merge(params, new_params, sub_merge=True) |
|
89 |
|
90 super(View, self).__init__(params) |
|
91 |
|
92 |
|
93 view = View() |
|
94 |
|
95 admin = decorators.view(view.admin) |
|
96 #applicant = decorators.view(view.applicant) # TODO |
|
97 apply_mentor = decorators.view(view.applyMentor) |
|
98 create = decorators.view(view.create) |
|
99 delete = decorators.view(view.delete) |
|
100 edit = decorators.view(view.edit) |
|
101 home = decorators.view(view.home) |
|
102 list = decorators.view(view.list) |
|
103 list_proposals = decorators.view(view.listProposals) |
|
104 list_public = decorators.view(view.listPublic) |
|
105 list_requests = decorators.view(view.listRequests) |
|
106 list_roles = decorators.view(view.listRoles) |
|
107 public = decorators.view(view.public) |
|
108 export = decorators.view(view.export) |
|
109 pick = decorators.view(view.pick) |