# HG changeset patch # User ymh # Date 1372691504 -7200 # Node ID bcbd95da9be29d0800d43ad83fc1d3583a5a2335 # Parent 040d7a2adb27d204974acb756589910b7f4a23ca add preview of notices + add missing img for wp diff -r 040d7a2adb27 -r bcbd95da9be2 src/core/models/notice.py --- 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' diff -r 040d7a2adb27 -r bcbd95da9be2 src/core/models/term.py --- 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): diff -r 040d7a2adb27 -r bcbd95da9be2 src/jocondelab/settings.py --- 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 diff -r 040d7a2adb27 -r bcbd95da9be2 src/jocondelab/static/jocondelab/css/style.css --- 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 diff -r 040d7a2adb27 -r bcbd95da9be2 src/jocondelab/static/jocondelab/img/Wikipedia-logo-v2-fr.png Binary file src/jocondelab/static/jocondelab/img/Wikipedia-logo-v2-fr.png has changed diff -r 040d7a2adb27 -r bcbd95da9be2 src/jocondelab/static/jocondelab/js/jocondelab.js --- 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 = $("
",{id: 'wp-infobox'}).addClass( "ui-widget-content ui-corner-all").appendTo('body'); } + wp_infobox.find('img').off('error'); + var html_str = "

"+item.label+"

" + (item.original_label !== item.label ? "

" + gettext("Redirected from: ") + item.original_label+"

":"") + "" + - "" + + "" + "
" + item.abstract + "
" ; + 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 }) } diff -r 040d7a2adb27 -r bcbd95da9be2 src/jocondelab/templates/jocondelab/term_edit.html --- 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 @@ + + {% trans 'nb notice' %} + {{term.nb_notice}} + + + {% trans 'notices' %} + + + + {% for notice in notices %} + + {%if forloop.last%}{% else %}{% autoescape off %}{% cycle "" "" %}{% endautoescape %}{% endif %} + {% endfor %} +
+ {% with thumbnail=notice.thumbnails.0 %} +
+ {% if thumbnail %} + + {% endif %} +
+ {% endwith %} +
+ + + + + + + +
domn{{ notice.domn }}
deno{{ notice.deno }}
titr{{ notice.titr }}
pdec{{ notice.pdec }}
lieux{{ notice.lieux }}
inv{{ notice.inv }}
+
+
+ +
diff -r 040d7a2adb27 -r bcbd95da9be2 src/jocondelab/views.py --- 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,