--- a/src/jocondelab/management/commands/import_extra_years.py Thu Sep 19 18:14:01 2013 +0200
+++ b/src/jocondelab/management/commands/import_extra_years.py Tue Sep 24 10:45:54 2013 +0200
@@ -28,13 +28,20 @@
reader = csv.DictReader(csv_file, dialect=dialect)
for i,row in enumerate(reader):
print row
- dbpedia_uri = row['dbpedia_uri']
- start_year = int(row['start_year'])
- end_year = int(row['end_year'])
- ts = Term.objects.filter(dbpedia_uri = dbpedia_uri)
- for t in ts:
- dyobj, created = DbpediaYears.objects.get_or_create(term=t, defaults={'start_year': start_year, 'end_year': end_year})
- if not created:
- dyobj.start_year = start_year
- dyobj.end_year = end_year
- dyobj.save()
\ No newline at end of file
+ if row.get('start_year', None) is not None and row.get('end_year', None) is not None:
+ start_year = int(row['start_year'])
+ end_year = int(row['end_year'])
+ dbpedia_uri = row.get('dbpedia_uri',None)
+ term_label = row.get('term_label',None)
+ ts = None
+ if dbpedia_uri is not None:
+ ts = Term.objects.filter(dbpedia_uri = dbpedia_uri)
+ elif term_label is not None:
+ ts = Term.objects.filter(label = term_label)
+ if ts is not None:
+ for t in ts:
+ dyobj, created = DbpediaYears.objects.get_or_create(term=t, defaults={'start_year': start_year, 'end_year': end_year})
+ if not created:
+ dyobj.start_year = start_year
+ dyobj.end_year = end_year
+ dyobj.save()
\ No newline at end of file
--- a/src/jocondelab/models/contribution.py Thu Sep 19 18:14:01 2013 +0200
+++ b/src/jocondelab/models/contribution.py Tue Sep 24 10:45:54 2013 +0200
@@ -45,7 +45,7 @@
app_label = 'jocondelab'
def __unicode__(self):
- return u'%s, %s'%((self.notice.titr or self.notice.deno),self.term.dbpedia_uri)
+ return u'%s, %s, %s'%((self.notice.titr or self.notice.deno),self.term.dbpedia_uri,(self.thesaurus.label if self.thesaurus else "Folksonomy"))
class ContributableTerm(models.Model):
--- a/src/jocondelab/static/jocondelab/css/front-notice.css Thu Sep 19 18:14:01 2013 +0200
+++ b/src/jocondelab/static/jocondelab/css/front-notice.css Tue Sep 24 10:45:54 2013 +0200
@@ -82,7 +82,15 @@
}
.contribution-frame {
- margin: 10px 0; background: #ffe8c0; padding: 10px;
+ margin: 10px 0; padding: 10px;
+}
+
+.folksonomy-frame {
+ background: #ffe8c0;
+}
+
+.description-frame {
+ background: #f0f8ff;
}
.contribution-frame h2 {
@@ -102,11 +110,15 @@
}
.contribution-upvote, .contribution-downvote {
- display: block; background: url(../img/vote-sprite.png); width: 11px; height: 6px;
+ display: block; background-image: url(../img/vote-sprite.png); width: 11px; height: 6px;
+}
+
+.contribution-upvote {
+ margin-bottom: 2px;
}
.contribution-downvote {
- background-position: 0 -6px; margin-top: 2px;
+ background-position: 0 -6px;
}
.contribution-upvote:hover {
@@ -116,3 +128,28 @@
.contribution-downvote:hover {
background-position: -11px -6px;
}
+
+.contribution-novote .contribution-upvote {
+ display: none;
+}
+
+.contribution-novote .contribution-downvote {
+ background-image: none; height: 16px; line-height: 16px; font-size: 12px; font-weight: bold; text-align: right;
+}
+
+.contribution-novote .contribution-downvote:before {
+ content: "×";
+}
+
+.button-links {
+ text-align: right; margin: 5px 0;
+}
+
+.button-links a {
+ color: #ffffff; font-size: 14px; font-weight: bold; padding: 4px 6px;
+ background: #202060; border-radius: 6px;
+}
+
+.button-links a:hover {
+ background: #404080;
+}
--- a/src/jocondelab/static/jocondelab/js/front-common.js Thu Sep 19 18:14:01 2013 +0200
+++ b/src/jocondelab/static/jocondelab/js/front-common.js Tue Sep 24 10:45:54 2013 +0200
@@ -228,7 +228,7 @@
show: showDbpediaBox,
setAnchor: setDbpediaBoxAnchor,
recentre: recentreDbpediaBox
- }
+ };
/* END DBPEDIA OVERLAY MANAGEMENT */
@@ -333,7 +333,7 @@
});
bindDbpediaBox($items.find(".notice-term a"));
adaptGrid();
- }
+ };
/* END NOTICE LIST MANAGEMENT */
@@ -374,7 +374,7 @@
});
}
});
- }
+ };
window.loadSearchResults = function(query) {
$(".hide-on-search").hide();
@@ -392,7 +392,7 @@
scrollLoad(query);
}
});
- }
+ };
/* */
--- a/src/jocondelab/static/jocondelab/js/front-geo.js Thu Sep 19 18:14:01 2013 +0200
+++ b/src/jocondelab/static/jocondelab/js/front-geo.js Tue Sep 24 10:45:54 2013 +0200
@@ -61,7 +61,7 @@
if (c.layer) {
c.layer.setStyle({weight: 1, color: "#000080", opacity: .3});
}
- })
+ });
stickyFeature = feature;
showDbpedia(feature);
loadSearchResults({ dbpedia_uri: feature.dbpedia_uri });
@@ -140,7 +140,7 @@
coord.latlng = L.latLng(coord.latitude, coord.longitude);
coord.marker = L.marker(coord.latlng).addTo(map);
coord.marker.on("click", function() { selectMarker(coord); });
- coord.marker.on("mouseover", function() { showDbpedia(coord) });
+ coord.marker.on("mouseover", function() { showDbpedia(coord); });
coord.marker.on("mouseout", function() { hideDbpedia(); });
}
}
@@ -169,7 +169,7 @@
var gjs = L.geoJson(null, {
style: function(f) {
- f.dbCountry = _(countries).find(function(c) { return c.iso_code_3 === f.id });
+ f.dbCountry = _(countries).find(function(c) { return c.iso_code_3 === f.id; });
var styleobj = { weight: 1, color: "#000080", opacity: .3 };
if (f.dbCountry && f.dbCountry.nb_notices) {
var x = Math.min(1, Math.max(0, Math.log(f.dbCountry.nb_notices) / scaleBase)),
@@ -185,7 +185,7 @@
},
onEachFeature: function(f, l) {
if (f.dbCountry) {
- f.dbCountry.bounds = l.getBounds()
+ f.dbCountry.bounds = l.getBounds();
f.dbCountry.latlng = f.dbCountry.bounds.getCenter();
f.dbCountry.layer = l;
l.on("click", function() { selectCountry(f.dbCountry); });
@@ -205,7 +205,7 @@
debouncedGetData();
- map.on("move", throttledMove)
+ map.on("move", throttledMove);
map.on("moveend", debouncedGetData);
var blockUnsticking = false;
--- a/src/jocondelab/static/jocondelab/js/front-notice.js Thu Sep 19 18:14:01 2013 +0200
+++ b/src/jocondelab/static/jocondelab/js/front-notice.js Tue Sep 24 10:45:54 2013 +0200
@@ -193,7 +193,7 @@
}
var tmpTemplate = '<li class="notice-term term-translated"></li>',
- $ntl = $(".notice-term-list");
+ $ntl = $(".notice-contribution-list");
$(".notice-contribution-field").autocomplete({
source: function( request, response ) {
@@ -248,7 +248,8 @@
notice_id: notice_id,
dbpedia_language: termdata.dbpedia_language,
dbpedia_uri: termdata.dbpedia_uri,
- translations: JSON.stringify(termdata.translations)
+ translations: JSON.stringify(termdata.translations),
+ thesaurus_label: $this.attr("data-thesaurus-label")
},
success: function(html) {
var $el = $(html),
@@ -264,7 +265,7 @@
error: function() {
$tmpItem.remove();
}
- })
+ });
} else {
$tmpItem.remove();
alert(gettext("No DbPedia resource found for term") + " " + ui.item.label);
@@ -284,6 +285,7 @@
$(".notice-contribution-list").on("click",".contribution-upvote, .contribution-downvote", function() {
var $this = $(this),
$li = $(this).parents("li"),
+ $list = $li.parent(),
endpoint = urls[$this.hasClass("contribution-upvote") ? "upvote" : "downvote"];
$.ajax({
url: endpoint,
@@ -294,7 +296,12 @@
contribution_id: $li.attr("data-contribution-id"),
},
success: function(html) {
- $li.replaceWith($(html));
+ if ($list.hasClass("contribution-novote")) {
+ $li.hide();
+ } else {
+ $li.replaceWith($(html));
+ }
+
}
});
return false;
--- a/src/jocondelab/static/jocondelab/js/front-termlist.js Thu Sep 19 18:14:01 2013 +0200
+++ b/src/jocondelab/static/jocondelab/js/front-termlist.js Tue Sep 24 10:45:54 2013 +0200
@@ -15,7 +15,7 @@
return false;
});
}
- })
+ });
}
$tt.click(function() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jocondelab/templates/jocondelab/front_about.html Tue Sep 24 10:45:54 2013 +0200
@@ -0,0 +1,12 @@
+{% extends "jocondelab/front_base.html" %}
+{% load i18n %}
+
+{% block title %}JocondeLab » {% trans 'À propos' %}{% endblock %}
+
+{% block breadcrumbs %}<a href="{% url 'front_about' %}">{% trans 'À propos' %}</a>{% endblock %}
+
+{% block main %}
+
+ <h2>{% trans 'À propos de JocondeLab' %}</h2>
+
+{% endblock %}
\ No newline at end of file
--- a/src/jocondelab/templates/jocondelab/front_base.html Thu Sep 19 18:14:01 2013 +0200
+++ b/src/jocondelab/templates/jocondelab/front_base.html Tue Sep 24 10:45:54 2013 +0200
@@ -75,6 +75,9 @@
<li class="menu-item">
<a href="{% url 'front_geo' %}">{% trans 'Mappemonde' %}</a>
</li>
+ <li class="menu-item">
+ <a href="{% url 'random_describe' %}">{% trans "Contribuer à l'iconographie" %}</a>
+ </li>
</ul>
<ul class="menu-list" id="language-menu">
{% get_language_info_list for LANGUAGES as languages %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jocondelab/templates/jocondelab/front_describe.html Tue Sep 24 10:45:54 2013 +0200
@@ -0,0 +1,13 @@
+{% extends "jocondelab/front_notice.html" %}
+{% load i18n %}
+
+{% block contribution %}
+ <div class="contribution-frame description-frame">
+ <h2>{% trans "Complétez l'iconographie" %}</h2>
+ <input class="notice-contribution-field" data-thesaurus-label="REPR" type="text" size="60" placeholder="{% trans 'Que voyez-vous dans cette oeuvre ?' %}" />
+ <ul class="notice-term-list notice-contribution-list contribution-novote"></ul>
+ <p class="button-links">
+ <a href="{% url 'random_describe' %}">{% trans 'Décrire une autre oeuvre' %}</a>
+ </p>
+ </div>
+{% endblock %}
--- a/src/jocondelab/templates/jocondelab/front_home.html Thu Sep 19 18:14:01 2013 +0200
+++ b/src/jocondelab/templates/jocondelab/front_home.html Tue Sep 24 10:45:54 2013 +0200
@@ -25,7 +25,10 @@
<h3><a href="{% url 'front_geo' %}">{% trans 'Mappemonde' %}</a></h3>
</li>
<li class="module-item">
- <h3><a href="{% url 'front_search' %}">{% trans 'À propos' %}</a></h3>
+ <h3><a href="{% url 'random_describe' %}">{% trans "Contribuer à l'iconographie" %}</a></h3>
+ </li>
+ <li class="module-item">
+ <h3><a href="{% url 'front_about' %}">{% trans 'À propos' %}</a></h3>
</li>
</ul>
</div>
--- a/src/jocondelab/templates/jocondelab/front_notice.html Thu Sep 19 18:14:01 2013 +0200
+++ b/src/jocondelab/templates/jocondelab/front_notice.html Tue Sep 24 10:45:54 2013 +0200
@@ -89,17 +89,21 @@
<p class="notice-jocondelink">
<a href="{{JOCONDE_NOTICE_BASE_URL}}{{ notice.ref }}" target="_blank">{% trans 'Visiter sur le portail Joconde' %}</a>
</p>
-
- <div class="contribution-frame">
- <h2>Contribution (Folksonomie)</h2>
+{% block contribution %}
+ <div class="contribution-frame folksonomy-frame">
+ <h2>{% trans 'Contribution (Folksonomie)' %}</h2>
<input class="notice-contribution-field" type="text" size="60" placeholder="{% trans 'Complétez les mots-clés de la fiche' %}" />
<ul class="notice-term-list notice-contribution-list">
{% for term in contributions %}
{% include "jocondelab/partial/contributed_item.html" %}
{% endfor %}
</ul>
+ <p class="button-links">
+ <a href="{% url 'front_describe' object.id %}">{% trans "Aidez-nous à approfondir l'iconographie" %}</a>
+ </p>
</div>
-
+{% endblock %}
+
</div>
</div>
{% endblock %}
--- a/src/jocondelab/urls.py Thu Sep 19 18:14:01 2013 +0200
+++ b/src/jocondelab/urls.py Tue Sep 24 10:45:54 2013 +0200
@@ -37,8 +37,11 @@
url(r'^search/$', SearchView.as_view(), name='front_search'),
url(r'^geo/$', GeoView.as_view(), name='front_geo'),
url(r'^timeline/$', TemplateView.as_view(template_name="jocondelab/front_timeline.html"), name='front_timeline'),
+ url(r'^about/$', TemplateView.as_view(template_name="jocondelab/front_about.html"), name='front_about'),
url(r'^notice/(?P<pk>\d+)/$', NoticeView.as_view(), name='front_notice'),
url(r'^notice/$', NoticeView.as_view(), name='random_notice'),
+ url(r'^describe/(?P<pk>\d+)/$', NoticeView.as_view(template_name="jocondelab/front_describe.html", show_contributions=False), name='front_describe'),
+ url(r'^describe/$', NoticeView.as_view(template_name="jocondelab/front_describe.html", show_contributions=False), name='random_describe'),
url(r'^ajax/terms/$', 'jocondelab.views.ajax.terms', name='ajax_terms'),
url(r'^ajax/years/$', 'jocondelab.views.ajax.years', name='ajax_years'),
url(r'^ajax/geocoords/$', 'jocondelab.views.ajax.geo_coords', name='ajax_geo_coords'),
--- a/src/jocondelab/views/front_office.py Thu Sep 19 18:14:01 2013 +0200
+++ b/src/jocondelab/views/front_office.py Tue Sep 24 10:45:54 2013 +0200
@@ -112,6 +112,7 @@
model = Notice
template_name = "jocondelab/front_notice.html"
+ show_contributions = True
def get_context_data(self, **kwargs):
@@ -136,18 +137,19 @@
"untranslated": []
}
termsbythesaurus[term["thesaurus"]]["translated" if term["translated"] else "untranslated"].append(term)
+ context["terms_by_thesaurus"] = termsbythesaurus
- cqs = self.object.contribution_set.select_related('term__dbpedia_fields')
- contributions = [{
- "label": ct.term.dbpedia_fields.get(language_code=lang).label,
- "dbpedia_uri": ct.term.dbpedia_uri,
- "contribution_id": ct.id,
- "li_style": "positive" if ct.contribution_count > 0 else "null",
- "font_size": "%.1f"%(12. + .5 * max(0., min(12., ct.contribution_count)))
- } for ct in cqs.filter(thesaurus=None,term__dbpedia_fields__language_code=lang).order_by('-contribution_count')]
-
- context["terms_by_thesaurus"] = termsbythesaurus
- context["contributions"] = contributions
+ if self.show_contributions:
+ cqs = self.object.contribution_set.select_related('term__dbpedia_fields')
+ contributions = [{
+ "label": ct.term.dbpedia_fields.get(language_code=lang).label,
+ "dbpedia_uri": ct.term.dbpedia_uri,
+ "contribution_id": ct.id,
+ "li_style": "positive" if ct.contribution_count > 0 else "null",
+ "font_size": "%.1f"%(12. + .5 * max(0., min(12., ct.contribution_count)))
+ } for ct in cqs.filter(thesaurus=None,term__dbpedia_fields__language_code=lang).order_by('-contribution_count')]
+ context["contributions"] = contributions
+
context['wikipedia_urls'] = json.dumps(settings.WIKIPEDIA_URLS)
context['JOCONDE_NOTICE_BASE_URL'] = settings.JOCONDE_NOTICE_BASE_URL
@@ -225,7 +227,7 @@
if letterpos < len(letters)-1:
tqs = tqs.filter(label__lt=letters[letterpos+1])
tqs = tqs.filter(notices__image=True).distinct('label').order_by('label').select_related('notices__images')
- tqs = tqs.values('notices__images__relative_url','dbpedia_uri','dbpedia_fields__abstract','dbpedia_fields__label')
+ tqs = tqs.values('notices__images__relative_url','dbpedia_uri','dbpedia_fields__abstract','label')
terms = []
known_uris = []
for t in tqs:
@@ -242,7 +244,7 @@
terms = [t for t in tqs if t['image_url']][:60]
terms = [{
"dbpedia_uri": t['dbpedia_uri'],
- "label": t['dbpedia_fields__label'],
+ "label": t.get('dbpedia_fields__label',t.get('label','')),
"abstract": t['dbpedia_fields__abstract'],
"image_url": "%s%s"%(settings.JOCONDE_IMG_BASE_URL, t.get('image_url',t.get('notices__images__relative_url','')))
} for t in terms]