# HG changeset patch # User ymh # Date 1432720447 -7200 # Node ID 5fa85499f70347bb608270ba14fec5a62fd5146d # Parent a61088cd80a6cd7f7265a78fa5d13f527d2bef4a revert wrong content-type changes diff -r a61088cd80a6 -r 5fa85499f703 src/ldt/ldt/__init__.py --- a/src/ldt/ldt/__init__.py Fri May 15 16:10:52 2015 +0200 +++ b/src/ldt/ldt/__init__.py Wed May 27 11:54:07 2015 +0200 @@ -1,6 +1,6 @@ __all__ = ["VERSION", "get_version", "__version__"] -VERSION = (1, 56, 02, "final", 0) +VERSION = (1, 56, 03, "final", 0) def get_version(): diff -r a61088cd80a6 -r 5fa85499f703 src/ldt/ldt/api/ldt/serializers/cinelabserializer.py --- a/src/ldt/ldt/api/ldt/serializers/cinelabserializer.py Fri May 15 16:10:52 2015 +0200 +++ b/src/ldt/ldt/api/ldt/serializers/cinelabserializer.py Wed May 27 11:54:07 2015 +0200 @@ -200,11 +200,11 @@ # New for metadatacomposer : we add meta informations about extra of different kinds : # related video, audio, links and html code which are not the native annotation datas # like title, description, etc. - if "content_type" in a["content"]: + if "mimetype" in a["content"]: # Video or audio bonus - if a["content"]["content_type"]=="application/x-ldt-video" or a["content"]["content_type"]=="application/x-ldt-audio": + if a["content"]["mimetype"]=="application/x-ldt-video" or a["content"]["mimetype"]=="application/x-ldt-audio": typeNode = lxml.etree.SubElement(metaNode, 'type') - if a["content"]["content_type"]=="application/x-ldt-video": + if a["content"]["mimetype"]=="application/x-ldt-video": typeNode.text = "video" else: typeNode.text = "audio" @@ -213,7 +213,7 @@ embedcodeNode = lxml.etree.SubElement(metaNode, 'embedcode') embedcodeNode.text = lxml.etree.CDATA(a["content"]["embedcode"]) # Text bonus - elif a["content"]["content_type"]=="application/x-ldt-text": + elif a["content"]["mimetype"]=="application/x-ldt-text": typeNode = lxml.etree.SubElement(metaNode, 'type') typeNode.text = "text" markupNode = lxml.etree.SubElement(metaNode, 'markup') @@ -221,7 +221,7 @@ textNode = lxml.etree.SubElement(metaNode, 'text') textNode.text = lxml.etree.CDATA(a["content"]["text"]) # Links bonus - elif a["content"]["content_type"]=="application/x-ldt-links": + elif a["content"]["mimetype"]=="application/x-ldt-links": typeNode = lxml.etree.SubElement(metaNode, 'type') typeNode.text = "links" linksNode = lxml.etree.SubElement(metaNode, 'links') @@ -232,7 +232,7 @@ titleNode = lxml.etree.SubElement(linkNode, 'title') titleNode.text = link["title"] # Image slideshow bonus - elif a["content"]["content_type"]=="application/x-ldt-slideshow": + elif a["content"]["mimetype"]=="application/x-ldt-slideshow": typeNode = lxml.etree.SubElement(metaNode, 'type') typeNode.text = "slideshow" durationNode = lxml.etree.SubElement(metaNode, 'slideduration') @@ -427,16 +427,16 @@ error_string += " Each annotation must have 'content/title' and 'content/description' fields." do_break = True # Test for metadatacomposer extra datas, type video, audio, text, links or slideshow - if "content_type" in a["content"]: - if a["content"]["content_type"]=="application/x-ldt-video" or a["content"]["content_type"]=="application/x-ldt-audio": + if "mimetype" in a["content"]: + if a["content"]["mimetype"]=="application/x-ldt-video" or a["content"]["mimetype"]=="application/x-ldt-audio": if not "url" in a["content"] or not "embedcode" in a["content"]: error_string += " A video or audio annotation must have 'content/url' and 'content/embedcode' fields." do_break = True - elif a["content"]["content_type"]=="application/x-ldt-text": + elif a["content"]["mimetype"]=="application/x-ldt-text": if not "markup" in a["content"] or not "text" in a["content"]: error_string += " A text annotation must have 'content/markup' and 'content/text' fields." do_break = True - elif a["content"]["content_type"]=="application/x-ldt-links": + elif a["content"]["mimetype"]=="application/x-ldt-links": if not "links" in a["content"]: error_string += " A links annotation must have 'content/links' field." do_break = True @@ -445,7 +445,7 @@ if not "url" in l or not "title" in l: error_string += " Each link in links annotation must have 'url' and 'title' fields." do_break = True - elif a["content"]["content_type"]=="application/x-ldt-slideshow": + elif a["content"]["mimetype"]=="application/x-ldt-slideshow": if not "slideduration" in a["content"] or not "autostart" in a["content"] or not "images" in a["content"]: error_string += " A slideshow annotation must have 'content/slideduration' and 'content/autostart' and 'content/images' fields." do_break = True diff -r a61088cd80a6 -r 5fa85499f703 src/ldt/ldt/ldt_utils/projectserializer.py --- a/src/ldt/ldt/ldt_utils/projectserializer.py Fri May 15 16:10:52 2015 +0200 +++ b/src/ldt/ldt/ldt_utils/projectserializer.py Wed May 27 11:54:07 2015 +0200 @@ -198,7 +198,7 @@ if len(element_source_node_list) > 0: element_source_node = element_source_node_list[0] - element_source = {"content_type" :element_source_node.get(u'content_type'), "url":element_source_node.get(u'url'), "content":reduce_text_node(element_source_node)} + element_source = {"mimetype" :element_source_node.get(u'mimetype'), "url":element_source_node.get(u'url'), "content":reduce_text_node(element_source_node)} else: element_source = None @@ -265,7 +265,7 @@ "media": element_media, "color": element_color, "content": { - "content_type": "application/x-ldt-structured", + "mimetype": "application/x-ldt-structured", "title": element_title, "description": element_description, #"color": element_color, @@ -274,7 +274,7 @@ }, "audio": { "src" : element_audio_src, - "content_type": "audio/mp3", + "mimetype": "audio/mp3", "href": element_audio_href }, "polemics" :[pol_elem.text for pol_elem in element_node.xpath("meta/polemics/polemic")], @@ -298,27 +298,27 @@ meta_type_node = element_node.xpath("meta/type") if len(meta_type_node) > 0: meta_type = reduce_text_node(meta_type_node[0], "text()") - # Update content_type and add datas + # Update mimetype and add datas if meta_type=="video": - new_annotation["content"]["content_type"] = "application/x-ldt-video" + new_annotation["content"]["mimetype"] = "application/x-ldt-video" new_annotation["content"]["url"] = reduce_text_node(element_node, "meta/url/text()") new_annotation["content"]["embedcode"] = reduce_text_node(element_node, "meta/embedcode/text()") elif meta_type=="audio": - new_annotation["content"]["content_type"] = "application/x-ldt-audio" + new_annotation["content"]["mimetype"] = "application/x-ldt-audio" new_annotation["content"]["url"] = reduce_text_node(element_node, "meta/url/text()") new_annotation["content"]["embedcode"] = reduce_text_node(element_node, "meta/embedcode/text()") elif meta_type=="text": - new_annotation["content"]["content_type"] = "application/x-ldt-text" + new_annotation["content"]["mimetype"] = "application/x-ldt-text" new_annotation["content"]["markup"] = reduce_text_node(element_node, "meta/markup/text()") new_annotation["content"]["text"] = reduce_text_node(element_node, "meta/text/text()") elif meta_type=="links": - new_annotation["content"]["content_type"] = "application/x-ldt-links" + new_annotation["content"]["mimetype"] = "application/x-ldt-links" new_annotation["content"]["links"] = [] link_nodes = element_node.xpath("meta/links/link") for link in link_nodes: new_annotation["content"]["links"].append({"url": reduce_text_node(link, "url/text()"), "title":reduce_text_node(link, "title/text()")}) elif meta_type=="slideshow": - new_annotation["content"]["content_type"] = "application/x-ldt-slideshow" + new_annotation["content"]["mimetype"] = "application/x-ldt-slideshow" new_annotation["content"]["slideduration"] = reduce_text_node(element_node, "meta/slideduration/text()") new_annotation["content"]["autostart"] = {'true': True, 'false': False, "0": False, "1": True}.get(reduce_text_node(element_node, "meta/autostart/text()").lower()) new_annotation["content"]["images"] = [] diff -r a61088cd80a6 -r 5fa85499f703 src/ldt/ldt/ldt_utils/segmentserializer.py --- a/src/ldt/ldt/ldt_utils/segmentserializer.py Fri May 15 16:10:52 2015 +0200 +++ b/src/ldt/ldt/ldt_utils/segmentserializer.py Wed May 27 11:54:07 2015 +0200 @@ -1,9 +1,11 @@ -from django.conf import settings from ldt.ldt_utils.stat import get_string_from_buckets from ldt.security.utils import use_forbidden_url import logging +import uuid + +from django.conf import settings import lxml.etree -import uuid + logger = logging.getLogger(__name__) @@ -47,7 +49,7 @@ cutting = cutting[0] - return cutting.text + return cutting.text def __parse_views(self): @@ -71,13 +73,12 @@ self.annotation_types = [] - annotation_types = [] + annotation_types = [] for seg in self.segments: title = self.__get_cutting_title(seg.project_id, seg.iri_id, seg.ensemble_id, seg.cutting_id, seg.project_obj) annotation_types.append({'id': seg.cutting_id, 'title': title}) for a in annotation_types: - view['annotation_types'].append(a['id']) self.annotation_types.append({ "dc:contributor": "undefined", @@ -161,7 +162,7 @@ 'color': "%s" % self.default_color, 'media': self.content.iri_id, 'content': { - 'content_type': 'application/x-ldt-structured', + 'mimetype': 'application/x-ldt-structured', 'description': seg.abstract, 'img': { 'src': '' @@ -170,7 +171,7 @@ 'color': self.default_color, 'polemics': [ ], 'audio': { - 'content_type': 'audio/mp3', + 'mimetype': 'audio/mp3', 'src': seg.audio_src, 'href': seg.audio_href }