Commits

magicrebirth committed 0f7238e

small commit

  • Participants
  • Parent commits 56a67f3

Comments (0)

Files changed (7)

File demoproject/apps/djfacet/facet.py

 		=+=
 	"""
 	def __init__(self, uniquename, name, originalModel, originalAttribute, displayAttribute = None, ordering = None, behaviour = None, hierarchyoptions= None, 
-						mask=None, customvalues = None, mptt = False, exclude=False, group=[]):
+						mask=None, customvalues = None, mptt = False, explanation = "", exclude=False, group=[]):
 		self.uniquename = uniquename
 		self.name = name
 		self.originalModel = originalModel
 		self.mask = mask	
 		self.customvalues = customvalues	
 		self.facetvalues = []
+		self.explanation = explanation
 		self.mptt = mptt  # this is also used in the template to mark the mptt facets!
 		self.exclude = self.get_excluded_objs(exclude)
 		self.group = group  # the groups the facet is included in

File demoproject/apps/djfacet/facetsgroup.py

 		"""				
 		for i in facetspecs:
 			if self.uniquename in i['appearance']['grouping'] and i.get("active", True):
+				
+				model = i.get('model')  # required
+				uniquename = i.get('uniquename') # required
 				mptt = i.get('mptt', False)
+				explanation = i.get('explanation', "")
 				appearance_specs = i['appearance']
 				mask = appearance_specs.get('mask', None)
 				customvalues = appearance_specs.get('customvalues', None)
 				behaviour = i.get('behaviour', None) # behavior of each facet//result_type
 				group = self
 				# Facet(name, originalModel, originalAttribute, displayAttribute = None, behaviour = None, hierarchyoptions= None,  mask=None, customvalues = None, mptt = False, exclude=False, group=[])
-				djfacetlog("..adding facet: %s" % appearance_specs['uniquename'], True)
-				x = Facet(appearance_specs['uniquename'], appearance_specs['label'], appearance_specs['model'], 
-								dbfield, displayfield, ordering, behaviour, hierarchyoptions, mask, customvalues, mptt, group=group)
+				djfacetlog("..adding facet: %s" % uniquename, True)
+				x = Facet(uniquename, appearance_specs['label'], model, 
+								dbfield, displayfield, ordering, behaviour, hierarchyoptions, mask, customvalues, mptt, explanation, group=group)
 							
 				self.facets.append(x)
 				# also instantiates all the values!

File demoproject/apps/djfacet/templates/djfacet/all_facets.html

 
 	       <div class="unit size1of2 RegionName {% if facet.mptt %} istreefacet  {% endif %}"> 
 	          <section>
-	       		<h3>{{facet.name|capfirst}} <span class="info tip" title="this is an example of some text and more text"></span></h3>	
+	       		<h3>{{facet.name|capfirst}} <span class="info tip" title="{{facet.explanation}}"></span></h3>	
                 
 				{% block inner_facet_values %}  								
 

File demoproject/apps/djfacet/templates/djfacet/base.html.orig

