2 ''' |
2 ''' |
3 Created on Nov 11, 2012 |
3 Created on Nov 11, 2012 |
4 |
4 |
5 @author: ymh |
5 @author: ymh |
6 ''' |
6 ''' |
|
7 from django.conf import settings |
7 from django.shortcuts import render_to_response |
8 from django.shortcuts import render_to_response |
8 from django.template.context import RequestContext |
9 from django.template.context import RequestContext |
|
10 from django.http import HttpResponse |
|
11 from hp.models import VideoKCRel |
|
12 import logging |
9 import requests |
13 import requests |
10 from django.conf import settings |
|
11 import logging |
|
12 import urlparse |
14 import urlparse |
13 |
15 |
14 logger = logging.getLogger(__name__) |
16 logger = logging.getLogger(__name__) |
15 |
17 |
16 |
18 |
39 url_content = settings.LDT_API_URL + "contents/%s" % content_id |
41 url_content = settings.LDT_API_URL + "contents/%s" % content_id |
40 |
42 |
41 r_content = requests.get(url_content) |
43 r_content = requests.get(url_content) |
42 |
44 |
43 logger.debug(r_content.text) |
45 logger.debug(r_content.text) |
|
46 |
|
47 content = r_content.json |
|
48 project_url = content['front_project'] |
|
49 project_path = urlparse.urlparse(project_url).path |
|
50 project_id = "" |
|
51 if project_path: |
|
52 project_path_parts = project_path.split("/") |
|
53 project_id = project_path_parts[-1] if project_path_parts[-1] else project_path_parts[-2] |
|
54 |
|
55 kc_id = None |
|
56 topic_id = None |
|
57 |
|
58 kc_relation_list = list(VideoKCRel.objects.filter(iri_id=content_id)[:1]) |
|
59 |
|
60 if len(kc_relation_list) > 0: |
|
61 kc_id = kc_relation_list[0].graph_id |
|
62 topic_id = kc_relation_list[0].topic_id |
|
63 |
|
64 return render_to_response( |
|
65 'hp/video_player.html', |
|
66 {'content':content, 'project_id': project_id, 'kc_id': kc_id, 'topic_id': topic_id}, |
|
67 context_instance=RequestContext(request)) |
44 |
68 |
45 return render_to_response('hp/video_player.html',{'content':r_content.json}, context_instance=RequestContext(request)) |
69 |
|
70 def kc_proxy(request, path): |
|
71 |
|
72 url = settings.KC_URL + path |
|
73 |
|
74 data = request.POST if request.method=="POST" else {} |
|
75 |
|
76 r = requests.request(request.method, url, data=data) |
|
77 |
|
78 return HttpResponse(content=r.text, content_type='application/json;charset=UTF-8') |
|
79 |