|
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 ProjectSurveys. |
|
18 """ |
|
19 |
|
20 __authors__ = [ |
|
21 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
|
22 ] |
|
23 |
|
24 |
|
25 from soc.logic import dicts |
|
26 from soc.logic.models.survey import project_logic as project_survey_logic |
|
27 from soc.views.models import survey |
|
28 |
|
29 |
|
30 class View(survey.View): |
|
31 """View methods for the ProjectSurvey model. |
|
32 """ |
|
33 |
|
34 def __init__(self, params=None): |
|
35 """Defines the fields and methods required for the base View class |
|
36 to provide the user with list, public, create, edit and delete views. |
|
37 |
|
38 Params: |
|
39 params: a dict with params for this View |
|
40 """ |
|
41 |
|
42 rights = access.Checker(params) |
|
43 rights['any_access'] = ['allow'] |
|
44 rights['show'] = [('checkIsSurveyReadable', project_survey_logic)] |
|
45 rights['create'] = ['checkIsUser'] |
|
46 rights['edit'] = [('checkIsSurveyWritable', project_survey_logic)] |
|
47 rights['delete'] = [('checkIsSurveyWritable', project_survey_logic)] |
|
48 rights['list'] = ['checkDocumentList'] |
|
49 rights['pick'] = ['checkDocumentPick'] |
|
50 |
|
51 new_params = {} |
|
52 new_params['logic'] = project_survey_logic |
|
53 new_params['rights'] = rights |
|
54 |
|
55 new_params['name'] = "Project Survey" |
|
56 |
|
57 new_params['extra_dynaexclude'] = ['prefix', 'taking_access'] |
|
58 |
|
59 params = dicts.merge(params, new_params) |
|
60 |
|
61 super(View, self).__init__(params=params) |
|
62 |
|
63 |
|
64 view = View() |
|
65 |
|
66 admin = decorators.view(view.admin) |
|
67 create = decorators.view(view.create) |
|
68 edit = decorators.view(view.edit) |
|
69 delete = decorators.view(view.delete) |
|
70 list = decorators.view(view.list) |
|
71 public = decorators.view(view.public) |
|
72 export = decorators.view(view.export) |
|
73 pick = decorators.view(view.pick) |
|
74 activate = decorators.view(view.activate) |
|
75 results = decorators.view(view.viewResults) |
|
76 json = decorators.view(view.exportSerialized) |