Commits

magicrebirth committed acd12d9

fixed unicode bug

Comments (0)

Files changed (6)

demoproject/apps/djfacet/cache_manager.py

 from django.db.models.query import QuerySet
 from django.db.models import Avg, Max, Min, Count, Q
 from django.core.cache import cache
+from  django.utils.encoding import force_unicode
 
 import operator, copy
 
 		"""
 
 		queryargs_Ids = [x.id for x in queryargs]
-		return "_".join([str(x) for x in sorted(queryargs_Ids)])  # we sort them always by number
+		return "_".join([force_unicode(x) for x in sorted(queryargs_Ids)])  # we sort them always by number
 
 
 

demoproject/apps/djfacet/templates/djfacet/components/control_breadcrumbs.html

 
 <h2>
 	
+	{# MIDDLE OF A SEARCH #}
+	
 	{% if query_filtersBuffer %}
 		<a href="{{url_prefix}}?resulttype={{result_typeObj.uniquename}}{{newurl_stub}}">Search Results</a>&nbsp;>>&nbsp;
+	
+	{# BEGINNING OF A SEARCH #}
+	
 	{% else %}
 		<a href="{{url_prefix}}allfacets/?resulttype={{result_typeObj.uniquename}}">All</a>&nbsp;>>&nbsp;
 	{% endif %}

demoproject/apps/djfacet/templates/djfacet/components/snippet_facet.html

 {# ps. the block declaration is needed because we may call this using 'render_block_to_string' #}
 
+
+
 {% block inner_facet_values %}
-
 	
-{% if twocolumnsflag %}
+	{% if twocolumnsflag %}
 	
 
 	<!-- CASE 1: TWO COLUMNS ::::: EG IN THE SPLASH PAGE -->
 				{# [  {{facetvalue.tot_all}}, {{facetvalue.tot_inbatch}}, {{facetvalue.tot_left}}] #}
 						
 			{% else %}	
-				<li><a class="inactive" title="Filter inactive because your search already produced {{totitems}} results">{{facetvalue.displayname|capfirst|default:"---"}} ({{facetvalue.howmany|default:"0"}})</a></li>							
+				<li><a class="inactive" title="Filter inactive because your search already produced {{totitems}} result{{totitems|pluralize}}">{{facetvalue.displayname|capfirst|default:"---"}} ({{facetvalue.howmany|default:"0"}})</a></li>							
 
 			{% endifnotequal %}
 
 
 		{% endfor %}
 
-		{#  LINK TO THE FACET-ALL-VALUES PAGE: always in splash page #}	
+		{#  LINK TO THE FACET-ALL-VALUES PAGE: for the moment only on the splash page #}	
 
-		{% if  forloop.last  %}
+		{% if  forloop.last  and facetvalue_group.0.tot_left > 0 %} 
 
 			{% if djfacet_splashpage %}
 
-		  		<li>
-					<a href="{{url_prefix}}facet/{{facet.uniquename}}/?resulttype={{result_typeObj.uniquename}}&amp;totitems={{totitems}}{{newurl_stub}}" ><span > more...</span></a>    
-					
-					{# 2012-04-26:removed this cause the count was mistaken with MPTT  ...and {{facetvalue_group.0.tot_left}} more.</span></a>  #}
-					
-					
-				</li>
+	  		<li>
+				<a href="{{url_prefix}}facet/{{facet.uniquename}}/?resulttype={{result_typeObj.uniquename}}&amp;totitems={{totitems}}{{newurl_stub}}" ><span > more...</span></a>    
+				
+				{# 2012-04-26:removed this cause the count was mistaken with MPTT  ...and {{facetvalue_group.0.tot_left}} more.</span></a>  #}
+				
+				
+			</li>
 
 			{% endif %}
 
 						{{facetvalue.displayname|capfirst|default:"---"}} ({{facetvalue.howmany|default:"0"}})							
 					</a></li>							
 				{% else %}	
-					<li><a class="inactive" title="Filter inactive because your search already produced {{totitems}} results">{{facetvalue.displayname|capfirst|default:"---"}} ({{facetvalue.howmany|default:"0"}})</a></li>							
+					<li><a class="inactive" title="Filter inactive because your search already produced {{totitems}} result{{totitems|pluralize}}">{{facetvalue.displayname|capfirst|default:"---"}} ({{facetvalue.howmany|default:"0"}})</a></li>							
 
 				{% endifnotequal %}
 
 	</ul>
 </div>
 
-
 {% endif %}
 
 

demoproject/apps/djfacet/templates/djfacet/single_facet.html

 			{% include "djfacet/components/navbar.html" %}
 
 	
-	
 			{% include "djfacet/components/control_bar.html" %}
 			
 			

demoproject/apps/djfacet/views.py

 		'DJF_STATIC_PATH' : DJF_STATIC_PATH,
 		'ajaxflag' : DJF_AJAX,
 		'twocolumnsflag' : False,
+		'djfacet_searchpage' : True,
 
 		'result_types' : DJF_SPECS.result_types,	
 		'result_typeObj' : FM_GLOBAL.get_resulttype_from_name(resulttype),	  
 						'facet' :	facet,
 						'newurl_stub' : newurl_stub,
 						'result_typeObj' : FM_GLOBAL.get_resulttype_from_name(resulttype),	
-						'totitems' : totitems ,
+						'totitems' : totitems or len(activeIDs),  #when using dbcache, totitems may fails
 						'ordering' : ordering , 
 						'DJF_STATIC_PATH' : DJF_STATIC_PATH,
 						})
 =============
 ===============
 
+2012-06-15
+-----------------------------------------
+- fixed bug with non unicode values in cache_manager.py
+- separated breadcrumbs into its own template
+
 
 
 2012-06-08