~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/app/browser/launchpadform.py

  • Committer: Stuart Bishop
  • Date: 2011-09-28 12:49:24 UTC
  • mfrom: (9893.10.1 trivial)
  • mto: This revision was merged to the branch mainline in revision 14178.
  • Revision ID: stuart.bishop@canonical.com-20110928124924-m5a22fymqghw6c5i
Merged trivial into distinct-db-users.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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).
3
3
 
4
4
"""Launchpad Form View Classes
116
116
        self.setUpWidgets()
117
117
 
118
118
        data = {}
119
 
        errors, action = form.handleSubmit(self.actions, data, self._validate)
 
119
        errors, form_action = form.handleSubmit(
 
120
            self.actions, data, self._validate)
120
121
 
121
122
        # no action selected, so return
122
 
        if action is None:
 
123
        if form_action is None:
123
124
            return
124
125
 
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__)
130
131
 
131
132
        if errors:
132
 
            self.form_result = action.failure(data, errors)
 
133
            self.form_result = form_action.failure(data, errors)
133
134
            self._abort()
134
135
        else:
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
141
142
 
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.
242
243
        """
243
 
        for action in self.actions:
244
 
            if action.available():
 
244
        for form_action in self.actions:
 
245
            if form_action.available():
245
246
                return True
246
247
        return False
247
248