# HG changeset patch # User hamidouk # Date 1327397144 -3600 # Node ID b068bc945c2df0054afac69c42ee83017fe3aac9 # Parent 5e7ec99d4f1e588da3952351e4c45df20ca52ddc# Parent 8c33427e558b2ff3b9dd090117692efb523c9c6f Merge with upstream. diff -r 5e7ec99d4f1e -r b068bc945c2d crea/.DS_Store Binary file crea/.DS_Store has changed diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/api/ldt/handlers.py --- a/src/ldt/ldt/api/ldt/handlers.py Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/api/ldt/handlers.py Tue Jan 24 10:25:44 2012 +0100 @@ -4,7 +4,7 @@ from piston.utils import rc, require_extended from ldt.ldt_utils.utils import LdtAnnotation from ldt.ldt_utils.stat import add_annotation_to_stat -from ldt.security.utils import protect_instance, unprotect_instance +from ldt.security import protect_models, unprotect_models from ldt.ldt_utils.segmentserializer import SegmentSerializer import logging #@UnresolvedImport @@ -157,7 +157,8 @@ adder = LdtAnnotation(project) logging.debug("request json " + repr(request.data)) - unprotect_instance(project) # allows anonymous user to save project + + unprotect_models() # Allows anonymous user to modify models in this request only meta = request.data['meta'] author = meta['creator'] @@ -169,14 +170,12 @@ begin = str(a['begin']) type_id, new_id = adder.add(a['media'], a['type'], a['type_title'], a['content']['data'], '', a['tags'], begin, dur, author, date) if not new_id: - protect_instance(project) + protect_models() return rc.BAD_REQUEST content = project.contents.get(iri_id=a['media']) - unprotect_instance(content) add_annotation_to_stat(content, project, a['begin'], a['end']) - protect_instance(content) # We update the ids a['type'] = type_id @@ -186,7 +185,7 @@ if len(new_annotations)>0 : adder.save() - protect_instance(project) + protect_models() return request.data @@ -204,9 +203,9 @@ project.ldt = ldt_str - unprotect_instance(project) + unprotect_models() project.save() - protect_instance(project) + protect_models() return rc.ALL_OK @@ -235,12 +234,12 @@ def read(self, request, iri_id, begin, end): """ - returns a single Segment + returns segments about content iri_id between timecodes begin and end """ content = Content.objects.get(iri_id=iri_id) segments = Segment.objects.filter(content=content).filter( - Q(start_ts__gt=begin, start_ts__lt=end) | # segment start between begin and end + Q(start_ts__gt=begin, start_ts__lt=end) | # segment starts between begin and end Q(start_ts__gt=begin-F('duration'), start_ts__lt=end-F('duration')) |# segment ends between begin and end Q(start_ts__lt=begin, start_ts__gt=end-F('duration')) # period [begin:end] is included in the segment ) diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/ldt_utils/models.py --- a/src/ldt/ldt/ldt_utils/models.py Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/models.py Tue Jan 24 10:25:44 2012 +0100 @@ -219,7 +219,7 @@ if not self.nb_annotation: self.nb_annotation = 0 if not self.stat_annotation: - self.stat_annotation = '0,0' + self.stat_annotation = ('0,' * settings.DIVISIONS_FOR_STAT_ANNOTATION)[:-1] super(Content, self).save(*args, **kwargs) diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/ldt_utils/projectserializer.py --- a/src/ldt/ldt/ldt_utils/projectserializer.py Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/projectserializer.py Tue Jan 24 10:25:44 2012 +0100 @@ -228,6 +228,8 @@ } self.tags[tag_title] = new_tag self.tags_dict[tag_id] = new_tag + else: + tag_id = self.tags[tag_title]["id"] element_tags.append({"id-ref":tag_id}) if not element_tags: @@ -354,7 +356,7 @@ href = "" meta_item_value = "" - if content not in self.viewable_contents: + if "Content" in settings.USE_GROUP_PERMISSIONS and content not in self.viewable_contents: href = settings.FORBIDDEN_STREAM_URL elif content.videopath: href = content.videopath.rstrip('/') + "/" + content.src diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/ldt_utils/segmentserializer.py --- a/src/ldt/ldt/ldt_utils/segmentserializer.py Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/segmentserializer.py Tue Jan 24 10:25:44 2012 +0100 @@ -23,7 +23,9 @@ self.views = None self.annotation_types = None self.medias = None - self.annotations = None + self.annotations = None + self.tags = {} + self.xml_docs = {} def __get_cutting_title(self, project_id, content_id, ensemble_id, cutting_id): @@ -35,7 +37,11 @@ else: doc = self.xml_docs[project_id] - cutting = doc.xpath('/iri/annotations/content[@id=\'%s\']/ensemble[@id=\'%s\']/decoupage[@id=\'%s\']/title' % (content_id, ensemble_id, cutting_id))[0] + cutting = doc.xpath('/iri/annotations/content[@id=\'%s\']/ensemble[@id=\'%s\']/decoupage[@id=\'%s\']/title' % (content_id, ensemble_id, cutting_id)) + if not cutting: + return None + + cutting = cutting[0] return cutting.text @@ -49,6 +55,16 @@ "annotation_types": [ ], } + stat = { + "id": "stat", + "contents": [ + self.content.iri_id + ], + "meta": { + "stat": self.content.stat_annotation + } + } + self.annotation_types = [] annotation_types = [] @@ -57,6 +73,7 @@ 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", @@ -69,16 +86,17 @@ }) - self.views = [view] + self.views = [view, stat] def __parse_content(self): href = "" meta_item_value = "" - - if self.content not in self.viewable_contents: - href = settings.FORBIDDEN_STREAM_URL + + if "Content" in settings.USE_GROUP_PERMISSIONS and self.content: + 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 meta_item_value = self.content.videopath.rstrip('/') + "/" @@ -116,11 +134,27 @@ for seg in self.segments: + segment_tags = [] + for tag in seg.tags.split(';'): + if not self.tags.has_key(tag): + new_tag = { + "meta": { + "dc:contributor": "IRI", + "dc:created": seg.date, + "dc:title": tag, + "dc:modified": seg.date, + "dc:creator": "IRI" + }, + "id": unicode(uuid.uuid1()) + } + self.tags[tag] = new_tag + segment_tags.append({'id-ref': self.tags[tag]['id']}) + segment = { 'begin': seg.start_ts, 'end': seg.start_ts + seg.duration, 'tags': seg.tags, - 'id': "s_%s" % unicode(uuid.uuid1()), + 'id': seg.element_id, 'color': "%s" % self.default_color, 'media': self.content.iri_id, 'content': { @@ -130,7 +164,7 @@ 'src': '' }, 'title': seg.title, - 'color': '2194379', + 'color': self.default_color, 'polemics': [ ], 'audio': { 'mimetype': 'audio/mp3', @@ -144,22 +178,26 @@ "dc:contributor": seg.author, "dc:created": seg.date, "dc:modified": seg.date, - "id-ref": seg.iri_id, + "id-ref": seg.cutting_id, "project": seg.project_id - } + }, + 'tags': segment_tags } self.annotations.append(segment) def serialize_to_cinelab(self): + if not self.segments: + return None + self.__parse_content() self.__parse_segments() self.__parse_views() res = {} res['views'] = self.views - res['tags'] = None + res['tags'] = self.tags.values() if len(self.tags) > 0 else None res['lists'] = None res['medias'] = self.medias res['annotations'] = self.annotations diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/ldt_utils/stat.py --- a/src/ldt/ldt/ldt_utils/stat.py Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/stat.py Tue Jan 24 10:25:44 2012 +0100 @@ -1,5 +1,5 @@ from django.conf import settings -from ldt.ldt_utils.models import AnnotationStat, Project, Segment +from ldt.ldt_utils.models import AnnotationStat, Project from django.db.models.signals import pre_delete import lxml.etree import datetime @@ -19,7 +19,7 @@ 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: @@ -35,6 +35,10 @@ for ann in content_node.xpath('ensemble/decoupage/elements/element'): begin = int(ann.get('begin')) end = int(ann.get('dur')) + begin + + text = ann.xpath('abstract')[0].text + if is_polemic(text): + pass buckets = find_buckets(buckets, limits, begin, end) nb_annotation += 1 @@ -80,7 +84,25 @@ buckets[i] += 1 return buckets - + +def is_polemic(text): + if text: + polemic_tags = ['++', '--', '==', '??'] + for tag in polemic_tags: + if tag in text: + return True + return False + + + +def filter_list(list, criteria, value): + new_list = [] + for l in list: + if getattr(l, criteria) == value: + new_list.append(l) + + return new_list + def delete_stat_project(sender, instance, **kwargs): @@ -149,10 +171,3 @@ contribution_project.save() -def filter_list(list, criteria, value): - new_list = [] - for l in list: - if getattr(l, criteria) == value: - new_list.append(l) - - return new_list \ No newline at end of file diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Tue Jan 24 10:25:44 2012 +0100 @@ -71,9 +71,9 @@ {% for content in content_list %}
  • - {% thumbnail content.image "294x165" format="PNG" crop="center" as im %}{% endthumbnail %} + {% thumbnail content.image "294x165" format="PNG" crop="center" as im %}{% trans 'open this media' %}{% endthumbnail %} -
    {{ content.nb_annotation }}
    +
    {{ content.nb_annotation }}

    {% if content.title|length > 69 %}{{content.title|slice:":69"}}...{% else %}{{content.title}}{% endif %}

    {% trans 'by' %} IRI | {{content.duration|str_duration:"h"}}

  • diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/ldt_utils/templates/front/front_base.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_base.html Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_base.html Tue Jan 24 10:25:44 2012 +0100 @@ -13,6 +13,7 @@ {% block js_import %}{% endblock %} {% block css_declaration %}{% endblock %} {% block css_import %} + {% endblock %} {% block js_declaration %}{% endblock %} @@ -22,7 +23,7 @@
    {% block body %} @@ -50,10 +51,10 @@
    diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/ldt_utils/templates/front/front_group.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_group.html Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_group.html Tue Jan 24 10:25:44 2012 +0100 @@ -19,9 +19,9 @@ {% for content in content_list %}
  • - {% thumbnail content.image "134x75" format="PNG" crop="center" as im %}{% endthumbnail %} -
    {{content.nb_annotation}}
    -

    {% if content.title|length > 69 %}{{content.title|slice:":69"}}...{% else %}{{content.title}}{% endif %}

    + {% thumbnail content.image "134x75" format="PNG" crop="center" as im %}{% trans 'open this media' %}{% endthumbnail %} +
    {{content.nb_annotation}}
    +

    {% if content.title|length > 69 %}{{content.title|slice:":69"}}...{% else %}{{content.title}}{% endif %}

    {% trans 'by' %} IRI | {{content.duration|str_duration:"h"}}

  • {% endfor %} @@ -34,9 +34,9 @@

    {% trans 'About the group' %}

    - {{group.profile.description|safe}} + {{group.get_profile.description|safe}}

    - {% thumbnail group.profile.image "54x40" format="PNG" crop="center" as im %}{{content.title}}{% endthumbnail %} + {% thumbnail group.get_profile.image "54x40" format="PNG" crop="center" as im %}{{content.title}}{% endthumbnail %}

     

    @@ -45,7 +45,7 @@ @@ -39,15 +40,15 @@ {% for content in most_contents %}
  • - {% thumbnail content.image "134x75" format="PNG" crop="center" as im %}{% endthumbnail %} -
    {{ content.nb_annotation }}
    -

    {% if content.title|length > 69 %}{{content.title|slice:":69"}}...{% else %}{{content.title}}{% endif %}

    + {% thumbnail content.image "134x75" format="PNG" crop="center" as im %}{% trans 'open this media' %}{% endthumbnail %} +
    {{ content.nb_annotation }}
    +

    {% if content.title|length > 69 %}{{content.title|slice:":69"}}...{% else %}{{content.title}}{% endif %}

    {% trans 'by' %} IRI | {{content.duration|str_duration:"h"}}

  • {% endfor %} @@ -60,13 +61,12 @@ {% for group in active_groups %}
  • -
    {{ group.user_set.count }}
    -
    32
    -

    {{group.name}}

    -

    {% if group.profile.description|length > 69 %}{{group.profile.description|safe|slice:":69"}}...{% else %}{{group.profile.description|safe}}{% endif %}

    +
    {{ group.user_set.count }}
    +

    {{group.name}}

    +

    {% if group.get_profile.description|length > 69 %}{{group.get_profile.description|safe|slice:":69"}}...{% else %}{{group.get_profile.description|safe}}{% endif %}

  • {% endfor %} diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/ldt_utils/templates/front/front_search_results.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Tue Jan 24 10:25:44 2012 +0100 @@ -110,7 +110,7 @@
  • {% trans "Search results for " %} {{ search }}

  • -
  • +
  • {{ nb_results }} {% trans "Result" %}{{ nb_results|pluralize }}

  • @@ -130,7 +130,7 @@

    {{res.content.duration|str_duration:"::"}}

    - + {{ res.content.stat_annotation }}
    @@ -142,10 +142,10 @@
  • - +
    -

    +

    {% if segment.title %}{{ segment.title }}{% else %}{% trans "No title" %}{% endif %}

    {% if segment.context %}{{ segment.context }}{% endif %}
    {% trans "Begin" %} : {{ segment.begin|str_duration:"::" }} - {% trans "duration" %} : {{ segment.duration|str_duration:"::" }}

  • @@ -159,7 +159,7 @@
  • {% if results.has_previous %} - {% trans "previous" %} + {% trans "previous" %} . {% endif %} {% if results.paginator.num_pages > 1 %} @@ -180,7 +180,7 @@ {% endif %} {% if results.has_next %} . - {% trans "next" %} + {% trans "next" %} {% endif %}

  • diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html Tue Jan 24 10:25:44 2012 +0100 @@ -30,12 +30,6 @@ diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html Tue Jan 24 10:25:44 2012 +0100 @@ -37,7 +37,22 @@ $("#close_button").click(function (e) { e.preventDefault(); parent.$.nmTop().close(); - }); + }); + + $("#moreoptions").click(function () { + var container = $("#moreoptionscontainer"); + + if (container.is(':visible')) { + $("#moreoptionscontainer").hide(); + $("#moreoptions").html("{% trans 'more options' %}"); + resize_modal_window($("#add_contribution")); + } else { + $("#moreoptionscontainer").show(); + $("#moreoptions").html("{% trans 'hide' %}"); + resize_modal_window($("#add_contribution")); + } + }); + }); tinyMCE.init({ @@ -54,6 +69,8 @@ height: "150", entity_encoding : "raw" }); + + @@ -107,9 +124,12 @@ +
    {% trans 'More options' %}
    +
    + {% include "ldt/ldt_utils/partial/picture.html" %} {% include "ldt/ldt_utils/partial/permissions.html" %} - {% include "ldt/ldt_utils/partial/picture.html" %} - +
    +
    diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/permissions.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/permissions.html Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/permissions.html Tue Jan 24 10:25:44 2012 +0100 @@ -14,54 +14,37 @@ } }); }); - } - + } + $(document).ready(function() { + var can_edit = '{{LDT_MEDIA_PREFIX}}img/pencil.png'; + var can_view = '{{LDT_MEDIA_PREFIX}}img/eye.png'; + {% if group_edition %} var search_url = "{% url ldt.ldt_utils.views.workspace.share_filter filter='__FILTER__' use_groups='false' %}"; {% else %} var search_url = "{% url ldt.ldt_utils.views.workspace.share_filter filter='__FILTER__' use_groups='true' %}"; {% endif %} - var share_this = '{% trans "share this project" %}'; - var do_not_share = '{% trans "do not share" %}'; - var share_img = '{{LDT_MEDIA_PREFIX}}img/user_add.png'; - var do_not_share_img = '{{LDT_MEDIA_PREFIX}}img/user_delete.png'; - var can_edit = '{{LDT_MEDIA_PREFIX}}img/pencil.png'; - var can_view = '{{LDT_MEDIA_PREFIX}}img/eye.png'; - var state = 1; - - if ($("#add_contribution").size()) { - var resize_elem = $("#add_contribution"); - } else { - var resize_elem = $("#add_content"); - } input_list_init = [ {'input_selector':"#searchuserinput", 'container_selector': "#itemcontainer", 'url':search_url} ]; - searchFieldInit(input_list_init); - - $("#shareproject").click(function () { - if (state == 1) { - $("#sharecontainer").show(); - $("#public input").attr('checked', false); - $("input[id=id_share]").val('True'); - var new_img = ''; - $(this).html(new_img + do_not_share); - state = 2; + searchFieldInit(input_list_init); + + $("#public input[type=checkbox]").change(function () { + if ($(this).is(':checked')) { + $("#permissioncontainer").hide(); } else { - $("#sharecontainer").hide(); - $("input[id=id_share]").val('False'); - var new_img = ''; - $(this).html(new_img + share_this); - state = 1; + $("#permissioncontainer").show(); } - - resize_modal_window(resize_elem); - }); - + resize_modal_window("#add_content"); + }); + + + $(".can_edit").live('click', function () { $(this).attr('src', can_view); + $(this).attr('title', "{% trans 'share.eye' %}"); $(this).removeClass('can_edit').addClass('can_view'); var id_item = $("input",$(this).closest('.shareline')).val(); $("#write input[value=" + id_item + "]").remove(); @@ -69,6 +52,7 @@ $(".can_view").live('click', function () { $(this).attr('src', can_edit); + $(this).attr('title', "{% trans 'share.pencil' %}"); $(this).removeClass('can_view').addClass('can_edit'); var id_item = $("input",$(this).closest('.shareline')).val(); $("#write").append(''); @@ -87,7 +71,7 @@ selection.each(function () { var id_item = $("input",$(this)).val(); $("#read").append(''); - $("td:last",$(this)).append('{% trans '); + $("td:last",$(this)).append('{% trans '); }); }); @@ -124,9 +108,13 @@ -
    +
    -
    + {% if content_form %} +
    {{ content_form.is_public }}
    + {% endif %} + +
    {% trans "User and group list" %}
    @@ -135,7 +123,7 @@
    - {% include "ldt/ldt_utils/partial/sharewith.html" %} + {% include "ldt/ldt_utils/partial/sharewith.html" %}
    diff -r 5e7ec99d4f1e -r b068bc945c2d src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/picture.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/picture.html Tue Jan 24 10:25:28 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/picture.html Tue Jan 24 10:25:44 2012 +0100 @@ -4,52 +4,24 @@ -