Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

all transactions to be looked up by uuid (bug 820198)

  • Loading branch information...
commit d4f4de58f7d7595245bdfa2853f9826a3178944f 1 parent 9fa9052
Andy McKay andymckay authored
15 lib/transactions/resources.py
... ... @@ -1,5 +1,7 @@
1 1 import uuid
2 2
  3 +from django.conf.urls.defaults import url
  4 +
3 5 from tastypie import fields
4 6
5 7 from lib.transactions.models import Transaction
@@ -19,8 +21,8 @@ class Meta(ModelResource.Meta):
19 21 fields = ['uuid', 'seller_product', 'amount', 'currency', 'provider',
20 22 'uid_pay', 'uid_support', 'type', 'status', 'related',
21 23 'notes']
22   - list_allowed_methods = ['get', 'post', 'patch']
23   - allowed_methods = ['get', 'put']
  24 + list_allowed_methods = ['get', 'post']
  25 + allowed_methods = ['get', 'patch']
24 26 resource_name = 'transaction'
25 27 filtering = {
26 28 'uuid': 'exact',
@@ -28,6 +30,15 @@ class Meta(ModelResource.Meta):
28 30 'provider': 'exact'
29 31 }
30 32
  33 + def override_urls(self):
  34 + return [
  35 + url(r"^(?P<resource_name>transaction)/(?P<uuid>.*)/$",
  36 + self.wrap_view('dispatch_detail'),
  37 + name="api_dispatch_detail"),
  38 + ]
  39 +
  40 + prepend_urls = override_urls
  41 +
31 42 def hydrate_uuid(self, bundle):
32 43 bundle.data.setdefault('uuid', str(uuid.uuid4()))
33 44 return bundle
18 lib/transactions/tests/test_api.py
... ... @@ -1,5 +1,7 @@
1 1 import json
2 2
  3 +from django.core.urlresolvers import reverse
  4 +
3 5 from nose.tools import eq_, ok_
4 6
5 7 from lib.sellers.tests.utils import make_seller_paypal
@@ -20,11 +22,14 @@ def setUp(self):
20 22 seller_product=self.product,
21 23 provider=constants.SOURCE_PAYPAL,
22 24 uuid=self.uuid)
23   - self.detail_url = self.get_detail_url('transaction', self.trans.pk)
  25 + self.detail_url = reverse('api_dispatch_detail',
  26 + kwargs={'api_name': self.api_name,
  27 + 'resource_name': 'transaction',
  28 + 'uuid': self.uuid})
24 29
25 30 def test_list_allowed(self):
26   - self.allowed_verbs(self.list_url, ['get', 'post', 'patch'])
27   - self.allowed_verbs(self.detail_url, ['get', 'put'])
  31 + self.allowed_verbs(self.list_url, ['get', 'post'])
  32 + self.allowed_verbs(self.detail_url, ['get', 'patch'])
28 33
29 34 def test_list(self):
30 35 res = self.client.get(self.list_url, data={'uuid': self.uuid})
@@ -48,3 +53,10 @@ def test_provider(self):
48 53 constants.SOURCE_BANGO})
49 54 eq_(res.status_code, 200)
50 55 eq_(json.loads(res.content)['meta']['total_count'], 0, res.content)
  56 +
  57 + def test_patch(self):
  58 + res = self.client.patch(self.detail_url,
  59 + data={'status': constants.STATUS_COMPLETED})
  60 + eq_(res.status_code, 202)
  61 + eq_(Transaction.objects.get(pk=self.trans.pk).status,
  62 + constants.STATUS_COMPLETED)

0 comments on commit d4f4de5

Please sign in to comment.
Something went wrong with that request. Please try again.