Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Stop user from restarting a completed/failed transaction (bug 829750)

  • Loading branch information...
commit f22d4cab490a7684cc6a9c9d6a97ca376e61cb6b 1 parent aa0c318
@wraithan wraithan authored
View
4 lib/solitude/constants.py
@@ -9,3 +9,7 @@
STATUS_COMPLETED = 1
STATUS_CHECKED = 2
STATUS_RECEIVED = 3
+STATUS_FAILED = 4
+STATUS_CANCELLED = 5
+
+STATUS_ENDED = (STATUS_COMPLETED, STATUS_FAILED, STATUS_CANCELLED)
View
15 webpay/pay/tests/test_views.py
@@ -335,6 +335,21 @@ def test_start_not_ready(self, get_transaction):
eq_(data['url'], None)
eq_(data['status'], constants.STATUS_RECEIVED)
+ def wait_ended_transaction(self, get_transaction, status):
+ with self.settings(VERBOSE_LOGGING=True):
+ get_transaction.return_value = {
+ 'status': status,
+ 'uid_pay': 123,
+ }
+ res = self.client.get(self.wait)
+ self.assertContains(res,
+ 'Transaction has already ended.',
+ status_code=400)
+
+ def test_wait_ended_transaction(self, get_transaction):
+ for status in constants.STATUS_ENDED:
+ self.wait_ended_transaction(get_transaction, status)
+
def test_wait(self, get_transaction):
res = self.client.get(self.wait)
eq_(res.status_code, 200)
View
8 webpay/pay/views.py
@@ -139,6 +139,11 @@ def wait_to_start(request):
trans = solitude.get_transaction(request.session['trans_id'])
except ValueError:
trans = {'status': None}
+
+ if trans['status'] in constants.STATUS_ENDED:
+ log.exception('Attempt to restart finished transaction.')
+ return _error(request, msg=_('Transaction has already ended.'))
+
if trans['status'] == constants.STATUS_PENDING:
# The transaction is ready; no need to wait for it.
return http.HttpResponseRedirect(
@@ -160,7 +165,4 @@ def trans_start_url(request):
data = {'url': None, 'status': trans['status']}
if trans['status'] == constants.STATUS_PENDING:
data['url'] = settings.BANGO_PAY_URL % trans['uid_pay']
- # TODO(Wraithan): We should catch if a user is trying to restart an expired
- # or completed transaction. (bug 829750).
- # This will timeout in the client until then.
return data
Please sign in to comment.
Something went wrong with that request. Please try again.