0001-wcs-send-quoted-tracking-code-to-wcs-32646.patch
combo/apps/wcs/views.py | ||
---|---|---|
19 | 19 |
from django.contrib import messages |
20 | 20 |
from django.core.urlresolvers import reverse |
21 | 21 |
from django.http import JsonResponse, HttpResponseRedirect, HttpResponseBadRequest |
22 |
from django.utils.http import urlquote |
|
22 | 23 |
from django.utils.six.moves.urllib import parse as urlparse |
23 | 24 |
from django.utils.translation import ugettext_lazy as _ |
24 | 25 |
from django.views.decorators.csrf import csrf_exempt |
... | ... | |
47 | 48 |
wcs_sites = get_wcs_services().values() |
48 | 49 | |
49 | 50 |
for wcs_site in wcs_sites: |
50 |
response = requests.get('/api/code/' + code,
|
|
51 |
response = requests.get('/api/code/' + urlquote(code),
|
|
51 | 52 |
remote_service=wcs_site, log_errors=False) |
52 | 53 |
if response.status_code == 200 and response.json().get('err') == 0: |
53 | 54 |
return response.json().get('load_url') |
tests/test_wcs.py | ||
---|---|---|
622 | 622 |
resp = resp.follow() |
623 | 623 |
assert '<li class="error">The tracking code could not been found.</li>' in resp.text |
624 | 624 | |
625 |
resp = app.get('/') |
|
626 |
resp.form['code'] = 'FOO?BAR?bad<code>' |
|
627 |
resp = resp.form.submit() |
|
628 |
assert resp.status_code == 302 |
|
629 |
resp = resp.follow() |
|
630 |
assert '<li class="error">The tracking code could not been found.</li>' in resp.text |
|
631 | ||
625 | 632 |
resp = app.get('/') |
626 | 633 |
resp.form['code'] = 'CNPHNTFB' |
627 | 634 |
resp = resp.form.submit() |
628 |
- |