Merge lp:~stevanr/linaro-license-protection/add-textile-api into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Stevan Radaković
Status: Merged
Approved by: Stevan Radaković
Approved revision: 138
Merged at revision: 138
Proposed branch: lp:~stevanr/linaro-license-protection/add-textile-api
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 44 lines (+20/-0)
2 files modified
license_protected_downloads/views.py (+15/-0)
urls.py (+5/-0)
To merge this branch: bzr merge lp:~stevanr/linaro-license-protection/add-textile-api
Reviewer Review Type Date Requested Status
Georgy Redkozubov Approve
Review via email: mp+130809@code.launchpad.net

Description of the change

Add async call for fetching rendered textile files.

To post a comment you must log in.
Revision history for this message
Georgy Redkozubov (gesha) wrote :

I would suggest to add 'type' check for test_path returned value if it is file.
Otherwise approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'license_protected_downloads/views.py'
2--- license_protected_downloads/views.py 2012-10-15 11:14:42 +0000
3+++ license_protected_downloads/views.py 2012-10-22 12:50:35 +0000
4@@ -1,5 +1,6 @@
5 import glob
6 import hashlib
7+import json
8 import mimetypes
9 import os
10 import re
11@@ -452,3 +453,17 @@
12 # TODO: Is it possible to add a redirect to response so we can take
13 # the user back to the original directory this file is in?
14 return response
15+
16+def get_textile_files(request):
17+
18+ if request.is_ajax():
19+ result = test_path(request.GET.get("path"))
20+ if not result:
21+ raise Http404
22+
23+ type = result[0]
24+ path = result[1]
25+
26+ return HttpResponse(json.dumps(RenderTextFiles.find_and_render(path)))
27+ else:
28+ raise NotImplementedError
29
30=== modified file 'urls.py'
31--- urls.py 2012-10-10 14:52:13 +0000
32+++ urls.py 2012-10-22 12:50:35 +0000
33@@ -37,6 +37,11 @@
34 'license_protected_downloads.views.accept_license',
35 name='accept_license'),
36
37+ # Recursively get files for rendering (async calls accepted only).
38+ url(r'^get-textile-files',
39+ 'license_protected_downloads.views.get_textile_files',
40+ name='get_textile_files'),
41+
42 # Catch-all. We always return a file (or try to) if it exists.
43 # This handler does that.
44 url(r'(?P<path>.*)', 'license_protected_downloads.views.file_server'),

Subscribers

People subscribed via source and target branches