# HG changeset patch # User verrierj # Date 1326904570 -3600 # Node ID 38e46b1d0bd318b16636a59c3032bc4dca37d48b # Parent b512f69a474a85661fe0c947336c7da741c6318b Small bugfixes diff -r b512f69a474a -r 38e46b1d0bd3 src/ldt/ldt/api/ldt/handlers.py --- a/src/ldt/ldt/api/ldt/handlers.py Wed Jan 18 16:31:01 2012 +0100 +++ b/src/ldt/ldt/api/ldt/handlers.py Wed Jan 18 17:36:10 2012 +0100 @@ -245,6 +245,6 @@ Q(start_ts__lt=begin, start_ts__gt=end-F('duration')) # period [begin:end] is included in the segment ) - a = SegmentSerializer(content, segments, viewable_contents=[content.iri_id]) + a = SegmentSerializer(content, segments, viewable_contents=[content]) return a.serialize_to_cinelab() diff -r b512f69a474a -r 38e46b1d0bd3 src/ldt/ldt/ldt_utils/projectserializer.py --- a/src/ldt/ldt/ldt_utils/projectserializer.py Wed Jan 18 16:31:01 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/projectserializer.py Wed Jan 18 17:36:10 2012 +0100 @@ -17,6 +17,10 @@ class ProjectSerializer: def __init__(self, project, from_contents=True, from_display=True, first_cutting=None, viewable_contents=[], only_one_cutting=False): + """ + viewable_contents should contain all contents from project that a user is allowed to see. The settings.FORBIDDDEN_STREAM_URL + will be displayed if a content is not found in viewable_contents, and the real stream will be displayed if it is. + """ self.project = project self.parsed = False self.ldt_doc = None @@ -350,7 +354,7 @@ href = "" meta_item_value = "" - if content.iri_id not in self.viewable_contents: + if content not in self.viewable_contents: href = settings.FORBIDDEN_STREAM_URL elif content.videopath: href = content.videopath.rstrip('/') + "/" + content.src @@ -383,6 +387,16 @@ self.medias_dict[content.iri_id] = new_media + new_display = { + "id": "stat", + "contents": [content.iri_id], + "meta": { + "stat": content.stat_annotation, + } + } + + self.views_dict['test'] = new_display + if self.serialize_contents: res = doc.xpath("/iri/body/ensembles/ensemble") for ensemble_node in res: diff -r b512f69a474a -r 38e46b1d0bd3 src/ldt/ldt/ldt_utils/segmentserializer.py --- a/src/ldt/ldt/ldt_utils/segmentserializer.py Wed Jan 18 16:31:01 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/segmentserializer.py Wed Jan 18 17:36:10 2012 +0100 @@ -6,13 +6,16 @@ DATE_FORMATS = ["%d/%m/%Y", "%Y-%m-%d"] -import pdb class SegmentSerializer(object): """ Serialize a set of annotations to a cinelab compatible array """ def __init__(self, content, segments, viewable_contents=[], default_color=2194379): + """ + viewable_contents should contain all contents from project that a user is allowed to see. The settings.FORBIDDDEN_STREAM_URL + will be displayed if a content is not found in viewable_contents, and the real stream will be displayed if it is. + """ self.content = content self.segments = segments self.viewable_contents = viewable_contents @@ -20,8 +23,7 @@ self.views = None self.annotation_types = None self.medias = None - self.annotations = None - + self.annotations = None self.xml_docs = {} def __get_cutting_title(self, project_id, content_id, ensemble_id, cutting_id): @@ -74,7 +76,8 @@ href = "" meta_item_value = "" - if self.content.iri_id not in self.viewable_contents: + + if self.content not in self.viewable_contents: href = settings.FORBIDDEN_STREAM_URL elif self.content.videopath: href = self.content.videopath.rstrip('/') + "/" + self.content.src diff -r b512f69a474a -r 38e46b1d0bd3 src/ldt/ldt/ldt_utils/stat.py --- a/src/ldt/ldt/ldt_utils/stat.py Wed Jan 18 16:31:01 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/stat.py Wed Jan 18 17:36:10 2012 +0100 @@ -6,7 +6,7 @@ def update_stat_project(project, contents=None, doc=None, update_contents=[]): - + if not contents: contents = project.contents.all() @@ -15,24 +15,24 @@ number_division = settings.DIVISIONS_FOR_STAT_ANNOTATION contributions = list(AnnotationStat.objects.filter(project=project)) - + for content_node in doc.xpath('/iri/annotations/content'): content_name = content_node.get('id') content = filter_list(contents, 'iri_id', content_name) - + print content_name # if the content referenced in the xml belongs to the # fields contents of the project if len(content) != 0: content = content[0] - contribution_to_content = contributions.get(content=content) + contribution_to_content = filter_list(contributions, 'content', content)[0] size_division = content.duration / number_division limits = [x * size_division for x in range(number_division+1)] buckets = [0] * number_division nb_annotation = 0 + for ann in content_node.xpath('ensemble/decoupage/elements/element'): - begin = int(ann.get('begin')) end = int(ann.get('dur')) + begin diff -r b512f69a474a -r 38e46b1d0bd3 src/ldt/ldt/ldt_utils/templates/front/front_search_results.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Wed Jan 18 16:31:01 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Wed Jan 18 17:36:10 2012 +0100 @@ -124,7 +124,7 @@
{{res.content.duration|str_duration:"::"}}
diff -r b512f69a474a -r 38e46b1d0bd3 src/ldt/ldt/ldt_utils/views/json.py --- a/src/ldt/ldt/ldt_utils/views/json.py Wed Jan 18 16:31:01 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/views/json.py Wed Jan 18 17:36:10 2012 +0100 @@ -61,7 +61,6 @@ escape_bool = {'true': True, 'false': False, "0": False, "1": True}.get(escape_str.lower()) viewable_contents = get_objects_for_user(request.user, 'ldt_utils.view_content', klass=project.contents.all()) - viewable_contents = [c.iri_id for c in viewable_contents] ps = ProjectSerializer(project, serialize_contents, viewable_contents=viewable_contents, first_cutting=first_cutting) project_dict = ps.serialize_to_cinelab()