# HG changeset patch # User ymh # Date 1308879065 -7200 # Node ID e70cbbc093ccece0d44876d59571842ca3b992ad # Parent e1098febb9d30d986d3ad50f5a8c678e7bc63654 improve tag letter list diff -r e1098febb9d3 -r e70cbbc093cc virtualenv/res/src/django-debug-toolbar.tar.gz Binary file virtualenv/res/src/django-debug-toolbar.tar.gz has changed diff -r e1098febb9d3 -r e70cbbc093cc web/hdabo/settings.py --- a/web/hdabo/settings.py Thu Jun 23 16:00:38 2011 +0200 +++ b/web/hdabo/settings.py Fri Jun 24 03:31:05 2011 +0200 @@ -111,16 +111,8 @@ 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', - #django-debug-toolbar - 'debug_toolbar.middleware.DebugToolbarMiddleware', ) -#django-debug-toolbar -INTERNAL_IPS = ('127.0.0.1','localhost',) -DEBUG_TOOLBAR_CONFIG = { - 'SHOW_TOOLBAR_CALLBACK': lambda(req): True, -} - ROOT_URLCONF = 'hdabo.urls' @@ -141,8 +133,6 @@ 'django_extensions', 'haystack', 'hdabo', - #django-debug-toolbar - 'debug_toolbar', ) # A sample logging configuration. The only tangible logging diff -r e1098febb9d3 -r e70cbbc093cc web/hdabo/static/hdabo/img/favicon.ico Binary file web/hdabo/static/hdabo/img/favicon.ico has changed diff -r e1098febb9d3 -r e70cbbc093cc web/hdabo/static/hdabo/js/hdabo.js --- a/web/hdabo/static/hdabo/js/hdabo.js Thu Jun 23 16:00:38 2011 +0200 +++ b/web/hdabo/static/hdabo/js/hdabo.js Fri Jun 24 03:31:05 2011 +0200 @@ -123,7 +123,7 @@ onDragClass: "dragged_row", onDrop: function(table, row){ old_order = row.id; - $($(row).children()[1]).html(""); + $($(row).children()[1]).html(""); rows = table.tBodies[0].rows; nb_rows = rows.length; for(var i=1; i - {% endblock %} {% block js_declaration %} diff -r e1098febb9d3 -r e70cbbc093cc web/hdabo/templates/partial/one_sheet.html --- a/web/hdabo/templates/partial/one_sheet.html Thu Jun 23 16:00:38 2011 +0200 +++ b/web/hdabo/templates/partial/one_sheet.html Fri Jun 24 03:31:05 2011 +0200 @@ -22,10 +22,10 @@

En cours Validé {% if ds.validated %} -    par {{ds.validator}} le {{ds.validation_date|date:"d/m/Y"}} +    par {{ds.validator.username}} le {{ds.validation_date|date:"d/m/Y"}} {% endif %} {% if valid != "2" %} - Ajouter un tag : OK + Ajouter un tag : OK {% endif %}

