web/hdalab/views/ajax.py
changeset 232 eb02eed5f7d1
parent 212 3e1193c6dce3
child 235 b41f0b200940
--- a/web/hdalab/views/ajax.py	Sat Aug 18 08:43:04 2012 +0200
+++ b/web/hdalab/views/ajax.py	Mon Aug 27 17:27:27 2012 +0200
@@ -129,8 +129,8 @@
 
 def cattree(request):
     # Gets the category tree from a label
-    ROOT_MAX_TAG_ORDER = 5
-    MAX_TAG_ORDER = 5
+    ROOT_MAX_TAG_ORDER = 8
+    MAX_TAG_ORDER = 8
     MAX_LEVEL = 3
     LEVEL_COEFF = 5
     label = request.GET.get('label', None)
@@ -146,7 +146,7 @@
 #    if len(tag_list):
     contents = []
 #    datasheets = Datasheet.objects.filter(validated = True, taggedsheet__tag__label__in = tag_list, taggedsheet__order__lte = MAX_TAG_ORDER).distinct()
-    datasheets = Datasheet.objects.filter(validated = True, taggedsheet__tag__label__iexact = label, taggedsheet__order__lte = ROOT_MAX_TAG_ORDER).distinct()
+    datasheets = Datasheet.objects.filter(validated = True, taggedsheet__tag__label__iexact = label, taggedsheet__order__lte = ROOT_MAX_TAG_ORDER).select_related('organisation').distinct()
     for datasheet in datasheets:
         # Calculating where we add the datasheet in the tree
         maintag = None
@@ -170,7 +170,8 @@
                 'url': datasheet.url,
                 'description': datasheet.description,
                 'hda_id': datasheet.hda_id,
-                'score': (dsscore + rootscore)
+                'organization': datasheet.organisation.name,
+                'score': max(dsscore, rootscore)
             })
     cleantags(resobj)