--- a/src/core/models/notice.py Fri Jun 28 18:16:58 2013 +0200
+++ b/src/core/models/notice.py Mon Jul 01 17:11:44 2013 +0200
@@ -91,6 +91,16 @@
util = models.CharField(max_length=1024, null=True, blank=True)
video = models.CharField(max_length=2048, null=True, blank=True)
www = models.CharField(max_length=512, null=True, blank=True)
+
+ def thumbnails(): #@NoSelf
+ doc = """Docstring""" #@UnusedVariable
+
+ def fget(self):
+ return [img for img in self.images.all() if img.url.split('.')[-2].endswith("_v")]
+
+ return locals()
+
+ thumbnails = property(**thumbnails())
class Meta:
app_label = 'core'
--- a/src/core/models/term.py Fri Jun 28 18:16:58 2013 +0200
+++ b/src/core/models/term.py Mon Jul 01 17:11:44 2013 +0200
@@ -102,6 +102,7 @@
wikipedia_edition = models.BooleanField(default=False, blank=False, null=False)
nb_notice = models.IntegerField(blank=False, null=False, default=0, db_index=True, editable=False)
+ notices = models.ManyToManyField('core.Notice', related_name="terms+", through="core.NoticeTerm")
@property
def alternative_labels_str(self):
--- a/src/jocondelab/settings.py Fri Jun 28 18:16:58 2013 +0200
+++ b/src/jocondelab/settings.py Mon Jul 01 17:11:44 2013 +0200
@@ -185,6 +185,7 @@
WIKIPEDIA_API_URL = "http://fr.wikipedia.org/w/api.php"
WIKIPEDIA_VERSION_PERMALINK_TEMPLATE = "http://fr.wikipedia.org/w/index.php?oldid=%s"
DBPEDIA_URI_TEMPLATE = "http://fr.dbpedia.org/resource/%s"
+JOCONDE_IMG_BASE_URL = "http://www.culture.gouv.fr/Wave/image/joconde"
TERM_LIST_PAGE_SIZE = 20
PAGINATOR_VISIBLE_RANGE = 5
--- a/src/jocondelab/static/jocondelab/css/style.css Fri Jun 28 18:16:58 2013 +0200
+++ b/src/jocondelab/static/jocondelab/css/style.css Mon Jul 01 17:11:44 2013 +0200
@@ -472,7 +472,7 @@
#wrapper {
- width:1024px;
+ width:1280px;
margin:0 auto 0 0;
}
@@ -487,7 +487,7 @@
}
#term-detail-container {
- width: 404px;
+ width: 660px;
float: right;
padding:10px;
}
@@ -537,6 +537,12 @@
padding-right: 5px;
}
+.wp-missing-img {
+ background: #ffffff url('../img/Wikipedia-logo-v2-fr.png') no-repeat;
+ width: 57px;
+ height: 60px;
+}
+
#prev-next-prev-link {
float: left;
}
@@ -551,4 +557,43 @@
#prev-next {
height: 25px;
+ padding-right: 256px;
+}
+
+.notice-outer-container > table {
+ border-collapse: separate;
+}
+
+.notice-container {
+ border: thin solid black;
+ vertical-align: top;
+ padding: 4px;
+}
+
+.notice-img {
+ width: 85px;
+ height: 128px;
+/* border: thin solid red; */
+ float:left;
+}
+
+.notice-img > img {
+ max-width: 85px;
+ max-height: 128px;
+}
+
+.notice-desc {
+ float:right;
+ width: 170px;
+}
+
+.notice-field-title {
+ text-align: right;
+ color: rgb(10, 115, 144);
+ width: 30px;
+}
+.notice-field-val {
+ text-align: left;
+ padding-left: 5px;
+ max-width: 140px;
}
\ No newline at end of file
Binary file src/jocondelab/static/jocondelab/img/Wikipedia-logo-v2-fr.png has changed
--- a/src/jocondelab/static/jocondelab/js/jocondelab.js Fri Jun 28 18:16:58 2013 +0200
+++ b/src/jocondelab/static/jocondelab/js/jocondelab.js Mon Jul 01 17:11:44 2013 +0200
@@ -6,17 +6,24 @@
wp_infobox = $("<div>",{id: 'wp-infobox'}).addClass( "ui-widget-content ui-corner-all").appendTo('body');
}
+ wp_infobox.find('img').off('error');
+
var html_str = "<h3>"+item.label+"</h3>" +
(item.original_label !== item.label ? "<h4>" + gettext("Redirected from: ") + item.original_label+"</h4>":"") +
"<div class='wp-infobox-wp-link'>" +
"<a target='_blank' href='"+ item.url +"'>Source wikipedia</a>" +
"</div>" +
- "<img class='wp-img' src=\""+ item.thumbnail+"\"/>" +
+ "<img class='wp-img"+ ((!item.thumbnail)?" wp-missing-img":"") + "' src=\""+ item.thumbnail+"\"/>" +
"<div>" + item.abstract + "</div>" ;
+ wp_infobox.html(html_str);
+
+ wp_infobox.find('img').error(function(){
+ $(this).addClass('wp-missing-img');
+ });
+
wp_infobox
- .html(html_str)
.position({my: "left top", at:"right+5 top", of: $(".ui-autocomplete")})
.css("z-index", $(".ui-autocomplete").css("z-index"))
.show();
@@ -39,7 +46,8 @@
query: get_dp_sparql(resource_url),
format: "application/sparql-results+json"
},
- dataType: "json"
+ dataType: "json",
+ cache: true
})
}
--- a/src/jocondelab/templates/jocondelab/term_edit.html Fri Jun 28 18:16:58 2013 +0200
+++ b/src/jocondelab/templates/jocondelab/term_edit.html Mon Jul 01 17:11:44 2013 +0200
@@ -167,6 +167,40 @@
</span>
</td>
</tr>
+ <tr>
+ <td>{% trans 'nb notice' %}</td>
+ <td>{{term.nb_notice}}</td>
+ </tr>
+ <tr>
+ <td>{% trans 'notices' %}</td>
+ <td class="notice-outer-container">
+ <table>
+ <tr>
+ {% for notice in notices %}
+ <td class='notice-container'>
+ {% with thumbnail=notice.thumbnails.0 %}
+ <div class="notice-img">
+ {% if thumbnail %}
+ <img src="{{JOCONDE_IMG_BASE_URL}}{{ thumbnail.url }}" />
+ {% endif %}
+ </div>
+ {% endwith %}
+ <div class="notice-desc">
+ <table>
+ <tr><td class="notice-field-title">domn</td><td class="notice-field-val">{{ notice.domn }}</td></tr>
+ <tr><td class="notice-field-title">deno</td><td class="notice-field-val">{{ notice.deno }}</td></tr>
+ <tr><td class="notice-field-title">titr</td><td class="notice-field-val">{{ notice.titr }}</td></tr>
+ <tr><td class="notice-field-title">pdec</td><td class="notice-field-val">{{ notice.pdec }}</td></tr>
+ <tr><td class="notice-field-title">lieux</td><td class="notice-field-val">{{ notice.lieux }}</td></tr>
+ <tr><td class="notice-field-title">inv</td><td class="notice-field-val">{{ notice.inv }}</td></tr>
+ </table>
+ </div>
+ </td>
+ {%if forloop.last%}</tr>{% else %}{% autoescape off %}{% cycle "" "</tr><tr>" %}{% endautoescape %}{% endif %}
+ {% endfor %}
+ </table>
+ </td>
+ </tr>
</table>
</div>
</div>
--- a/src/jocondelab/views.py Fri Jun 28 18:16:58 2013 +0200
+++ b/src/jocondelab/views.py Mon Jul 01 17:11:44 2013 +0200
@@ -104,9 +104,12 @@
# Beware: because of multiple inheritance this call MultipleObjectMixin.get_context_data(self, **context)
context = DetailView.get_context_data(self, **kwargs)
+
+ context['notices'] = self.object.notices.select_related().all().prefetch_related('images')[:10]
context['filter_form'] = self.get_filter_form()
context['link_semantic_level_choice'] = TERM_WK_LINK_SEMANTIC_LEVEL_CHOICES
+ context['JOCONDE_IMG_BASE_URL'] = settings.JOCONDE_IMG_BASE_URL;
field_index = {
'DOMN' : 1,