|
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 Student. |
|
18 """ |
|
19 |
|
20 __authors__ = [ |
|
21 '"Madhusudan.C.S" <madhusudancs@gmail.com>', |
|
22 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
|
23 ] |
|
24 |
|
25 |
|
26 from soc.logic import dicts |
|
27 from soc.views.helper import decorators |
|
28 from soc.views.helper import dynaform |
|
29 from soc.views.models import student |
|
30 |
|
31 from soc.modules.ghop.logic.models import mentor as ghop_mentor_logic |
|
32 from soc.modules.ghop.logic.models import organization as ghop_org_logic |
|
33 from soc.modules.ghop.logic.models import org_admin as ghop_org_admin_logic |
|
34 from soc.modules.ghop.logic.models import program as ghop_program_logic |
|
35 from soc.modules.ghop.logic.models import student as ghop_student_logic |
|
36 from soc.modules.ghop.views.helper import access as ghop_access |
|
37 from soc.modules.ghop.views.models import program as ghop_program_view |
|
38 |
|
39 import soc.modules.ghop.logic.models.student |
|
40 |
|
41 |
|
42 class View(student.View): |
|
43 """View methods for the GHOP Student model. |
|
44 """ |
|
45 |
|
46 def __init__(self, params=None): |
|
47 """Defines the fields and methods required for the student View class |
|
48 to provide the user with list, public, create, edit and delete views. |
|
49 |
|
50 Params: |
|
51 params: a dict with params for this View |
|
52 """ |
|
53 |
|
54 rights = ghop_access.GHOPChecker(params) |
|
55 rights['edit'] = [('checkIsMyActiveRole', ghop_student_logic.logic)] |
|
56 rights['apply'] = [ |
|
57 'checkIsUser', |
|
58 ('checkIsActivePeriod', |
|
59 ['student_signup', 'scope_path', ghop_program_logic.logic]), |
|
60 ('checkIsNotParticipatingInProgramInScope', [ghop_program_logic.logic, |
|
61 ghop_student_logic.logic, ghop_org_admin_logic.logic, |
|
62 ghop_mentor_logic.logic]), |
|
63 'checkCanApply'] |
|
64 rights['manage'] = [('checkIsMyActiveRole', ghop_student_logic.logic)] |
|
65 |
|
66 new_params = {} |
|
67 new_params['logic'] = soc.modules.ghop.logic.models.student.logic |
|
68 new_params['rights'] = rights |
|
69 |
|
70 new_params['group_logic'] = ghop_program_logic.logic |
|
71 new_params['group_view'] = ghop_program_view.view |
|
72 |
|
73 new_params['scope_view'] = ghop_program_view |
|
74 |
|
75 new_params['name'] = "GHOP Student" |
|
76 new_params['module_name'] = "student" |
|
77 new_params['sidebar_grouping'] = 'Students' |
|
78 |
|
79 new_params['module_package'] = 'soc.modules.ghop.views.models' |
|
80 new_params['url_name'] = 'ghop/student' |
|
81 |
|
82 params = dicts.merge(params, new_params, sub_merge=True) |
|
83 |
|
84 super(View, self).__init__(params=params) |
|
85 |
|
86 |
|
87 view = View() |
|
88 |
|
89 apply = decorators.view(view.apply) |
|
90 create = decorators.view(view.create) |
|
91 delete = decorators.view(view.delete) |
|
92 edit = decorators.view(view.edit) |
|
93 list = decorators.view(view.list) |
|
94 manage = decorators.view(view.manage) |
|
95 public = decorators.view(view.public) |
|
96 export = decorators.view(view.export) |