-
-
-
-<!DOCTYPE html>
-<!--[if IE 7 ]>    <html class="no-js ie7" lang="en"> <![endif]--> 
-<!--[if IE 8 ]>    <html class="no-js ie8" lang="en"> <![endif]--> 
-<!--[if (gte IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
-    <head>
-        <title>DJfacet: a faceted browser that'll get you going in no time</title>
-        <!-- jquery from Google CDN -->
-        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
-        <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
-        
-        <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}{{DJF_STATIC_PATH}}/css/base.css" />
-        <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}{{DJF_STATIC_PATH}}/css/site.css" />
-        <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}{{DJF_STATIC_PATH}}/css/mod.css" />
-        <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}{{DJF_STATIC_PATH}}/css/typography.css" />
-        
-        
-        <!-- Modernizr: this should be called AFTER CSS to avoid FOUC
-            For dev purposes use /_a/s/libs/modernizr-dev.js
-        -->
-        <script type="text/javascript" src="{{ STATIC_URL }}{{DJF_STATIC_PATH}}/js/modernizr-dev.js"></script>
-		<script type="text/javascript" src="{{ STATIC_URL }}{{DJF_STATIC_PATH}}/js/jquery-ui.min.js"></script>
-		<script type="text/javascript" src="{{ STATIC_URL }}{{DJF_STATIC_PATH}}/js/jquery.blockUI2.31.js"></script>
-		<script type="text/javascript" src="{{ STATIC_URL }}{{DJF_STATIC_PATH}}/js/jquery.tipsy.js"></script>
-		<script type="text/javascript" src="{{ STATIC_URL }}{{DJF_STATIC_PATH}}/js/djfacet.js"></script>		
-
-  
-		
-		<script type="text/javascript">
-		
-			
-			// ONLOAD FUNCTION
-
-			$(document).ready(function() {
-
-				toggle_facets();
-				toggle_history();
-				
-				close_history();
-				
-				{% if ajaxflag %}
-					
-					// DEFAULT: all panels are created open - then they get closed at load time via js					
-					close_facets();
-					
-					$(".openclosefacet").bind( "click", function(event, ui) {
-					  // alert("clicked" + $(this)); 
-					updateFacetValues($(this));
-					});
-					
-				{% endif %}
-				
-				/* Tipsy tool tips */
-				   try {
-				       $(".tip").tipsy({
-				           delayIn: 500,
-				           delayOut: 500,
-				           fade: true
-				       });
-				   } catch(e) {
-				       // pass
-				       }
-			});
-
-		
-		</script>
-		
-		
-    </head>
-
-	<body>
-		
-		<div class="hidden">
-            <ul>
-                <li><a href="#contentSection">Skip to content</a></li>
-                <li><a href="#localNavigation">Skip to local navigation</a></li>                
-                <li><a href="#mainNavigation">Skip to main navigation</a></li>
-            </ul>
-
-			{# a couple of useful fields #}
-			<input type="hidden" id="active_restype" name="" value="{{result_typeObj.uniquename}}" />
-			<input type="hidden" id="active_urlstub" name="" value="{{newurl_stub}}" />
-			<input type="hidden" id="blockUImessage1" name="" value="" />
-			
-        </div>
-
-        <!-- WRAPPER STARTS -->
-        <div class="wrapper" id="djfacet_maindiv">
-            
-
-		
-			{% block header %}
-		
-			{% endblock %}
-
-            
-
-			{% block contents %}
- 
-
-			{% endblock %}
-			
- 
-          
-
-			{% include "djfacet/components/footer.html" %}
-            
-            
-           
-            
-            
-        </div>
-        
-        <!-- WRAPPER ENDS -->
-        
-		
-	</body>
-</html>
-
-
-

File demoproject/apps/djfacet/templates/djfacet/components/control_bar.html

 		
 		{% if query_filtersBuffer %}
 		
-		<!-- CASE 2 :: SINGLE_FACET PAGE IN THE MIDDLE OF A SEARCH  -->
-			{# &nbsp;&nbsp;&nbsp;&nbsp; #}
-			{# <br /> #}
 			
 		    <li>Current filter{{ query_filtersBuffer|pluralize }}:
 

File demoproject/facetspecs.py

 
 facetslist +=	[ 
 
-			{	'appearance' : {'label' : 'Region name' , 
-								'uniquename' : 'regionname',
-								'model' : Region , 
+			{	'active' : True, 
+				'explanation': "no explanation yet", 
+				'uniquename' : 'regionname',
+				'model' : Region ,
+				'appearance' : {'label' : 'Region name' , 
 								'dbfield' : "name", 
 								'displayfield' : "name", 
-								'explanation': "no explanation yet", # TODO: add explanations to all of them!
 								'grouping'	: ['countrygroup'],
 								'ordering' : 'name',
 								} ,
 									
 
 
-			{	'appearance' : {'label' : 'Region idbname' , 
-								'uniquename' : 'regionidbname',
-								'model' : Region , 
+			{	'active' : True, 
+				'explanation': "no explanation yet",
+				'uniquename' : 'regionidbname',
+				'model' : Region ,
+				'appearance' : {'label' : 'Region idbname' , 
 								'dbfield' : "idbname", 
 								'displayfield' : "idbname", 
-								'explanation': "no explanation yet", # TODO: add explanations to all of them!
 								'grouping'	: ['countrygroup'],
 								'ordering' : 'idbname',
 								} ,
 								]
 						 },
 
-			{	'appearance' : {'label' : 'Country name' , 
-								'uniquename' : 'countryname',
-								'model' : Country , 
+			{	'active' : True, 
+				'explanation': "no explanation yet",
+				'uniquename' : 'countryname',
+				'model' : Country ,
+				'appearance' : {'label' : 'Country name' , 
 								'dbfield' : "name", 
 								'displayfield' : "name", 
 								'explanation': "no explanation yet", # TODO: add explanations to all of them!
 				# THIS IS AN MPTT/HIERARCHICAL FACET		
 
 				{	'mptt' : True,
+					'explanation': "no explanation yet", 
+					'uniquename' : 'religionname',
+					'model' : Religion ,
 					'appearance' : {'label' : 'Religion name' , 
-									'uniquename' : 'religionname',
-									'model' : Religion , 
 									'dbfield' : "name", 
 									'displayfield' : "name", 
-									'explanation': "no explanation yet", # TODO: add explanations to all of them!
 									'grouping'	: ['religiongroup'],
 									'ordering' : 'name',
 									} ,
 							# NOW LET'S DEFINE A CUSTOM FACET (NOT WORKING YET SO I DISABLED IT) :
 
 				{	'active' : False,
-				
+					'explanation': "no explanation yet", 
+					'uniquename' : 'myreligions',
+					'model' : Religion ,
 					'appearance' : {'label' : 'My Religions' , 
-									'uniquename' : 'myreligions',
-									'model' : Religion , 
 									'dbfield' : "name", 
 									'displayfield' : "name", 
-									'explanation': "no explanation yet", # TODO: add explanations to all of them!
 									'grouping'	: ['religiongroup'],
 									'ordering' : 'name',
 									'customvalues' :	{
 
 
 
-
-
-
-##################
-#  2010-07-29
-#  how to use the specs format: 
-#
-##################
-
-
-
-
-
-# { 'label' : 'person name' ,	==>	 THE LABEL DISPLAYED ON THE FACET PANEL
-#  'uniquename' :	'troupegroup',	 ==> a unique name used for internal purposes
-#	'model' : Person ,		==> THE MAIN MODEL WE GET THE FACET VALUES FROM 
-#	'displayfield' : "pretty_name",	 ==> THE MODEL ATTR USED FOR DISPLAYING FACET VALUES
-#	'dbfield' : "name",	  ==> THE MODEL ATTR USED FOR GETTING THE ACTUAL FACET VALUES. IMP: THIS IS ALSO USED FOR BEHAVIOUR WHEN THIS 
-#							  IS LEFT BLANK BELOW, EG WHEN THE RESULT TYPE MODEL IS EQUAL TO FACET MODEL 
-#	'explanation': "some explanation", ==> SOME EXPLANATION OF THE FACET AS A WHOLE
-#	'grouping'	: ['documentgroup'], ==> WHAT GROUP THE FACET GOES INTO IN THE INTERFACE
-#	'hierarchy' : {'alpha': True, },	==> IF WE WANT FACET VALUES TO BE ORDERED HIERARCHICALLY
-#	 'mask'	  :	   TODO
-#  'behaviour' : [ {'resulttype' : 'people',  ==> FOR EACH RESULT TYPE (REFERENCED VIA UNIQUENAMES) PASS THE DJANGO QUERY-PATH AS A STRING
-#				   'querypath' : "",	 ===> if expressed as a tuple ('path1', 'path2') it is transformed into an OR
-#					'inversepath' : None, ===> if None, the inverse path is calculated automatically
-										# ====> if "string" or ("tuple",) it is passed as it is....
-#										 ===> if {"GENERIC" : True}, means that the result type in question is the owner of the facet property
-#												(although in some case the facet is calculated based on another one) 
-#												eg 'revision' or 'edited record' fields, which are present on all Models
-#				 'explanation' : "showing all people with selected surname " } , ==> AN EXPLANATION OF THE QUERY
-#				{'resulttype' : 'people', 
-#				 'querypath' : "",
-#				 'inversepath' : None, ===> if None, the inverse path is calculated
-#				 'explanation' : "showing all people with selected surname " }
-#				]
-#			 },
-
-
-
-

File demoproject/settings.py.orig

-""" DJfacet_project settings.
-
-originally coded by michele pasin on 2011-10-11
-++++
-A ``local_settings`` module must be made available to define sensitive
-and highly installation-specific settings.
-
-"""
-
-
-import os, sys
-import django
-from time import strftime
-
-# the site root is one level up from where settings.py is
-DJANGO_ROOT = os.path.dirname(os.path.realpath(django.__file__))
-SITE_ROOT = os.path.dirname(os.path.realpath(__file__)).rsplit('/', 1)[0]
-
-sys.path.append(os.path.join(SITE_ROOT, "demoproject/apps"))
-sys.path.append(os.path.join(SITE_ROOT, "demoproject/libs"))
-
-
-MYLOCAL_SERVER_PATH = "/mac/Dropbox/code/"
-
-# DYNAMIC LOCATION SELECTION: MODIFY AS NEEDED!
-if MYLOCAL_SERVER_PATH in SITE_ROOT: 
-	LOCAL_SERVER, LIVE_SERVER = True, False
-else:
-	LOCAL_SERVER, LIVE_SERVER = False, True
-if not (LOCAL_SERVER or LIVE_SERVER):
-	raise Exception("Could not determine which location you're in! \nLOCAL_SERVER or LIVE_SERVER?")
-	
-
-if not LIVE_SERVER:
-	DEBUG = True
-else:
-	DEBUG = False
-TEMPLATE_DEBUG = DEBUG
-
-ADMINS = (
-	('mikele', 'michele@mail.com'),
-)
-MANAGERS = ADMINS 
-TIME_ZONE = 'Europe/London'
-LANGUAGE_CODE = 'en-us'
-SITE_ID = 1
-USE_I18N = True
-
-
-MEDIA_URL = '/media/uploads/'
-STATIC_URL = '/media/static/'
-ADMIN_MEDIA_PREFIX = '/media/static/admin/'
-MPTTEXTRA_ADMIN_MEDIA = '/media/static/feincms/'
-
-# Absolute path to the directory that holds media uploaded
-MEDIA_ROOT = os.path.join(SITE_ROOT, 'uploads')
-# physical location of extra static files in development server
-STATICFILES_DIRS = (
-    os.path.join(SITE_ROOT, 'demoproject/static'),
-)
-# path used with "python manage.py collectstatic"
-STATIC_ROOT = os.path.join(SITE_ROOT, 'apache/static')
-
-
-
-TEMPLATE_LOADERS = (
-	# 'django.template.loaders.filesystem.load_template_source', DEPRECATED django1.3
-	'django.template.loaders.filesystem.Loader',
-	# 'django.template.loaders.app_directories.load_template_source', DEPRECATED django1.3
-	'django.template.loaders.app_directories.Loader'
-)
-
-
-MIDDLEWARE_CLASSES = (
-	'django.middleware.common.CommonMiddleware',
-	'django.contrib.sessions.middleware.SessionMiddleware',
-	'django.contrib.auth.middleware.AuthenticationMiddleware',
-	'django.contrib.messages.middleware.MessageMiddleware',
-	'django.middleware.csrf.CsrfViewMiddleware',
-	# tHis is deprecated, but needed here for backward compatibility in the admin
-	'django.middleware.csrf.CsrfResponseMiddleware', 
-)
-
-
-TEMPLATE_DIRS = (
-	os.path.join(SITE_ROOT, 'demoproject/mytemplates'),
-)
-
-
-TEMPLATE_CONTEXT_PROCESSORS = (
-	"django.contrib.auth.context_processors.auth",
-	"django.core.context_processors.debug",
-	"django.core.context_processors.i18n",
-	"django.core.context_processors.media" , 
-	'django.contrib.messages.context_processors.messages',
-	"django.core.context_processors.request",
-	"django.core.context_processors.static"
-)
-
-
-
-
-
-ROOT_URLCONF = 'demoproject.urls'
-
-
-
-
-INSTALLED_APPS = (	
-	'django.contrib.auth',
-	'django.contrib.contenttypes',
-	'django.contrib.sessions',
-	'django.contrib.sites',
-	'django.contrib.humanize',
-	'django.contrib.messages',
-	
-	'django.contrib.staticfiles',
-	
-	'django.contrib.admin',
-	'django_extensions',
-	 	
-	'djfacet',	 
-	'religions',
-
-)
-
-
-
-
-
-
-try:
-	if LOCAL_SERVER:
-		from local_settings import *
-	elif LIVE_SERVER:
-		from local_livsettings import *
-except ImportError:
-	pass
-
-
-
-
-
-
-# 
-# simple function that appends a debug string to another string (or file)
-# 
-def printdebug(stringa):
-	""" helper function: print to the command line output only if not running WSGI (othersiwe it'd cause an error)"""
-	if stringa == 'noise':
-		stringa = "\n%s\n" % ("*&*^" * 100)
-	if LOCAL_SERVER:
-		print ">>[%s]debug>>: %s"  % (strftime("%Y-%m-%d %H:%M:%S"), stringa)
-	else:
-		pass
-
-
-
-
-
-
-
-# ********
-# SITE_WIDE CACHE
-# ********
-
-# Needed always cause the FB is stored here : from django.core.cache import cache
-
-if LIVE_SERVER:
-	CACHE_IS_LOADED = True	# False when testing or in other circumstances...
-else:
-	CACHE_IS_LOADED = False
-
-
-if CACHE_IS_LOADED:
-	MIDDLEWARE_CLASSES += ('django.middleware.cache.FetchFromCacheMiddleware',)   # CACHE: needs to be last
-	temp = list(MIDDLEWARE_CLASSES)
-	temp.reverse()
-	temp += ['django.middleware.cache.UpdateCacheMiddleware']  # CACHE: needs to be first
-	temp.reverse()
-	MIDDLEWARE_CLASSES = tuple(temp)
-	CACHE_BACKEND = 'locmem://'
-	CACHE_MIDDLEWARE_SECONDS = 100000    #900
-	if LIVE_SERVER:
-		CACHE_MIDDLEWARE_ANONYMOUS_ONLY = False  # this makes sure that the admin is not cached
-	else:
-		CACHE_MIDDLEWARE_ANONYMOUS_ONLY = False
-
-
-
-
-
-
-
-# ======= DJFACET options: showing all of them for description =======
-
-DJF_CACHE = False   # default value = False
-DJF_AJAX = False  	# default value = 'vertical' 
-DJF_MAXRES_PAGE = 50  # default value = 50
-DJF_MAXRES_FACET = 5  # default value = 5 
-DJF_MAXRES_ALLFACETS = 9  # default value = 9 
-DJF_SHOWLOGS = True		# default value = False
-DJF_SPECS_MODULE = 'facetspecs'  # default value = 'facetspecs'
-DJF_URL_AS_NUMBERS = False  # default value = False
-DJF_SPLASHPAGE = True # default value = 'vertical'
-DJF_SPLASHPAGE_CACHE = False  # default value = False
-DJF_STATIC_PATH = 'djfacet_beax'  # default value = 'djfacet'
-DJF_MPTT_INHERITANCE = True  # default = False
-