diff -r 342f180b09ec -r b6010b3d6ea8 src/hp/views.py --- a/src/hp/views.py Tue Nov 13 16:37:47 2012 +0100 +++ b/src/hp/views.py Wed Nov 14 16:29:01 2012 +0100 @@ -4,11 +4,13 @@ @author: ymh ''' +from django.conf import settings from django.shortcuts import render_to_response from django.template.context import RequestContext +from django.http import HttpResponse +from hp.models import VideoKCRel +import logging import requests -from django.conf import settings -import logging import urlparse logger = logging.getLogger(__name__) @@ -41,5 +43,37 @@ r_content = requests.get(url_content) logger.debug(r_content.text) + + content = r_content.json + project_url = content['front_project'] + project_path = urlparse.urlparse(project_url).path + project_id = "" + if project_path: + project_path_parts = project_path.split("/") + project_id = project_path_parts[-1] if project_path_parts[-1] else project_path_parts[-2] + + kc_id = None + topic_id = None + + kc_relation_list = list(VideoKCRel.objects.filter(iri_id=content_id)[:1]) + + if len(kc_relation_list) > 0: + kc_id = kc_relation_list[0].graph_id + topic_id = kc_relation_list[0].topic_id + + return render_to_response( + 'hp/video_player.html', + {'content':content, 'project_id': project_id, 'kc_id': kc_id, 'topic_id': topic_id}, + context_instance=RequestContext(request)) - return render_to_response('hp/video_player.html',{'content':r_content.json}, context_instance=RequestContext(request)) \ No newline at end of file + +def kc_proxy(request, path): + + url = settings.KC_URL + path + + data = request.POST if request.method=="POST" else {} + + r = requests.request(request.method, url, data=data) + + return HttpResponse(content=r.text, content_type='application/json;charset=UTF-8') + \ No newline at end of file