{% csrf_token %} diff -r e1098febb9d3 -r e70cbbc093cc web/hdabo/utils.py --- a/web/hdabo/utils.py Thu Jun 23 16:00:38 2011 +0200 +++ b/web/hdabo/utils.py Fri Jun 24 03:31:05 2011 +0200 @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import collections +import unicodedata ### @@ -318,7 +319,7 @@ ''' if isinstance(other, OrderedDict): - return len(self)==len(other) and self.items() == other.items() + return len(self) == len(other) and self.items() == other.items() return dict.__eq__(self, other) def __ne__(self, other): @@ -339,3 +340,6 @@ return ItemsView(self) ## end of http://code.activestate.com/recipes/576693/ }}} +def remove_accents(str): + nkfd_form = unicodedata.normalize('NFKD', unicode(str)) + return u"".join([c for c in nkfd_form if not unicodedata.combining(c)]) diff -r e1098febb9d3 -r e70cbbc093cc web/hdabo/views.py --- a/web/hdabo/views.py Thu Jun 23 16:00:38 2011 +0200 +++ b/web/hdabo/views.py Fri Jun 24 03:31:05 2011 +0200 @@ -3,6 +3,7 @@ from django.conf import settings from django.contrib.auth.decorators import login_required #@UnusedImport from django.core.paginator import Paginator +from django.db import connection from django.db.models import Max, Count from django.http import HttpResponseBadRequest from django.shortcuts import render_to_response, redirect @@ -10,7 +11,7 @@ from django.utils.http import urlquote from haystack.constants import DJANGO_ID from haystack.query import SearchQuerySet -from hdabo.utils import OrderedDict +from hdabo.utils import OrderedDict, remove_accents from hdabo.wp_utils import (normalize_tag, query_wikipedia_title, get_or_create_tag, process_tag) from models import Datasheet, Organisation, Tag, TagCategory, TaggedSheet @@ -23,22 +24,17 @@ #@login_required def home(request): - # Get all organizations - #ds_queryset = Datasheet.objects.filter(organisation="hdabo_organisation.id") - - orgas = Organisation.objects.all()\ - .order_by('name').annotate(nb_all=Count("datasheet"))\ - .extra(select={ - 'nb_val':"SELECT COUNT(*) FROM hdabo_datasheet WHERE hdabo_datasheet.validated=true and hdabo_datasheet.organisation_id=hdabo_organisation.id", - 'nb_unval':"SELECT COUNT(*) FROM hdabo_datasheet WHERE hdabo_datasheet.validated=false and hdabo_datasheet.organisation_id=hdabo_organisation.id", - }) - # Count all validated, unvalidated sheets for each organisation + orgas = Organisation.objects.all().order_by('name') + org_list = [] + all_ds_mapping = dict([(res['organisation'],res['nb_all']) for res in Datasheet.objects.values("organisation").annotate(nb_all=Count("organisation"))]) + validated_ds_mapping = dict([(res['organisation'],res['nb_val']) for res in Datasheet.objects.filter(validated=True).values("organisation").annotate(nb_val=Count("organisation"))]) + unvalidated_ds_mapping = dict([(res['organisation'],res['nb_unval']) for res in Datasheet.objects.filter(validated=False).values("organisation").annotate(nb_unval=Count("organisation"))]) + for orga in orgas : - #all_datasheets = Datasheet.objects.filter(organisation=orga) - nb_all = orga.nb_all#len(all_datasheets) - nb_val = orga.nb_val#len(all_datasheets.filter(validated=True)) - nb_unval = orga.nb_unval#len(all_datasheets.filter(validated=False)) + nb_all = all_ds_mapping.get(orga.id,0) + nb_val = validated_ds_mapping.get(orga.id,0) + nb_unval = unvalidated_ds_mapping.get(orga.id,0) org_list.append({'organisation':orga, 'nb_all':nb_all, 'nb_val':nb_val, 'nb_unval':nb_unval}) return render_to_response("organisation_list.html", @@ -115,8 +111,21 @@ prev_page = max(num_page - 1, 1) next_page = min(num_page + 1, p.num_pages) last_page = p.num_pages - - search_def = tuple([(c,urlquote(c + settings.SEARCH_STAR_CHARACTER)) for c in '01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ']) + + + cursor = connection.cursor() #@UndefinedVariable + fl_list = [] + try: + cursor.execute("select upper(substring(label from 1 for 1)) as fl from hdabo_tag group by fl order by fl;") + + for row in cursor: + new_char = remove_accents(row[0]) + if new_char not in fl_list: + fl_list.append(new_char) + finally: + cursor.close() + + search_def = tuple([(c,urlquote(c + settings.SEARCH_STAR_CHARACTER)) for c in fl_list]) return render_to_response("all_tags.html", {'nb_total':p.count, 'tags':current_page.object_list, 'current_page':current_page,