43 def project_json(request, project, serialize_contents=True, first_cutting=None): |
43 def project_json(request, project, serialize_contents=True, first_cutting=None): |
44 |
44 |
45 if not ldt_auth.check_access(request.user, project): |
45 if not ldt_auth.check_access(request.user, project): |
46 return HttpResponseForbidden(_("You can not access this project")) |
46 return HttpResponseForbidden(_("You can not access this project")) |
47 |
47 |
48 mimetype = request.REQUEST.get("mimetype") |
48 content_type = request.REQUEST.get("content_type") |
49 if mimetype is None: |
49 if content_type is None: |
50 mimetype = "application/json; charset=utf-8" |
50 content_type = "application/json; charset=utf-8" |
51 else: |
51 else: |
52 mimetype = mimetype.encode("utf-8") |
52 content_type = content_type.encode("utf-8") |
53 if "charset" not in mimetype: |
53 if "charset" not in content_type: |
54 mimetype += "; charset=utf-8" |
54 content_type += "; charset=utf-8" |
55 resp = HttpResponse(mimetype=mimetype) |
55 resp = HttpResponse(content_type=content_type) |
56 resp['Cache-Control'] = 'no-cache, must-revalidate' |
56 resp['Cache-Control'] = 'no-cache, must-revalidate' |
57 resp['Pragma'] = 'no-cache' |
57 resp['Pragma'] = 'no-cache' |
58 |
58 |
59 indent = request.REQUEST.get("indent") |
59 indent = request.REQUEST.get("indent") |
60 if indent is None: |
60 if indent is None: |
121 project = Project() |
121 project = Project() |
122 project.ldt = lxml.etree.tostring(project_xml, pretty_print=True) |
122 project.ldt = lxml.etree.tostring(project_xml, pretty_print=True) |
123 # Needed datas for jsonification |
123 # Needed datas for jsonification |
124 now = datetime.now() |
124 now = datetime.now() |
125 project.modification_date = project.creation_date = now |
125 project.modification_date = project.creation_date = now |
126 #return HttpResponse(lxml.etree.tostring(project_xml, pretty_print=True), mimetype="text/xml;charset=utf-8") |
126 #return HttpResponse(lxml.etree.tostring(project_xml, pretty_print=True), content_type="text/xml;charset=utf-8") |
127 logger.debug("mashup_by_tag : serialize_to_cinelab prepare") |
127 logger.debug("mashup_by_tag : serialize_to_cinelab prepare") |
128 |
128 |
129 ps = ProjectJsonSerializer(project, from_contents=False) |
129 ps = ProjectJsonSerializer(project, from_contents=False) |
130 logger.debug("mashup_by_tag : serialize_to_cinelab serializer ready") |
130 logger.debug("mashup_by_tag : serialize_to_cinelab serializer ready") |
131 mashup_dict = ps.serialize_to_cinelab() |
131 mashup_dict = ps.serialize_to_cinelab() |
219 # Callback to allo jsonp |
219 # Callback to allo jsonp |
220 callback = request.REQUEST.get("callback") |
220 callback = request.REQUEST.get("callback") |
221 if callback is not None: |
221 if callback is not None: |
222 json_str = "%s(%s)" % (callback, json_str) |
222 json_str = "%s(%s)" % (callback, json_str) |
223 |
223 |
224 resp = HttpResponse(mimetype="application/json; charset=utf-8") |
224 resp = HttpResponse(content_type="application/json; charset=utf-8") |
225 resp.write(json_str) |
225 resp.write(json_str) |
226 |
226 |
227 return resp |
227 return resp |