src/ldt/ldt/ldt_utils/views/workspace.py
changeset 931 cc5442349bdd
parent 915 5d08847528dd
parent 930 e107b2225680
child 937 16cc07633339
equal deleted inserted replaced
925:fd2d4a7a5de6 931:cc5442349bdd
    21 from itertools import groupby
    21 from itertools import groupby
    22 import base64
    22 import base64
    23 import django.core.urlresolvers
    23 import django.core.urlresolvers
    24 import ldt.auth as ldt_auth
    24 import ldt.auth as ldt_auth
    25 from django.utils.safestring import mark_safe
    25 from django.utils.safestring import mark_safe
    26 import logging
       
    27 
    26 
    28 
    27 
    29 
    28 
    30 @login_required
    29 @login_required
    31 def home(request):
    30 def home(request):
    97     
    96     
    98     rend_dict = get_datas_for_embed(request, json_url, player_id, ldt_id)
    97     rend_dict = get_datas_for_embed(request, json_url, player_id, ldt_id)
    99     
    98     
   100     embed_rendered = dict((typestr,
    99     embed_rendered = dict((typestr,
   101                            (lambda s:escape(render_to_string("ldt/ldt_utils/partial/embed_%s.html" % (s), rend_dict, context_instance=RequestContext(request))))(typestr))
   100                            (lambda s:escape(render_to_string("ldt/ldt_utils/partial/embed_%s.html" % (s), rend_dict, context_instance=RequestContext(request))))(typestr))
   102                            for typestr in ('player', 'seo_body', 'seo_meta', 'links'))
   101                            for typestr in ('seo_body', 'seo_meta', 'links'))
   103 
   102 
   104     rend_dict['embed_rendered'] = embed_rendered
   103     rend_dict['embed_rendered'] = embed_rendered
       
   104 
   105     return render_to_response("ldt/ldt_utils/embed_popup.html", rend_dict, context_instance=RequestContext(request))
   105     return render_to_response("ldt/ldt_utils/embed_popup.html", rend_dict, context_instance=RequestContext(request))
   106 
   106 
   107 
   107 
   108 def iframe_embed(request):
   108 def iframe_embed(request):
   109 
   109 
   123     player_id = "player_project_" + project_id
   123     player_id = "player_project_" + project_id
   124     ldt_id = project_id
   124     ldt_id = project_id
   125     rend_dict = get_datas_for_embed(request, json_url, player_id, ldt_id)
   125     rend_dict = get_datas_for_embed(request, json_url, player_id, ldt_id)
   126     
   126     
   127     # Manage iframe options
   127     # Manage iframe options
       
   128     rend_dict["player_height"]=request.GET.get("player_height")
       
   129     rend_dict["player_width"]=request.GET.get("player_width")
   128     if request.GET.has_key("polemic"):
   130     if request.GET.has_key("polemic"):
   129         rend_dict["polemic"] = request.GET.get("polemic")
   131         rend_dict["polemic"] = request.GET.get("polemic")
       
   132         rend_dict["polemic_defaultColor"] = request.GET.get("polemic_defaultColor")
       
   133         rend_dict["polemic_foundColor"] = request.GET.get("polemic_foundColor")
       
   134         rend_dict["polemic_okColor"] = request.GET.get("polemic_okColor")
       
   135         rend_dict["polemic_koColor"] = request.GET.get("polemic_koColor")
       
   136         rend_dict["polemic_refColor"] = request.GET.get("polemic_refColor")
       
   137         rend_dict["polemic_qColor"] = request.GET.get("polemic_qColor")
       
   138 
   130     if request.GET.has_key("show_mic_record"):
   139     if request.GET.has_key("show_mic_record"):
   131         rend_dict["show_mic_record"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("show_mic_record").lower())
   140         rend_dict["show_mic_record"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("show_mic_record").lower())
   132     if request.GET.has_key("annotations_list"):
   141     if request.GET.has_key("annotations_list"):
   133         rend_dict["annotations_list"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("annotations_list").lower())
   142         rend_dict["annotations_list"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("annotations_list").lower())
   134         rend_dict["player_width"] = 550
   143         rend_dict["player_width"] = 550
   135     
   144     if request.GET.has_key("createannotation"):
   136     rend_dict["annotation_block"]= True
   145         rend_dict["createannotation"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("createannotation").lower())
   137     
   146     if request.GET.has_key("tag_titles"):
   138 
   147        rend_dict["tag_titles"] = request.GET.get("tag_titles") 
       
   148     if request.GET.has_key("sparkline"):
       
   149         rend_dict["sparkline"] = request.GET.get("sparkline")
       
   150         rend_dict["sparkline_lineColor"] = request.GET.get("sparkline_lineColor")
       
   151         rend_dict["sparkline_fillColor"] = request.GET.get("sparkline_fillColor")
       
   152     if request.GET.has_key("slideshare"):
       
   153         rend_dict["slideshare"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("slideshare").lower())
       
   154     if request.GET.has_key("social"):
       
   155         rend_dict["social"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("social").lower())     
       
   156         if request.GET.has_key("show_url"):
       
   157             rend_dict["show_url"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("show_url").lower())     
       
   158         if request.GET.has_key("show_twitter"):
       
   159             rend_dict["show_twitter"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("show_twitter").lower())     
       
   160         if request.GET.has_key("show_fb"):
       
   161             rend_dict["show_fb"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("show_fb").lower())     
       
   162         if request.GET.has_key("show_gplus"):
       
   163             rend_dict["show_gplus"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("show_gplus").lower())     
       
   164         if request.GET.has_key("show_mail"):
       
   165             rend_dict["show_mail"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("show_mail").lower())     
       
   166     if request.GET.has_key("annotation"):
       
   167         rend_dict["annotation"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("annotation").lower())
       
   168     if request.GET.has_key("tweet"):
       
   169         rend_dict["tweet"] ={'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("tweet").lower())
       
   170     if request.GET.has_key("segments"):
       
   171         rend_dict["segments"] = request.GET.get("segments")
       
   172     if request.GET.has_key("tagcloud"):
       
   173         rend_dict["tagcloud"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("tagcloud").lower())
   139     return render_to_response("ldt/ldt_utils/embed_iframe.html", rend_dict, context_instance=RequestContext(request))
   174     return render_to_response("ldt/ldt_utils/embed_iframe.html", rend_dict, context_instance=RequestContext(request))
   140 
   175 
   141 
   176 
   142 def get_datas_for_embed(request, json_url, player_id, ldt_id):
   177 def get_datas_for_embed(request, json_url, player_id, ldt_id):
   143     
   178     
   153                 break
   188                 break
   154     
   189     
   155     stream_mode = project.stream_mode
   190     stream_mode = project.stream_mode
   156     if stream_mode != "video":
   191     if stream_mode != "video":
   157         stream_mode = 'radio'
   192         stream_mode = 'radio'
   158 
       
   159     player_width = 550
       
   160     player_height = 380
       
   161     
   193     
   162     if stream_mode == 'radio':
   194     if stream_mode == 'radio':
   163         player_height = 1
   195         player_height = 1
   164         
   196         
   165     if not ldt_auth.check_access(request.user, project):
   197     if not ldt_auth.check_access(request.user, project):
   166         return HttpResponseForbidden(_("You can not access this project"))
   198         return HttpResponseForbidden(_("You can not access this project"))
   167 
   199     WEB_URL=settings.WEB_URL
       
   200     LDT_MEDIA_PREFIX=settings.LDT_MEDIA_PREFIX
       
   201     LANGUAGE_CODE=settings.LANGUAGE_CODE
   168     ps = ProjectJsonSerializer(project, from_contents=True, from_display=True)
   202     ps = ProjectJsonSerializer(project, from_contents=True, from_display=True)
   169     annotations = ps.get_annotations(first_cutting=True)
   203     annotations = ps.get_annotations(first_cutting=True)
   170     rend_dict = {'json_url':json_url, 'player_id':player_id, 'annotations':annotations, 'ldt_id': ldt_id, 'stream_mode': stream_mode, 
   204     rend_dict = {'json_url':json_url, 'player_id':player_id, 'annotations':annotations, 'ldt_id': ldt_id, 'stream_mode': stream_mode, 
   171                  'player_width': player_width, 'player_height': player_height, 'external_url': external_url,
   205                 'external_url': external_url,
   172                  'polemic':False, 'show_mic_record':False, 'annotations_list':False, 'iframe_url':iframe_url}
   206                  'polemic':False, 'show_mic_record':False, 'annotations_list':False, 'iframe_url':iframe_url, 'WEB_URL':WEB_URL,
       
   207                   'LDT_MEDIA_PREFIX':LDT_MEDIA_PREFIX, 'LANGUAGE_CODE':LANGUAGE_CODE}
   173     
   208     
   174     return rend_dict
   209     return rend_dict
   175 
   210 
   176 
   211 
   177 
   212