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 Timeline. |
|
18 """ |
|
19 |
|
20 __authors__ = [ |
|
21 '"Madhusudan.C.S" <madhusudancs@gmail.com>' |
|
22 ] |
|
23 |
|
24 |
|
25 from soc.logic import dicts |
|
26 from soc.views.helper import decorators |
|
27 from soc.views.helper import dynaform |
|
28 from soc.views.helper import params as params_helper |
|
29 from soc.views.models import timeline |
|
30 from soc.views.sitemap import sidebar |
|
31 |
|
32 import soc.cache.logic |
|
33 |
|
34 from soc.modules.ghop.logic.models import program as ghop_program_logic |
|
35 |
|
36 import soc.modules.ghop.logic.models.timeline |
|
37 |
|
38 |
|
39 class View(timeline.View): |
|
40 """View methods for the GHOP Timeline model. |
|
41 """ |
|
42 |
|
43 def __init__(self, params=None): |
|
44 """Defines the fields and methods required for the program View class |
|
45 to provide the user with list, public, create, edit and delete views. |
|
46 |
|
47 Params: |
|
48 params: a dict with params for this View |
|
49 """ |
|
50 |
|
51 new_params = {} |
|
52 new_params['logic'] = soc.modules.ghop.logic.models.timeline.logic |
|
53 |
|
54 new_params['name'] = "GHOP Timeline" |
|
55 new_params['module_name'] = "timeline" |
|
56 |
|
57 new_params['module_package'] = 'soc.modules.ghop.views.models' |
|
58 new_params['url_name'] = 'ghop/timeline' |
|
59 |
|
60 params = dicts.merge(params, new_params, sub_merge=True) |
|
61 |
|
62 super(View, self).__init__(params=params) |
|
63 |
|
64 def edit(self, request, access_type, |
|
65 page_name=None, params=None, seed=None, **kwargs): |
|
66 """See base.View.edit. |
|
67 """ |
|
68 |
|
69 params = dicts.merge(params, self._params) |
|
70 |
|
71 key_fields = ghop_program_logic.logic.getKeyFieldsFromFields(kwargs) |
|
72 |
|
73 program = ghop_program_logic.logic.getFromKeyFields(key_fields) |
|
74 if program: |
|
75 params['logic'] = ghop_program_logic.logic.timeline_logic |
|
76 |
|
77 timeline_model = ghop_program_logic.logic.timeline_logic |
|
78 |
|
79 return super(View, self).edit(request, access_type, page_name=page_name, |
|
80 params=params, seed=seed, **kwargs) |
|
81 |
|
82 |
|
83 view = View() |
|
84 |
|
85 admin = decorators.view(view.admin) |
|
86 create = decorators.view(view.create) |
|
87 delete = decorators.view(view.delete) |
|
88 edit = decorators.view(view.edit) |
|
89 list = decorators.view(view.list) |
|
90 public = decorators.view(view.public) |
|
91 export = decorators.view(view.export) |
|