0001-portfolio-get-origin-from-publisher-25126.patch
tests/test_form_pages.py | ||
---|---|---|
3094 | 3094 |
http_post_request.return_value = None, 200, 'null', None |
3095 | 3095 |
resp = resp.form.submit('button_export_to') |
3096 | 3096 |
assert http_post_request.call_count == 1 |
3097 |
assert http_post_request.call_args[0][0].startswith('http://fargo.example.net/api/documents/push/') |
|
3098 |
payload = json.loads(http_post_request.call_args[0][1]) |
|
3099 |
assert payload['file_name'] == 'template.pdf' |
|
3100 |
assert payload['user_email'] == 'foo@localhost' |
|
3101 |
assert payload['origin'] == 'example.net' |
|
3102 |
assert payload['file_b64_content'].decode('base64').startswith('%PDF') |
|
3097 | 3103 |
assert ("file 'template.pdf' pushed to portfolio of 'Foo Bar\\xc3\\xa9'" |
3098 | 3104 |
== caplog.records[-1].message) |
3099 | 3105 |
assert resp.location == form_location |
wcs/portfolio.py | ||
---|---|---|
18 | 18 |
import urlparse |
19 | 19 |
import hashlib |
20 | 20 |
import urllib |
21 |
import urlparse |
|
21 | 22 |
import base64 |
22 | 23 | |
23 | 24 |
from qommon import get_logger |
... | ... | |
88 | 89 |
payload['user_nameid'] = unicode(user.name_identifiers[0], 'ascii') |
89 | 90 |
elif user.email: |
90 | 91 |
payload['user_email'] = unicode(user.email, 'ascii') |
91 |
payload['origin'] = get_request().get_server().split(':')[0]
|
|
92 |
payload['origin'] = urlparse.urlparse(get_publisher().get_frontoffice_url()).netloc
|
|
92 | 93 |
payload['file_name'] = unicode(filename, charset) |
93 | 94 |
stream.seek(0) |
94 | 95 |
payload['file_b64_content'] = base64.b64encode(stream.read()) |
95 |
- |