add link to joconde search. Add option to import
--- a/sbin/sync/config.py.tmpl Sat Jun 15 16:21:02 2013 +0200
+++ b/sbin/sync/config.py.tmpl Sun Jun 16 01:03:40 2013 +0200
@@ -47,8 +47,8 @@
env.config = {
'web': {
- 'base_url': "/",
- 'web_url': 'http://labs.iri-resesarch.org/jocondelab',
+ 'base_url': "/jocondelab/",
+ 'web_url': 'http://labs.iri-resesarch.org',
'db_engine':'postgresql_psycopg2',
'db_name':'jocondelab',
'db_user': 'iriuser',
--- a/src/core/wp_utils.py Sat Jun 15 16:21:02 2013 +0200
+++ b/src/core/wp_utils.py Sun Jun 16 01:03:40 2013 +0200
@@ -130,7 +130,7 @@
-def get_or_create_term(term_label, term_uri, term_lang, thesaurus, wp_label_transform=(lambda l:l)):
+def get_or_create_term(term_label, term_uri, term_lang, thesaurus, wp_label_transform=(lambda l:l), skip_wp_query=False):
term_label_normalized = normalize_term(term_label)
# We get the wikipedia references for the tag_label
@@ -161,7 +161,7 @@
term_label_obj = TermLabel(label=term_label, term=term, lang=term_lang)
term_label_obj.save()
- elif term.wikipedia_pageid:
+ elif term.wikipedia_pageid and not skip_wp_query:
wp_res = query_wikipedia_title(site, pageid=term.wikipedia_pageid)
wikipedia_revision_id = wp_res['revision_id']
term.wikipedia_revision_id = wikipedia_revision_id
--- a/src/jocondelab/management/commands/import_terms.py Sat Jun 15 16:21:02 2013 +0200
+++ b/src/jocondelab/management/commands/import_terms.py Sun Jun 16 01:03:40 2013 +0200
@@ -48,12 +48,20 @@
default= 50,
help= 'number of object to import in bulk operations'
),
+ make_option('-s','--skip-wp',
+ dest= 'skip_wp_query',
+ action= 'store_true',
+ default= False,
+ help= 'skip wikipedia query'
+ ),
+
)
def handle_noargs(self, **options):
batch_size = options.get('batch_size', 50)
+ skip_wp_query = options.get('skip_wp_query', False)
transaction.enter_transaction_management()
transaction.managed()
@@ -83,7 +91,8 @@
term_uri=unicode(s),
term_lang=lang,
thesaurus = thes,
- wp_label_transform = THESAURUS_LABEL_TRANSFORM.get(thes.label,lambda l:l)
+ wp_label_transform = THESAURUS_LABEL_TRANSFORM.get(thes.label,lambda l:l),
+ skip_wp_query=skip_wp_query
)
if not ((i+1) % batch_size):
@@ -91,7 +100,7 @@
transaction.commit()
for i,(s,_,o) in enumerate(graph.triples((None, URIRef("http://www.w3.org/2004/02/skos/core#altLabel"), None), context=context)):
- self.stdout.write("%d - Thesaurus %s term alt label %s" % (i+1, thes.label, repr(o)))
+ self.stdout.write("%d - Thesaurus %s term alt label %s for %s" % (i+1, thes.label, repr(o), repr(s)))
try:
term = Term.objects.get(uri=unicode(s))
alt_label = unicode(o).strip()
@@ -99,7 +108,7 @@
if not TermLabel.objects.filter(label=alt_label, term=term).exists():
TermLabel.objects.create(label=alt_label, term=term, lang=lang)
except Term.DoesNotExist:
- self.stdout.write("Thesaurus %s term alt label %s doe not exists",(thes.label, o))
+ self.stdout.write("Thesaurus %s term alt label %s for %s does not exists" % (thes.label, repr(o), repr(s)))
if not ((i+1) % batch_size):
transaction.commit()
Binary file src/jocondelab/static/jocondelab/img/red_cross_disabled.png has changed
--- a/src/jocondelab/templates/jocondelab/term_edit.html Sat Jun 15 16:21:02 2013 +0200
+++ b/src/jocondelab/templates/jocondelab/term_edit.html Sun Jun 16 01:03:40 2013 +0200
@@ -1,5 +1,5 @@
{% extends "jocondelab/base.html" %}
-
+{% load i18n %}
{% block js_import %}
{{block.super}}
<script type="text/javascript" src="{{STATIC_URL}}jocondelab/lib/jquery-ui.min.js"></script>
@@ -79,13 +79,24 @@
</td>
<td class="text_centered">
{% if term.wikipedia_url and term.wikipedia_url != "" %}
- <img src="{{STATIC_URL}}jocondelab/img/red_cross.png" class="remove_wp_link" id="{{term.id}}" alt="{{term.label}}" />
+ {% if term.validated %}
+ <img src="{{STATIC_URL}}jocondelab/img/red_cross_disabled.png" class="remove_wp_link_disabled" id="{{term.id}}" alt="{{term.label}}" />
+ {% else %}
+ <img src="{{STATIC_URL}}jocondelab/img/red_cross.png" class="remove_wp_link" id="{{term.id}}" alt="{{term.label}}" />
+ {% endif %}
{% else %}
{% endif %}
</td>
<td class="text_centered">
- <span>Ajouter un tag : <input type="text" name="wp_search" id="wp_search" size="35" /> <span id="ok_search" class="hand_cursor"><b>OK</b></span></span>
+ {% if term.validated %}
+ <span>{% trans "Select Wikipedia page" %} : <input type="text" name="wp_search" id="wp_search" size="35" disabled="disabled" /> <span id="ok_search_disabled" class="hand_cursor_disabled"><b>OK</b></span></span>
+ {% else %}
+ <span>{% trans "Select Wikipedia page" %} : <input type="text" name="wp_search" id="wp_search" size="35" /> <span id="ok_search" class="hand_cursor"><b>OK</b></span></span>
+ {% endif %}
+ </td>
+ <td class="text_centered">
+ <a href='http://www.culture.gouv.fr/public/mistral/joconde_fr?FIELD_1={{term.thesaurus.label}}&VALUE_1={{term.label|urlencode:""}}&ACTION=CHERCHER' target="_blank">Recherche joconde</a>
</td>
</tr>
</table>