70 |
70 |
71 params = dicts.merge(original_params, params) |
71 params = dicts.merge(original_params, params) |
72 |
72 |
73 base.View.__init__(self, params=params) |
73 base.View.__init__(self, params=params) |
74 |
74 |
75 def create(self, request, page_name=None, params=None, **kwargs): |
75 def create(self, request, **kwargs): |
76 """Specialized create view to enforce needing a scope_path |
76 """Specialized create view to enforce needing a scope_path |
77 |
77 |
78 This view simply gives control to the base.View.create if the |
78 This view simply gives control to the base.View.create if the |
79 scope_path is specified in kwargs. If it is not present, it |
79 scope_path is specified in kwargs. If it is not present, it |
80 instead displays the result of self.selectSponsor. Refer to the |
80 instead displays the result of self.select. Refer to the |
81 respective docstrings on what they do. |
81 respective docstrings on what they do. |
82 |
82 |
83 Args: |
83 Args: |
84 see base.View.create |
84 see base.View.create |
85 """ |
85 """ |
86 |
86 |
87 if 'scope_path' in kwargs: |
87 if 'scope_path' in kwargs: |
88 return super(View, self).create(request, page_name=page_name, |
88 return super(View, self).create(request, **kwargs) |
89 params=params, **kwargs) |
|
90 |
|
91 return self.selectSponsor(request, page_name, params) |
|
92 |
|
93 def selectSponsor(self, request, page_name, params): |
|
94 """Displays a list page allowing the user to select a Sponsor |
|
95 |
|
96 After having selected the Sponsor, the user is redirected to the |
|
97 'create a new program' page with the scope_path set appropriately. |
|
98 |
|
99 Params usage: |
|
100 The params dictionary is passed to getCreateProgramRedirect from |
|
101 the redirects module, please see the docstring for |
|
102 getCreateProgramRedirect on how it uses it. |
|
103 The params dictionary is also passed to getListContent from |
|
104 the helper.list module, please refer to its docstring also. |
|
105 The params dictionary is passed to self._list as well, refer |
|
106 to its docstring for details on how it uses it. |
|
107 |
|
108 Args: |
|
109 request: the standard Django HTTP request object |
|
110 page_name: the page name displayed in templates as page and header title |
|
111 params: a dict with params for this View |
|
112 """ |
|
113 |
89 |
114 view = sponsor_view.view |
90 view = sponsor_view.view |
115 redirect = redirects.getCreateRedirect |
91 redirect = redirects.getCreateRedirect |
116 |
92 return self.select(request, view, redirect, **kwargs) |
117 params = dicts.merge(params, self._params) |
|
118 |
|
119 new_params = {} |
|
120 new_params['list_action'] = (redirect, params) |
|
121 |
|
122 new_params = dicts.merge(new_params, view.getParams()) |
|
123 params = dicts.merge(new_params, params) |
|
124 |
|
125 content = helper.lists.getListContent(request, params) |
|
126 contents = [content] |
|
127 |
|
128 return self._list(request, params, contents, page_name) |
|
129 |
93 |
130 def _editGet(self, request, entity, form): |
94 def _editGet(self, request, entity, form): |
131 """See base.View._editGet(). |
95 """See base.View._editGet(). |
132 """ |
96 """ |
133 |
97 |