|
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 GSoCStudent. |
|
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 student |
|
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.student import logic as student_logic |
|
33 from soc.modules.gsoc.logic.models.mentor import logic as mentor_logic |
|
34 from soc.modules.gsoc.logic.models.org_admin import logic as org_admin_logic |
|
35 from soc.modules.gsoc.views.models import program as program_view |
|
36 |
|
37 |
|
38 class View(student.View): |
|
39 """View methods for the Student 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['create'] = ['checkIsDeveloper'] |
|
52 rights['edit'] = [('checkIsMyActiveRole', student_logic)] |
|
53 rights['delete'] = ['checkIsDeveloper'] |
|
54 rights['apply'] = [ |
|
55 'checkIsUser', |
|
56 ('checkIsActivePeriod', |
|
57 ['student_signup', 'scope_path', program_logic]), |
|
58 ('checkIsNotParticipatingInProgramInScope', [program_logic, |
|
59 student_logic, org_admin_logic, mentor_logic]), |
|
60 ] |
|
61 rights['manage'] = [('checkIsMyActiveRole', student_logic)] |
|
62 rights['list_projects'] = [ |
|
63 ('checkHasActiveRoleForScope', student_logic), |
|
64 ('checkIsAfterEvent', ['accepted_students_announced_deadline', |
|
65 'scope_path', program_logic])] |
|
66 |
|
67 new_params = {} |
|
68 new_params['logic'] = student_logic |
|
69 new_params['rights'] = rights |
|
70 |
|
71 new_params['group_logic'] = program_logic |
|
72 new_params['group_view'] = program_view.view |
|
73 |
|
74 new_params['scope_view'] = program_view |
|
75 |
|
76 new_params['name'] = "GSoC Student" |
|
77 new_params['module_name'] = "student" |
|
78 new_params['sidebar_grouping'] = 'Students' |
|
79 |
|
80 new_params['module_package'] = 'soc.modules.gsoc.views.models' |
|
81 new_params['url_name'] = 'gsoc/student' |
|
82 |
|
83 params = dicts.merge(params, new_params, sub_merge=True) |
|
84 |
|
85 super(View, self).__init__(params) |
|
86 |
|
87 |
|
88 view = View() |
|
89 |
|
90 apply = decorators.view(view.apply) |
|
91 create = decorators.view(view.create) |
|
92 delete = decorators.view(view.delete) |
|
93 edit = decorators.view(view.edit) |
|
94 list = decorators.view(view.list) |
|
95 list_projects = decorators.view(view.listProjects) |
|
96 manage = decorators.view(view.manage) |
|
97 public = decorators.view(view.public) |
|
98 export = decorators.view(view.export) |