# HG changeset patch # User cavaliet # Date 1403262639 -7200 # Node ID 177b508612f4fefc05ba6468e9be25178b031412 # Parent e8855ddc18512544759743fbf4fc38d3794058d3 add, configure and correct hdalab to installed apps diff -r e8855ddc1851 -r 177b508612f4 src/hdabo/django_wsgi.py --- a/src/hdabo/django_wsgi.py Thu Jun 19 12:47:41 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -import os - -os.environ['DJANGO_SETTINGS_MODULE'] = 'spel.settings' - -import django.core.handlers.wsgi - -application = django.core.handlers.wsgi.WSGIHandler() - -if os.environ.get('PYDEV_DEBUG', "False").lower() in ["true", "1", "t"]: - import pydevd #@UnresolvedImport - pydevd.settrace(suspend=False) diff -r e8855ddc1851 -r 177b508612f4 src/hdabo/settings.py --- a/src/hdabo/settings.py Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdabo/settings.py Fri Jun 20 13:10:39 2014 +0200 @@ -106,6 +106,7 @@ 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.locale.LocaleMiddleware', ) ROOT_URLCONF = 'hdabo.urls' @@ -128,8 +129,19 @@ 'django_extensions', 'haystack', 'hdabo', + 'hdalab', ) +ugettext = lambda s:s +LANGUAGES = ( + ('fr', ugettext('French')), + ('en', ugettext('English')), + ('it', ugettext('Italian')), + ('de', ugettext('German')), + ('es', ugettext('Spanish')), + ('ja', ugettext('Japanese')), + #('zh-tw', ugettext('Chinese')), +) WIKIPEDIA_API_URL = "http://fr.wikipedia.org/w/api.php" WIKIPEDIA_VERSION_PERMALINK_TEMPLATE = "http://fr.wikipedia.org/w/index.php?oldid=%s" diff -r e8855ddc1851 -r 177b508612f4 src/hdabo/urls.py --- a/src/hdabo/urls.py Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdabo/urls.py Fri Jun 20 13:10:39 2014 +0200 @@ -3,6 +3,7 @@ from django.contrib.auth import urls as auth_url from django.contrib.auth.decorators import login_required from .views import AddOrUpdateFolder, Folders, SearchDatasheet, DeleteFolder +from hdalab import urls as hdalab_url # Uncomment the next two lines to enable the admin: @@ -52,4 +53,5 @@ url(r'^folder/(?P[\w-]+)$', login_required(AddOrUpdateFolder.as_view()), name='add_or_update_folder'), url(r'^searchajax/$', login_required(SearchDatasheet()), name='searchajax'), url(r'^deletefolder/(?P[\w-]+)$', login_required(DeleteFolder.as_view()), name='delete_folder'), + url(r'^hdalab/', include(hdalab_url)), ) diff -r e8855ddc1851 -r 177b508612f4 src/hdalab/django_wsgi.py --- a/src/hdalab/django_wsgi.py Thu Jun 19 12:47:41 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -import os - -os.environ['DJANGO_SETTINGS_MODULE'] = 'hdalab.settings' - -import django.core.handlers.wsgi - -application = django.core.handlers.wsgi.WSGIHandler() - -if os.environ.get('PYDEV_DEBUG', "False").lower() in ["true", "1", "t"]: - import pydevd #@UnresolvedImport - pydevd.settrace(suspend=False) diff -r e8855ddc1851 -r 177b508612f4 src/hdalab/management/commands/query_dbpedia.py --- a/src/hdalab/management/commands/query_dbpedia.py Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdalab/management/commands/query_dbpedia.py Fri Jun 20 13:10:39 2014 +0200 @@ -195,7 +195,10 @@ except Exception as e: - print "\nError processing resource %s : %s" %(rdf_uri,unicode(e)) + if tag.dbpedia_uri: + print "\nError processing resource %s : %s" %(tag.dbpedia_uri,unicode(e)) + else: + print "\nError processing resource %s" % unicode(e) traceback.print_exception(type(e), e, sys.exc_info()[2]) diff -r e8855ddc1851 -r 177b508612f4 src/hdalab/models/dataviz.py --- a/src/hdalab/models/dataviz.py Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdalab/models/dataviz.py Fri Jun 20 13:10:39 2014 +0200 @@ -28,7 +28,7 @@ class Country(models.Model): - dbpedia_uri = models.URLField(verify_exists=False, max_length=255, blank=False, null=False, db_index=True, unique=True) + dbpedia_uri = models.URLField(max_length=255, blank=False, null=False, db_index=True, unique=True) class Meta: app_label = 'hdalab' @@ -43,10 +43,10 @@ class DbpediaFields(models.Model): - dbpedia_uri = models.URLField(verify_exists=False, max_length=2048, blank=False, null=False, db_index=True, unique=False) + dbpedia_uri = models.URLField(max_length=2048, blank=False, null=False, db_index=True, unique=False) tag = models.OneToOneField(Tag, blank=True, null=True, db_index=True, related_name="dbpedia_fields") abstract = models.TextField(blank=True, null=True) - thumbnail = models.URLField(verify_exists=False, max_length=2048, blank=True, null=True, db_index=False) + thumbnail = models.URLField(max_length=2048, blank=True, null=True, db_index=False) label = models.CharField(max_length=2048, unique=False, blank=True, null=True) class Meta: diff -r e8855ddc1851 -r 177b508612f4 src/hdalab/modwsgi.wsgi --- a/src/hdalab/modwsgi.wsgi Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdalab/modwsgi.wsgi Fri Jun 20 13:10:39 2014 +0200 @@ -1,22 +1,18 @@ -import os -import sys -import site - - +import os, sys, site def application(environ, start_response): global g_env_set if 'g_env_set' not in globals() or not g_env_set: - os.environ['DJANGO_SETTINGS_MODULE'] = environ['DJANGO_SETTINGS_MODULE'] + os.environ.setdefault('DJANGO_SETTINGS_MODULE',environ['DJANGO_SETTINGS_MODULE']) prev_sys_path = list(sys.path) sys.path.append(environ['PROJECT_PATH']) - for path in environ.get('PYTHON_PATH', "").split(os.pathsep): + for path in environ.get('PYTHON_PATH',"").split(os.pathsep): if path: - site.addsitedir(path) #@UndefinedVariable + site.addsitedir(path) new_sys_path = [] for item in list(sys.path): @@ -29,7 +25,7 @@ import django.core.handlers.wsgi _application = django.core.handlers.wsgi.WSGIHandler() - + if environ.get('PYDEV_DEBUG', "False").lower() in ["true", "1", "t"]: import pydevd #@UnresolvedImport pydevd.settrace(suspend=False) diff -r e8855ddc1851 -r 177b508612f4 src/hdalab/templates/base.html --- a/src/hdalab/templates/base.html Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdalab/templates/base.html Fri Jun 20 13:10:39 2014 +0200 @@ -1,4 +1,5 @@ {% load analytics %} +{% load static %} @@ -7,15 +8,15 @@ - + {% block title %}HdA Lab{% endblock %} {% block css_import %} - + {% endblock %} {% block js_import %} - + {% endblock %} @@ -24,15 +25,15 @@ {% block header %}
@@ -51,12 +52,12 @@
  • - +
  • - +
  • diff -r e8855ddc1851 -r 177b508612f4 src/hdalab/templates/categories.html --- a/src/hdalab/templates/categories.html Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdalab/templates/categories.html Fri Jun 20 13:10:39 2014 +0200 @@ -1,29 +1,30 @@ {% extends "base.html" %} +{% load static %} {% block title %}{{block.super}} > Recherche par arbre{% endblock %} {% block css_import %} {{block.super}} - - - + + + {% endblock %} {% block js_import %} {{block.super}} - - - + + + - - + + {% endblock %} {% block categories_actif %}actif{% endblock %} diff -r e8855ddc1851 -r 177b508612f4 src/hdalab/templates/facettes.html --- a/src/hdalab/templates/facettes.html Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdalab/templates/facettes.html Fri Jun 20 13:10:39 2014 +0200 @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load static %} {% load i18n %} @@ -6,30 +7,30 @@ {% block css_import %} {{block.super}} - - - + + + {% endblock %} {% block js_import %} {{block.super}} - - - - - + + + + + - - + + @@ -43,7 +44,7 @@
    -
    + {% csrf_token %} {% get_language_info_list for LANGUAGES as languages %} diff -r e8855ddc1851 -r 177b508612f4 src/hdalab/templates/index.html --- a/src/hdalab/templates/index.html Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdalab/templates/index.html Fri Jun 20 13:10:39 2014 +0200 @@ -1,10 +1,11 @@ {% extends "base.html" %} +{% load static %} {% block title %}{{block.super}} > Accueil{% endblock %} {% block css_import %} {{block.super}} - + {% endblock %} {% block js_import %} @@ -39,7 +40,7 @@

    Recherchez les contenus d'Histoire des Arts par plusieurs points d'entrée : pays, périodes historiques, disciplines artistiques et mots-clés liés aux œvres.

    Les éléments de l'interface sont à la fois des critères de recherche et des mode de visualisation des résultats : Au fur et à mesure de vos recherches, ils se mettent à jour pour refléter le nombre de contenus correspondant.

    -

    »

    +

    »

    @@ -51,7 +52,7 @@

    Naviguez dans l'arbre des catégories de Wikipedia pour atteindre les contenus du portail Histoire des Arts.

    Recherchez une catégorie par son titre, puis explorez les sous-catégories et les tags qui y sont rattachés.

    -

    »

    +

    »

    @@ -66,7 +67,7 @@
  • La branche « Secteur urbain » du Thésaurus de l’architecture et de l’urbanisme (état 2010)
  • La branche « Architecture d’habitation » du Thésaurus iconographique Garnier (état 2012)
  • -

    »

    +

    »

    @@ -89,14 +90,14 @@ diff -r e8855ddc1851 -r 177b508612f4 src/hdalab/templates/notice.html --- a/src/hdalab/templates/notice.html Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdalab/templates/notice.html Fri Jun 20 13:10:39 2014 +0200 @@ -1,16 +1,17 @@ {% extends "base.html" %} +{% load static %} {% block title %}{{block.super}} > {{datasheet.title}}{% endblock %} {% block css_import %} {{block.super}} - + {% endblock %} {% block js_import %} {{block.super}} - - + + {% endblock %} {% block main_content %} @@ -43,7 +44,7 @@ {% for ds in related %}
  • -

    {{ds.title}}

    +

    {{ds.title}}

    {{ds.organisation_name}}

      {% for t in ds.ordered_tags %}{% endfor %}
  • diff -r e8855ddc1851 -r 177b508612f4 src/hdalab/templates/thesaurus.html --- a/src/hdalab/templates/thesaurus.html Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdalab/templates/thesaurus.html Fri Jun 20 13:10:39 2014 +0200 @@ -1,27 +1,28 @@ {% extends "base.html" %} +{% load static %} {% block title %}{{block.super}} > Recherche par arbre{% endblock %} {% block css_import %} {{block.super}} - - - + + + {% endblock %} {% block js_import %} {{block.super}} - - - + + + - - + + {% endblock %} {% block thesaurus_actif %}actif{% endblock %} diff -r e8855ddc1851 -r 177b508612f4 src/hdalab/urls.py --- a/src/hdalab/urls.py Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdalab/urls.py Fri Jun 20 13:10:39 2014 +0200 @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -from django.conf.urls.defaults import patterns, include, url -from django.contrib import admin +from django.conf.urls import patterns, include, url from django.views.generic import TemplateView #from hdalab.views.ajax import filter @@ -17,7 +16,7 @@ # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: - url(r'^admin/', include(admin.site.urls)), + #url(r'^admin/', include(admin.site.urls)), url(r'^i18n/', include('django.conf.urls.i18n')), url('^jsi18n/?$', 'django.views.i18n.javascript_catalog', name='jsi18n.all'), diff -r e8855ddc1851 -r 177b508612f4 src/hdalab/views/ajax.py --- a/src/hdalab/views/ajax.py Thu Jun 19 12:47:41 2014 +0200 +++ b/src/hdalab/views/ajax.py Fri Jun 20 13:10:39 2014 +0200 @@ -19,6 +19,9 @@ import itertools import uuid +import logging +logger = logging.getLogger(__name__) + def tagtranslation(request): lang = request.GET.get('lang',request.LANGUAGE_CODE) @@ -350,16 +353,22 @@ translations = {} + logger.debug("ICI 0") if lang not in no_translate_langs: - transqs = DbpediaFieldsTranslation.objects.filter(master__in = [ts.tag.dbpedia_fields for ts in qs], language_code = lang) + ts_list = [] + for ts in qs: + if hasattr(ts, 'tag') and hasattr(ts.tag, 'dbpedia_fields') : + ts_list.append(ts.tag.dbpedia_fields) + transqs = DbpediaFieldsTranslation.objects.filter(master__in = ts_list, language_code = lang) translations = dict([(trans.master_id,trans.label) for trans in transqs]) for ts in qs: - match_tag = ts.tag.id in matchtagids - contenus[ts.datasheet_id]['tags'].append({'id': ts.tag.id, 'label':ts.tag.label, 'order':ts.order, 'match': match_tag , 'translated_label': translations.get(ts.tag.dbpedia_fields.id, ts.tag.label) if ts.tag.dbpedia_fields is not None else ts.tag.label}) - - if match_tag: - contenus[ts.datasheet_id]['score'] += 2*max_tag_order - ts.order + if hasattr(ts, 'tag') and hasattr(ts.tag, 'dbpedia_fields') : + match_tag = ts.tag.id in matchtagids + contenus[ts.datasheet_id]['tags'].append({'id': ts.tag.id, 'label':ts.tag.label, 'order':ts.order, 'match': match_tag , 'translated_label': translations.get(ts.tag.dbpedia_fields.id, ts.tag.label) if ts.tag.dbpedia_fields is not None else ts.tag.label}) + + if match_tag: + contenus[ts.datasheet_id]['score'] += 2*max_tag_order - ts.order if contentlist is None: contenus = sorted(contenus.values(),key=lambda e: -e['score'])