src/hp/views.py
changeset 65 6289931858a7
parent 62 0cdd0bb4141c
child 72 b31ba28871ca
equal deleted inserted replaced
64:78f174d908a0 65:6289931858a7
    53     r_content = requests.get(url_content)
    53     r_content = requests.get(url_content)
    54         
    54         
    55     logger.debug(r_content.text)
    55     logger.debug(r_content.text)
    56     
    56     
    57     content = r_content.json
    57     content = r_content.json
    58     project_url = content['front_project']
       
    59     project_path = urlparse.urlparse(project_url).path
       
    60     project_id = ""
       
    61     if project_path:
       
    62         project_path_parts = project_path.split("/")
       
    63         project_id = project_path_parts[-1] if project_path_parts[-1] else project_path_parts[-2]
       
    64         
    58         
    65     kc_id = None
    59     kc_id = None
    66     topic_id = None
    60     topic_id = None
    67     
    61     
    68     kc_relation_list = list(VideoKCRel.objects.filter(iri_id=content_id)[:1])
    62     kc_relation_list = list(VideoKCRel.objects.filter(iri_id=content_id)[:1])
    69     
    63     
    70     if len(kc_relation_list) > 0:
    64     if len(kc_relation_list) > 0:
    71         kc_id = kc_relation_list[0].graph_id
    65         kc_id = kc_relation_list[0].graph_id
    72         topic_id = kc_relation_list[0].topic_id
    66         topic_id = kc_relation_list[0].topic_id
       
    67         project_id = kc_relation_list[0].project_id
       
    68 
       
    69     if not project_id:
       
    70         project_url = content['front_project']
       
    71         project_path = urlparse.urlparse(project_url).path    
       
    72         project_id = ""
       
    73         if project_path:
       
    74             project_path_parts = project_path.split("/")
       
    75             project_id = project_path_parts[-1] if project_path_parts[-1] else project_path_parts[-2]
    73     
    76     
    74     return render_to_response(
    77     return render_to_response(
    75         'hp/video_player.html',
    78         'hp/video_player.html',
    76         {'content':content, 'project_id': project_id, 'kc_id': kc_id, 'topic_id': topic_id},
    79         {'content':content, 'project_id': project_id, 'kc_id': kc_id, 'topic_id': topic_id},
    77         context_instance=RequestContext(request))
    80         context_instance=RequestContext(request))