1
# Copyright 2009 Canonical Ltd. This software is licensed under the
1
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
4
"""Launchpad Form View Classes
116
116
self.setUpWidgets()
119
errors, action = form.handleSubmit(self.actions, data, self._validate)
119
errors, form_action = form.handleSubmit(
120
self.actions, data, self._validate)
121
122
# no action selected, so return
123
if form_action is None:
125
126
# Check to see if an attempt was made to submit a non-safe
126
127
# action with a GET query.
127
is_safe = getattr(action, 'is_safe', False)
128
is_safe = getattr(form_action, 'is_safe', False)
128
129
if not is_safe and self.request.method != 'POST':
129
raise UnsafeFormGetSubmissionError(action.__name__)
130
raise UnsafeFormGetSubmissionError(form_action.__name__)
132
self.form_result = action.failure(data, errors)
133
self.form_result = form_action.failure(data, errors)
135
self.form_result = action.success(data)
136
self.form_result = form_action.success(data)
136
137
if self.next_url:
137
138
self.request.response.redirect(self.next_url)
138
139
if self.request.is_ajax:
139
140
self._processNotifications(self.request)
140
self.action_taken = action
141
self.action_taken = form_action
142
143
def _processNotifications(self, request):
143
144
"""Add any notification messages to the response headers."""
240
241
If False is returned, the view or template probably needs to explain
241
242
why no actions can be performed and offer a cancel link.
243
for action in self.actions:
244
if action.available():
244
for form_action in self.actions:
245
if form_action.available():