# HG changeset patch # User hamidouk # Date 1327595247 -3600 # Node ID 21350969c66462b7b4b548aa08f66307aca0764d # Parent 7f189d7b9d5a0f8fea152dda50a1fffbef7ca705# Parent af360d447874e9404023e1441b31402fab297ead Merge with upstream diff -r 7f189d7b9d5a -r 21350969c664 src/ldt/ldt/ldt_utils/migrations/0005_add_permissions.py --- a/src/ldt/ldt/ldt_utils/migrations/0005_add_permissions.py Thu Jan 26 17:23:18 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/migrations/0005_add_permissions.py Thu Jan 26 17:27:27 2012 +0100 @@ -20,10 +20,8 @@ for model in ["project", "content", "segment", "author", "media"]: self.add_perm(orm, model) - - - set_default_permissions(is_migration=True, orm=orm) - + + # Run command ./manage.py assignpermissions after this migration def add_perm(self, orm, model_name): diff -r 7f189d7b9d5a -r 21350969c664 src/ldt/ldt/ldt_utils/migrations/0007_auto__add_field_content_image__del_field_media_image.py --- a/src/ldt/ldt/ldt_utils/migrations/0007_auto__add_field_content_image__del_field_media_image.py Thu Jan 26 17:23:18 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/migrations/0007_auto__add_field_content_image__del_field_media_image.py Thu Jan 26 17:27:27 2012 +0100 @@ -1,5 +1,6 @@ # encoding: utf-8 import datetime +from django.conf import settings from south.db import db from south.v2 import SchemaMigration from django.db import models @@ -9,7 +10,7 @@ def forwards(self, orm): # Adding field 'Content.image' - db.add_column('ldt_utils_content', 'image', self.gf('sorl.thumbnail.fields.ImageField')(default='thumbnails/contents/drive.jpg', max_length=100), keep_default=False) + db.add_column('ldt_utils_content', 'image', self.gf('sorl.thumbnail.fields.ImageField')(default=settings.DEFAULT_CONTENT_ICON, max_length=100), keep_default=False) # Deleting field 'Media.image' db.delete_column('ldt_utils_media', 'image') diff -r 7f189d7b9d5a -r 21350969c664 src/ldt/ldt/ldt_utils/migrations/0011_gen_stat_annotation.py --- a/src/ldt/ldt/ldt_utils/migrations/0011_gen_stat_annotation.py Thu Jan 26 17:23:18 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/migrations/0011_gen_stat_annotation.py Thu Jan 26 17:27:27 2012 +0100 @@ -11,19 +11,13 @@ def forwards(self, orm): "Write your forwards methods here." - - for proj in orm.Project.objects.all(): - update_stat_project(proj) - - # Sets fields nb_annotation and stat_annotation to 0 and 0,0,...,0 - # for contents that do not have annotations - for content in orm.Content.objects.all(): - if not content.stat_annotation: - update_stat_content(content) + pass + # use command ./manage.py statannotation after this migration def backwards(self, orm): "Write your backwards methods here." + pass models = { diff -r 7f189d7b9d5a -r 21350969c664 src/ldt/ldt/ldt_utils/models.py --- a/src/ldt/ldt/ldt_utils/models.py Thu Jan 26 17:23:18 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/models.py Thu Jan 26 17:27:27 2012 +0100 @@ -346,11 +346,11 @@ if self.pk: everyone = Group.objects.get(name=settings.PUBLIC_GROUP_NAME) if value: - assign('view_content', everyone, self) - assign('view_media', everyone, self.media_obj) + assign('ldt_utils.view_content', everyone, self) + assign('ldt_utils.view_media', everyone, self.media_obj) else: - remove_perm('view_content', everyone, self) - remove_perm('view_media', everyone, self.media_obj) + remove_perm('ldt_utils.view_content', everyone, self) + remove_perm('ldt_utils.view_media', everyone, self.media_obj) return locals() @@ -375,6 +375,7 @@ # Tag management def get_tags(self): return Tag.objects.get_for_object(self) + @@ -502,7 +503,13 @@ default_image = os.path.basename(settings.DEFAULT_CONTENT_ICON) for content in self.contents.all(): - if os.path.basename(content.image.file.name) != default_image: + add_image = False + try: + current_image = content.image.file.name + except IOError: + add_image = True + + if add_image or current_image != default_image: self.image = content.image return True diff -r 7f189d7b9d5a -r 21350969c664 src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Thu Jan 26 17:23:18 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Thu Jan 26 17:27:27 2012 +0100 @@ -9,6 +9,7 @@ {{block.super}} + {% endblock %} {% block css_import %} @@ -16,50 +17,6 @@ {% endblock %} -{% block js_declaration %} -{{block.super}} - - -{% endblock %} - {% block body %} {{block.super}} @@ -71,8 +28,18 @@ {% for content in content_list %}
  • - {% thumbnail content.image "294x165" format="PNG" crop="center" as im %}{% trans 'open this media' %}{% endthumbnail %} - + + {% thumbnail content.image "294x165" format="PNG" crop="center" as im %}{% trans 'open this media' %}{% endthumbnail %} +
    +
      +
    • 0%
    • +
    • 0%
    • +
    • 0%
    • +
    • 0%
    • +
    + {{ content.stat_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 7f189d7b9d5a -r 21350969c664 src/ldt/ldt/ldt_utils/templates/front/front_home.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_home.html Thu Jan 26 17:23:18 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_home.html Thu Jan 26 17:27:27 2012 +0100 @@ -6,6 +6,13 @@ {% block title %}{% trans "front.home" %}{% endblock %} +{% block js_import %} +{{block.super}} + + + +{% endblock %} + {% block css_import %} {{block.super}} @@ -26,7 +33,17 @@
  • {% for content in last_contents %}
  • - {% thumbnail content.image "294x165" format="PNG" crop="center" as im %}{% trans 'open this media' %}{% endthumbnail %} + {% thumbnail content.image "294x165" format="PNG" crop="center" as im %}{% trans 'open this media' %}{% endthumbnail %} +
    +
      +
    • 0%
    • +
    • 0%
    • +
    • 0%
    • +
    • 0%
    • +
    + {{ content.stat_annotation }} +
    +
    {{ content.nb_annotation }}

    {{content.title}}

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

    @@ -46,14 +63,16 @@
  • {% for content in most_contents %}
  • - + {% thumbnail content.image "134x75" format="PNG" crop="center" as im %}{% trans 'open this media' %}{% endthumbnail %} - +
    +
      +
    • 0%
    • +
    • 0%
    • +
    • 0%
    • +
    • 0%
    • +
    +
    {{ content.nb_annotation }}

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

    diff -r 7f189d7b9d5a -r 21350969c664 src/ldt/ldt/management/commands/statannotation.py --- a/src/ldt/ldt/management/commands/statannotation.py Thu Jan 26 17:23:18 2012 +0100 +++ b/src/ldt/ldt/management/commands/statannotation.py Thu Jan 26 17:27:27 2012 +0100 @@ -1,37 +1,23 @@ from django.core.management.base import BaseCommand -from ldt.ldt_utils.models import Content -from ldt.ldt_utils.stat import update_stat_content -from optparse import make_option +from ldt.ldt_utils.models import Content, Project +from ldt.ldt_utils.stat import update_stat_content, update_stat_project class Command(BaseCommand): - help = 'Computes annotation volume for a given content' + help = 'Computes annotation for all contents and all projects' - option_list = BaseCommand.option_list + ( - make_option("-c", "--content", - dest="content", - action="store", - help="The id of the content we want to compute annotation volume on"), - ) - def handle(self, *args, **options): - parser = self.create_parser("statannotation", "") - options, args = parser.parse_args() - - verbose = (options.verbosity == "2") + def handle(self, *args, **options): - id_content = options.content - if id_content: - contents = Content.objects.filter(iri_id=id_content) - if not len(contents): - print "No content found with iri_id %s" % id_content - return None - else: - contents = Content.objects.all() - print "analysing all contents" + for proj in Project.objects.all(): + print "Stat for project %s" % proj + update_stat_project(proj) - - for content in contents: - update_stat_content(content) + # Sets fields nb_annotation and stat_annotation to 0 and 0,0,...,0 + # for contents that do not have annotations + for content in Content.objects.all(): + if not content.stat_annotation: + print "Stat for content %s" % content + update_stat_content(content) return None \ No newline at end of file diff -r 7f189d7b9d5a -r 21350969c664 src/ldt/ldt/static/ldt/css/front_common.css --- a/src/ldt/ldt/static/ldt/css/front_common.css Thu Jan 26 17:23:18 2012 +0100 +++ b/src/ldt/ldt/static/ldt/css/front_common.css Thu Jan 26 17:27:27 2012 +0100 @@ -132,17 +132,25 @@ .img_media { background: #000000; border: 2px solid #ffffff; padding: 1px; } -.img_and_polemic { +.img_and_overlay { float: left; position: relative; } +.overlay { + position: absolute; bottom: 7px; width: 100%; +} + +.graph_annotation { + float: left; height: 20px; margin: 0 4px; +} + .polemics { - position: absolute; bottom: 8px; list-style: none; z-index: 2; + float: left; margin-bottom: 2px; list-style: none; z-index: 2; width: 95%; font-size: 9px; color: #ffffff; } .polemics li { - text-align: left; overflow: hidden; padding: 0 0 0 3px; margin: 2px 0; clear: both; + float: left; text-align: left; overflow: hidden; padding: 0 0 0 3px; margin: 2px 0; clear: both; width: 100%; box-shadow: 2px 2px 2px #000000; } diff -r 7f189d7b9d5a -r 21350969c664 src/ldt/ldt/static/ldt/css/front_home.css --- a/src/ldt/ldt/static/ldt/css/front_home.css Thu Jan 26 17:23:18 2012 +0100 +++ b/src/ldt/ldt/static/ldt/css/front_home.css Thu Jan 26 17:27:27 2012 +0100 @@ -22,10 +22,6 @@ .title_ul { list-style: none; } -.graph_annotation { - background: url(./imgs/whitealpha.png); position:absolute; - z-index: 2; width: 294px; height: 20px; left: 3px; top: 148px; -} /* Plus annotés */ diff -r 7f189d7b9d5a -r 21350969c664 src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js --- a/src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js Thu Jan 26 17:23:18 2012 +0100 +++ b/src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js Thu Jan 26 17:27:27 2012 +0100 @@ -61,7 +61,9 @@ }); $("li.li_segment").removeClass("selected"); $("#li_" + _id).addClass("selected"); - $("#result_preview").show().html($("#li_" + _id + " div.hidden_preview").html()); + $("#result_preview") + .show() + .html($("#li_" + _id + " div.hidden_preview").html()); $("#result_preview .result_taglist") .html( $("#result_preview .result_taglist").html() @@ -82,4 +84,9 @@ "opacity" : ".5", }); }); + $(document).scroll(function() { + $("#result_preview").css({ + "padding-top": Math.max(30,$(document).scrollTop()-20) + 'px', + }) + }) }); \ No newline at end of file diff -r 7f189d7b9d5a -r 21350969c664 src/ldt/ldt/static/ldt/js/Ldt_front_sparkline.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/static/ldt/js/Ldt_front_sparkline.js Thu Jan 26 17:27:27 2012 +0100 @@ -0,0 +1,36 @@ +$(document).ready(function () { + $('.graph_annotation').each(function(_i) { + var _values = this.innerHTML.split(','), + _nb = _values.length, + _width = $(this).parent().parent().parent().width() - 8, + _height = $(this).height(), + _max = _values.reduce(function(_a,_b) { + return Math.max(_a,_b); + }, 1), + _x = function(_p) { + return _p * _width / _nb; + }, + _y = function(_p) { + return _height * ( 1 - _p / _max ); + }, + _d = _values.map(function(_v,_k) { + return ( _k == 0 ? + "M" + _x(_k) + " " + _y(_v) : + "C" + _x(_k-.5) + " " + _y(_values[_k - 1]) + + " " + + _x(_k-.5) + " " + _y(_v) + + " " + + _x(_k) + " " + _y(_v) + ) ; + }).join("") + "L" + _width + " " + _height + "L0 " + _height; + this.innerHTML = ''; + var _paper = new Raphael(this,_width,_height); + _paper.rect(0,0,_width,_height).attr({ + "stroke" : "none", + "fill" : "#ffffff", + "opacity" : .8, + }); + _paper.path(_d).attr({ + "fill" : "#adadad", + "stroke" : "#808080" + }); + }); +}); \ No newline at end of file