v0.4 better chapter filters V00.04
authorcavaliet
Thu, 27 Mar 2014 12:55:14 +0100
changeset 36 db864df8fe66
parent 35 34aced5a43db
child 37 157447feaaef
v0.4 better chapter filters
src/spel/__init__.py
src/spel/static/spel/js/spectacle.js
src/spel/templates/partial/spel_chapters.html
src/spel/views.py
--- a/src/spel/__init__.py	Wed Mar 26 13:55:23 2014 +0100
+++ b/src/spel/__init__.py	Thu Mar 27 12:55:14 2014 +0100
@@ -1,4 +1,4 @@
-VERSION = (0, 0, 3, "final", 0)
+VERSION = (0, 4, 0, "final", 0)
 
 VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION[:2])))
 
--- a/src/spel/static/spel/js/spectacle.js	Wed Mar 26 13:55:23 2014 +0100
+++ b/src/spel/static/spel/js/spectacle.js	Thu Mar 27 12:55:14 2014 +0100
@@ -187,6 +187,14 @@
 		else if($(this).parent().hasClass("perso")){
 			$("#mulsel3").multiselect('deselect', "personnages: " + $(this).parent().text().trim());
 		}
+		else if($(this).parent().hasClass("date")){
+			$('input[name=start_date]').val("");
+			$('input[name=end_date]').val("");
+		}
+		else if($(this).parent().hasClass("reftext")){
+			$('#start-text option:first-child').attr("selected", "selected");
+			$('#end-text').val("");
+		}
 		$("#btn-filter-chapters").click();
 		// manage when nothing is selected
 		if($(".chapter-tag-list").children().length==0){
--- a/src/spel/templates/partial/spel_chapters.html	Wed Mar 26 13:55:23 2014 +0100
+++ b/src/spel/templates/partial/spel_chapters.html	Thu Mar 27 12:55:14 2014 +0100
@@ -7,9 +7,14 @@
 <div class="row">
   <div class="col-md-8">
 	<ul class="list-inline chapter-tag-list">
+	    {% if start_date != "" or end_date != "" %}<li class="small searched-tag date">
+	      {% if start_date != "" %}{{ start_date }} &le; {% endif %}date{% if end_date != "" %} &le; {{ end_date }}{% endif %}
+	      <span class="glyphicon glyphicon-remove small"></span></li>
+	    {% endif %}
 	    {% for t in annot_types %}<li class="small searched-tag type">{{ t|remove_tag_key }} <span class="glyphicon glyphicon-remove small"></span></li>{% endfor %}
 	    {% for t in mod_scen %}<li class="small searched-tag modscen">{{ t|remove_tag_key }} <span class="glyphicon glyphicon-remove small"></span></li>{% endfor %}
 	    {% for t in perso %}<li class="small searched-tag perso">{{ t|remove_tag_key }} <span class="glyphicon glyphicon-remove small"></span></li>{% endfor %}
+	    {% if searched_ref_text %}<li class="small searched-tag reftext">{{ searched_ref_text|first }} &le; ref. texte  &le; {{ searched_ref_text|last }} <span class="glyphicon glyphicon-remove small"></span></li>{% endif %}
 	</ul>
     <p>{{ segments|length }} segment(s) trouvé(s)</p>
   </div>
--- a/src/spel/views.py	Wed Mar 26 13:55:23 2014 +0100
+++ b/src/spel/views.py	Thu Mar 27 12:55:14 2014 +0100
@@ -80,6 +80,7 @@
         start_text = request.GET.get("start_text", "")
         end_text = request.GET.get("end_text", "")
         ref_text = None
+        searched_ref_text = None
         if (start_text!="" and start_text!="start") or (end_text!="" and end_text!="end"):
             # First get all ref_text values
             rt_tags = Tag.objects.filter(name__startswith="ref_text:")
@@ -123,7 +124,8 @@
             # Get segments from tagged items
             s = TaggedItem.objects.get_by_model(seg_queryset, tags)
         
-        context = {"annot_types": annot_types, "mod_scen":mod_scen, "perso":perso, "segments": s}
+        context = {"annot_types":annot_types, "start_date":start_date_param, "end_date":end_date_param, 
+                   "mod_scen":mod_scen, "perso":perso, "searched_ref_text":searched_ref_text, "segments": s}
         
         return self.render_to_response(context)
     
@@ -166,7 +168,7 @@
             raw_query += "\n  )) "
         raw_query += "\n) "
         
-        context = {"annot_chapters": True, "annot_types": [], "mod_scen":[], "perso":[], "segments": list(Segment.objects.raw(raw_query)) }
+        context = {"annot_chapters": True, "start_date":"", "end_date":"", "annot_types": [], "mod_scen":[], "perso":[], "segments": list(Segment.objects.raw(raw_query)) }
         return self.render_to_response(context)