--- a/src/spel/__init__.py Fri May 23 16:23:27 2014 +0200
+++ b/src/spel/__init__.py Tue May 27 11:07:34 2014 +0200
@@ -1,4 +1,4 @@
-VERSION = (0, 5, 17, "final", 0)
+VERSION = (0, 5, 18, "final", 0)
VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION[:2])))
--- a/src/spel/static/spel/js/opera.js Fri May 23 16:23:27 2014 +0200
+++ b/src/spel/static/spel/js/opera.js Tue May 27 11:07:34 2014 +0200
@@ -12,6 +12,12 @@
filter_enabled = true;
}
}
+ if(!filter_enabled){
+ // check search input
+ if($("#search-input").val().trim()!=""){
+ filter_enabled = true;
+ }
+ }
if(filter_enabled){
$("#btn-filter-chapters").removeAttr('disabled');
}
@@ -79,14 +85,9 @@
$("#mulsel4").multiselect('dataprovider', data4);
$("#mulsel4").multiselect('enable');
});
- $(document).on('input', "#search-input", function(){
- if($(this).val()!=""){
- $("#btn-search-annotations").removeAttr('disabled');
- }
- else{
- $("#btn-search-annotations").attr('disabled','disabled');
- }
- });
+
+ // on change
+ $(document).on('input', "#search-input", enabledFilter );
// Data 5 : Actes
$.ajax({
@@ -169,7 +170,14 @@
enabledFilter();
});
-
+ $(document).on('input', "#search-input", function(){
+ if($(this).val()!=""){
+ $("#btn-search-annotations").removeAttr('disabled');
+ }
+ else{
+ $("#btn-search-annotations").attr('disabled','disabled');
+ }
+ });
function buildChapterTable(html){
$(".chapter-results").removeClass("loader");
@@ -190,7 +198,7 @@
// Search chapters management
$("#btn-filter-chapters").click(function(e){
- if($("#mulsel1").val()==null && $("#mulsel2").val()==null && $("#mulsel3").val()==null && $("#mulsel4").val()==null && $("#mulsel5").val()==null && $("#mulsel6").val()==null && !((typeof $("#end-mesure").attr('disabled'))==="undefined" || $("#start-mesure").val()!="start")){
+ if($("#mulsel1").val()==null && $("#mulsel2").val()==null && $("#mulsel3").val()==null && $("#mulsel4").val()==null && $("#mulsel5").val()==null && $("#mulsel6").val()==null && !((typeof $("#end-mesure").attr('disabled'))==="undefined" || $("#start-mesure").val()!="start") && $("#search-input").val().trim()==""){
$(".chapter-results").html("<p>Vous devez sélectionner au moins un filtre</p>");
return false;
}
@@ -205,6 +213,7 @@
modalites_sceniques: ( ($("#mulsel2").val()==null) ? [] : $("#mulsel2").val() ).join(","),
personnages: ( ($("#mulsel3").val()==null) ? [] : $("#mulsel3").val() ).join(","),
type_travail: ( ($("#mulsel4").val()==null) ? [] : $("#mulsel4").val() ).join(","),
+ q: $("#search-input").val(),
acte: ( ($("#mulsel5").val()==null) ? [] : $("#mulsel5").val() ).join(","),
scene: ( ($("#mulsel6").val()==null) ? [] : $("#mulsel6").val() ).join(","),
start_mesure: $("#start-mesure").val(),
@@ -224,7 +233,10 @@
// click-to-remove-tag management for chapter
$(".chapter-results").on("click", ".chapter-tag-list .glyphicon-remove", function(){
- if($(this).parent().hasClass("type")){
+ if($(this).parent().children().first().hasClass("glyphicon-search")){
+ $("#search-input").val("");
+ }
+ else if($(this).parent().hasClass("type")){
$("#mulsel1").multiselect('deselect', $(this).parent().text().trim());
}
else if($(this).parent().hasClass("modscen")){
--- a/src/spel/templates/partial/spel_opera_annotations.html Fri May 23 16:23:27 2014 +0200
+++ b/src/spel/templates/partial/spel_opera_annotations.html Tue May 27 11:07:34 2014 +0200
@@ -19,6 +19,7 @@
{% else %}
{% for t in mesure %}<li class="small searched-tag mesure">mesure: {{ t }} <span class="glyphicon glyphicon-remove small"></span></li>{% endfor %}
{% endif %}
+ {% if q != "" %}<li class="small searched-tag"><span class="glyphicon glyphicon-search small"></span> : {{ q }} <span class="glyphicon glyphicon-remove small"></span></li>{% endif %}
</ul>
<p>{{ segments|length }} segment(s) trouvé(s)</p>
</div>
@@ -39,8 +40,8 @@
<td>{{ s.tags|get_tags:"opera_scene"|join:', ' }}</td>
<td>{{ s.tags|get_tags:"opera_mesure"|join:', ' }}</td>
<td>
- <span class="glyphicon glyphicon-time popinfo" data-trigger="hover" data-container="body" data-toggle="popover" data-placement="auto"
- data-content="<strong>Timecodes:</strong> {{ s.start_ts|str_duration }} - {{ s.start_ts|add:s.duration|str_duration }}"></span>
+ <span class="glyphicon glyphicon-info-sign popinfo" data-trigger="hover" data-container="body" data-toggle="popover" data-placement="auto"
+ data-content="<strong>Timecodes:</strong> {{ s.start_ts|str_duration }} - {{ s.start_ts|add:s.duration|str_duration }}<br/><strong>Commentaire</strong>: {{ s.abstract }}"></span>
<a class="play-button" href="{% url 'spel_player' %}?g={{ s.iri_id }}&d=opera&f=720p.mp4#id={{ s.element_id }}" target="_blank"><span class="glyphicon glyphicon-play"></span></a>
</td>
</tr>
--- a/src/spel/templates/spel_opera.html Fri May 23 16:23:27 2014 +0200
+++ b/src/spel/templates/spel_opera.html Tue May 27 11:07:34 2014 +0200
@@ -37,7 +37,7 @@
</div>
<div class="col-md-3">
<form id="searchform" role="form">
- <input type="text" class="form-control" id="search-input" name="search-input" placeholder="Commentaire" disabled="disabled" />
+ <input type="text" class="form-control" id="search-input" name="search-input" placeholder="Commentaire" />
<button style="display: none;"><span class="glyphicon glyphicon-search form-control-feedback"></span></button>
</form>
</div>
--- a/src/spel/views.py Fri May 23 16:23:27 2014 +0200
+++ b/src/spel/views.py Tue May 27 11:07:34 2014 +0200
@@ -3,24 +3,26 @@
@author: tcavalie
'''
+
+from django.conf import settings
+from django.contrib.contenttypes.models import ContentType
+from django.db.models import Q
+from django.db.models.aggregates import Count
+from django.db.models.query import RawQuerySet
+from django.http.response import HttpResponse
+from django.views.generic import TemplateView
+from itertools import groupby
+from ldt.indexation import get_results_with_context
+from ldt.ldt_utils.models import Segment, Content
+from ldt.ldt_utils.views.workspace import get_search_results
+from operator import itemgetter
+from taggit.models import Tag, TaggedItem
import json
import re
import time
-from django.db.models import Q
-from django.conf import settings
-from django.views.generic import TemplateView
-from itertools import groupby
-from operator import itemgetter
-from taggit.models import Tag, TaggedItem
-from ldt.ldt_utils.models import Segment, Content
import logging
-from ldt.ldt_utils.views.workspace import get_search_results
-from django.http.response import HttpResponse
-from django.db.models.query import RawQuerySet
-from django.contrib.contenttypes.models import ContentType
-from django.db.models.aggregates import Count
logger = logging.getLogger(__name__)
@@ -350,12 +352,20 @@
end_date_param = request.GET.get("end_date", "")
if end_date_param!="":
content_qs = content_qs.filter(content_creation_date__lt=end_date_param + " 23:59:59")
- iri_ids = content_qs.values_list("iri_id", flat=True)
- #logger.debug("iri_ids")
- #logger.debug(iri_ids)
- # Filter segment if necessary
+
+ # Query on abstract management
+ q = request.GET.get("q", "").strip()
+ if q!="":
+ # Query case : we get segments by the search engine
+ field = "abstract"
+ results = get_results_with_context(Segment, field, q, content_qs)
+ seg_queryset = Segment.objects.filter(pk__in=[e['indexation_id'] for e in results]).select_related("content__title")
+ else:
+ # Filter segment if necessary
+ iri_ids = content_qs.values_list("iri_id", flat=True)
+ seg_queryset = Segment.objects.filter(iri_id__in=iri_ids).select_related("content__title")
+
annot_types_param = request.GET.get("annotation_types", "")
- seg_queryset = Segment.objects.filter(iri_id__in=iri_ids).select_related("content__title")
annot_types = []
if annot_types_param!="":
annot_types = annot_types_param.split(",")
@@ -383,6 +393,7 @@
if scene_param!="":
scene = scene_param.split(",")
+ # Mesure management
start_mesure = request.GET.get("start_mesure", "")
end_mesure = request.GET.get("end_mesure", "")
mesure = None
@@ -446,18 +457,20 @@
# Get segments from tagged items
#s = TaggedItem.objects.get_by_model(seg_queryset, tags)
tags = list(tags)
- seg_ids = list(TaggedItem.objects\
- .values_list("object_id", flat=True)\
- .filter(content_type=ContentType.objects.get_for_model(Segment))\
- .filter(tag__in=tags)\
- .annotate(count_status=Count('object_id'))\
- .filter(count_status=len(tags)))
- s = list(seg_queryset.filter(pk__in=seg_ids))
-
+ if len(tags)>0:
+ seg_ids = list(TaggedItem.objects\
+ .values_list("object_id", flat=True)\
+ .filter(content_type=ContentType.objects.get_for_model(Segment))\
+ .filter(tag__in=tags)\
+ .annotate(count_status=Count('object_id'))\
+ .filter(count_status=len(tags)))
+ s = list(seg_queryset.filter(pk__in=seg_ids))
+ else:
+ s = list(seg_queryset)
context = {"annot_types":annot_types, "start_date":start_date_param, "end_date":end_date_param,
"mod_scen":mod_scen, "perso":perso, "type_travail":type_travail, "acte":acte,
- "scene":scene, "mesure":mesure_int, "segments": s}
+ "scene":scene, "mesure":mesure_int, "q":q, "segments": s}
return self.render_to_response(context)