Adding specific elements in header and footer for iconolab-episteme project
plus adjustment of the metadata display in templates.
--- a/src/iconolab_episteme/management/commands/importimages.py Thu Jun 28 18:50:20 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-# -*- coding: UTF-8 -*-
-import json
-import logging
-import os
-import pprint
-import re
-import shutil
-import imghdr
-
-from django.conf import settings
-from django.core.management.base import BaseCommand, CommandError
-from PIL import Image as ImagePIL
-from sorl.thumbnail import get_thumbnail
-
-from iconolab.management.commands.importimages import BaseImportImagesCommand
-from iconolab.models import (Collection, Folder, Image, ImageStats, Item,
- ItemMetadata, MetaCategory)
-
-if settings.IMPORT_LOGGER_NAME and settings.LOGGING['loggers'].get(settings.IMPORT_LOGGER_NAME, ''):
- logger = logging.getLogger(settings.IMPORT_LOGGER_NAME)
-else:
- logger = logging.getLogger(__name__)
-
-class Command(BaseImportImagesCommand):
- help = 'import images from a directory into the media folder and creates item and image objects'
-
- def add_arguments(self, parser):
- parser.add_argument('source_dir')
- parser.add_argument(
- '--collection-id',
- dest='collection_id',
- default=False,
- help='insert extracted data into the specified collection instead of trying to load a collection fixture',
- )
- parser.add_argument(
- '--no-jpg-conversion',
- dest='no-jpg-conversion',
- default=False,
- help='use this option if you only want the image copied and not converted'
- )
-
- def handle(self, *args, **options):
-
- #Set no image size limit to PIL to be able to process big images.
- ImagePIL.MAX_IMAGE_PIXELS = None
-
- print('# Logging with logger '+logger.name)
- logger.debug('# Initializing command with args: %r', options)
-
- self.source_dir = options.get('source_dir')
-
- collection_id = options.get('collection_id')
-
- if not collection_id:
- raise CommandError("No collection id, aborting")
-
- print('## Finding collection with id %s' % collection_id)
-
- try:
- try:
- collection = Collection.objects.get(pk=int(collection_id))
- except ValueError:
- collection = Collection.objects.get(name=collection_id)
- except Collection.DoesNotExist:
- raise CommandError('!!! Collection with id ' + collection_id
- +' was not found, aborting !!!')
-
- print(
- '## Converting image and moving it to static dir, creating Image and Item objects')
- print('### Images will be stored in ' + os.path.join(settings.MEDIA_ROOT,'uploads'))
-
- for dirname, dirs, files in os.walk(self.source_dir):
- for filename in files:
- print("::Examining %s" % filename)
- filename_without_extension, extension = os.path.splitext(filename)
- if imghdr.what(os.path.join(dirname, filename)) is None:
- print("-> This is not an image: continue")
- continue
-
- json_path = os.path.join(dirname, filename_without_extension + ".json")
- if not os.path.isfile(json_path):
- print("-> has not a matching json: continue")
- continue
-
- print("-> Processing %s" %json_path)
- with open(json_path) as json_data:
- eso_data = json.load(json_data)
- eso_object = eso_data['object']
- eso_image = eso_data['image']
-
- path_images = os.path.join(filename_without_extension, filename)
- image_list = [path_images]
- image_dir = filename_without_extension
-
- natural_key = ItemMetadata.get_natural_key(collection, eso_image['id'])
-
- if ItemMetadata.objects.filter(item__collection=collection, natural_key=natural_key).exists():
- print('#### An item with ' +
- natural_key +' for natural key, already exists in database in the import collection')
- else:
- try:
- os.mkdir(os.path.join(settings.MEDIA_ROOT,'uploads', image_dir))
- print(image_dir, "directory created")
- except FileExistsError:
- print(image_dir, "directory already exists")
-
- try:
- self.create_item_and_metadata(
- natural_key, collection, eso_data, image_list, options, self.source_dir)
- except Exception as e:
- print("!!! Exception processing %s : %s" % (json_path, e))
- continue
-
- print('# All done!')
\ No newline at end of file
Binary file src/iconolab_episteme/static/iconolab_episteme/img/logo_ANR.png has changed
Binary file src/iconolab_episteme/static/iconolab_episteme/img/logo_LS2N_footer.png has changed
Binary file src/iconolab_episteme/static/iconolab_episteme/img/logo_cea_footer.png has changed
Binary file src/iconolab_episteme/static/iconolab_episteme/img/logo_chs_footer.png has changed
Binary file src/iconolab_episteme/static/iconolab_episteme/img/logo_episteme.png has changed
Binary file src/iconolab_episteme/static/iconolab_episteme/img/logo_liris_footer.png has changed
Binary file src/iconolab_episteme/static/iconolab_episteme/img/logo_mediapart_footer.png has changed
--- a/src/iconolab_episteme/templates/iconolab/metadatas/detail_image_metadatas.html Thu Jun 28 18:50:20 2018 +0200
+++ b/src/iconolab_episteme/templates/iconolab/metadatas/detail_image_metadatas.html Tue Jul 03 13:38:28 2018 +0200
@@ -1,8 +1,8 @@
{% load iconolab_episteme_tags %}
<dl class="dl-horizontal">
- {% if item.metadatas.metadata_obj.image.title %}<dt>Titre</dt><dd>{{item.metadatas.metadata_obj.image.title}}</dd>{% endif %}
- {% if item.metadatas.metadata_obj.image.description_html %}<dt>Description</dt><dd>{{item.metadatas.metadata_obj.image.description_html|safe}}</dd>{% endif %}
+ {% if item.metadatas.metadata_obj.image.title %}<dt>Titre</dt><dd>{{item.metadatas.metadata_obj.image.title}}</dd><br>{% endif %}
+ {% if item.metadatas.metadata_obj.image.description_html %}<dt>Description</dt><dd>{{item.metadatas.metadata_obj.image.description_html|safe}}</dd><br>{% endif %}
{% if item.metadatas.metadata_obj.image.credit %}<dt>Crédits</dt><dd>{{item.metadatas.metadata_obj.image.credit}}</dd>{% endif %}
{% if item.metadatas.metadata_obj.image.id %}<dt>Identification</dt><dd>{{item.metadatas.metadata_obj.image.id}}</dd>{% endif %}
</dl>
--- a/src/iconolab_episteme/templates/iconolab/metadatas/detail_item_metadatas.html Thu Jun 28 18:50:20 2018 +0200
+++ b/src/iconolab_episteme/templates/iconolab/metadatas/detail_item_metadatas.html Tue Jul 03 13:38:28 2018 +0200
@@ -1,7 +1,7 @@
{% load iconolab_episteme_tags %}
{% if item.metadatas.metadata_obj.image.title %}<h3>Titre : <small>{{item.metadatas.metadata_obj.image.title}}</small></h3>{% endif %}
-{% if item.metadatas.metadata_obj.image.description_html %}<h4>Description : <small>{{item.metadatas.metadata_obj.image.description_html|safe}}</small></h4>{% endif %}
+{% if item.metadatas.metadata_obj.image.description_html %}<div><h4 style='float:left'>Description :</h4> <div class='text-muted' style='display:inline-block'>{{item.metadatas.metadata_obj.image.description_html|safe}}</div></div>{% endif %}
{% if item.metadatas.metadata_obj.image.credit %}<h5>Crédits : <small>{{item.metadatas.metadata_obj.image.credit}}</small></h5>{% endif %}
{% if item.metadatas.metadata_obj.image.id %}<h5>Identification : <small>{{item.metadatas.metadata_obj.image.id}}</small></h5>{% endif %}
{% if item.metadatas.metadata_obj.image.id %}<h5><a href="{% eso_link item.metadatas %}" target="_blank">Cet objet dans la base d'images de l'ESO</a></h5>{% endif %}
--- a/src/iconolab_episteme/templates/iconolab/metadatas/image_search_metadatas.html Thu Jun 28 18:50:20 2018 +0200
+++ b/src/iconolab_episteme/templates/iconolab/metadatas/image_search_metadatas.html Tue Jul 03 13:38:28 2018 +0200
@@ -1,4 +1,4 @@
-{% if item.object.metadatas.metadata_obj.image.title %}<h3>Titre : <small>{{item.object.metadatas.metadata_obj.image.title}}</small></h3>{% endif %}
+{% if item.object.metadatas.metadata_obj.image.title %}<h3>Titre : <small>{{item.object.metadatas.metadata_obj.image.title}}</small></h3><br>{% endif %}
{% if item.object.metadatas.metadata_obj.image.description_html %}<h4>Description :</h4> <div class='text-muted'>{{item.object.metadatas.metadata_obj.image.description_html|safe}}</div>{% endif %}
{% if item.object.metadatas.metadata_obj.image.credit %}<h5>Crédits : <small>{{item.object.metadatas.metadata_obj.image.credit}}</small></h5>{% endif %}
{% if item.object.metadatas.metadata_obj.image.id %}<h5>Identification : <small>{{item.object.metadatas.metadata_obj.image.id}}</small></h5>{% endif %}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/iconolab_episteme/templates/partials/footer.html Tue Jul 03 13:38:28 2018 +0200
@@ -0,0 +1,26 @@
+{% load staticfiles %}
+{% load iconolab_tags %}
+{% load iconolab_episteme_tags %}
+
+<div class="container">
+<hr style="margin-top: 5px;">
+ <div class="pull-left footer-info">
+ <h4><small>Version {% version %}/{% episteme_version %}</small></h4>
+ </div>
+ <div class="pull-right partners-icons">
+ <a href="http://www.iri.centrepompidou.fr/projets/episteme" target="_blank" rel="noopener noreferrer"><img style='width:110px;height:auto;vertical-align: middle;' src="{% static 'iconolab/img/logo_IRI_footer.png' %}"></a>
+
+ <a href="http://liris.cnrs.fr/equipes?id=75" target="_blank" rel="noopener noreferrer"><img style='width:90px;height:auto;vertical-align: middle;' src="{% static 'iconolab_episteme/img/logo_liris_footer.png' %}"></a>
+
+ <a href="https://www.ls2n.fr/" target="_blank" rel="noopener noreferrer"><img style='width:100px;height:auto;vertical-align: middle;' src="{% static 'iconolab_episteme/img/logo_LS2N_footer.png' %}"></a>
+
+ <a href="http://histoire-sociale.univ-paris1.fr/?lang=fr" target="_blank" rel="noopener noreferrer"><img style='width:90px;height:auto;vertical-align: middle;' src="{% static 'iconolab_episteme/img/logo_chs_footer.png' %}"></a>
+
+ <a href="http://irfu.cea.fr/" target="_blank" rel="noopener noreferrer"><img style='width:57px;height:auto;vertical-align: middle;' src="{% static 'iconolab_episteme/img/logo_cea_footer.png' %}"></a>
+
+ <a href="https://www.mediapart.fr/" target="_blank" rel="noopener noreferrer"><img style='width:100px;height:auto;vertical-align: middle;' src="{% static 'iconolab_episteme/img/logo_mediapart_footer.png' %}"></a>
+ </div>
+ <div class="pull-right footer-link">
+ <h4><small><a href="{% url 'iconolab_glossary' %}">Glossaire</a></small></h4>
+ </div>
+</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/iconolab_episteme/templates/partials/header.html Tue Jul 03 13:38:28 2018 +0200
@@ -0,0 +1,46 @@
+{% load notifications_tags %}
+{% load iconolab_tags %}
+{% load staticfiles %}
+
+<header>
+ <section id="topnav">
+ <nav class="navbar navbar-default">
+ <div class="{% container_class %}">
+ <div class="navbar-header">
+ {# {% if not homepage %} #}
+ <a class="navbar-brand" href="{% url 'home' %}">
+ <img src="{% static 'iconolab/img/iconolab.png' %}" alt="Iconolab" height="20">
+ </a>
+ {# {% endif %} #}
+ </div>
+ <div id="navbar" class="navbar-collapse collapse">
+ <ul class="nav navbar-nav">
+ <li><a href="{% url 'iconolab_help' %}">Le projet</a></li>
+ {% if collection_name %}<li><a href="{% url 'collection_home' collection_name %}">Contribuer</a></li>{% endif %}
+ </ul>
+ {% include "partials/header_search_form.html"%}
+ <a class="navbar-brand" href="https://projet-episteme.org/" target="_blank" rel="noopener noreferrer">
+ <img src="{% static 'iconolab_episteme/img/logo_episteme.png' %}" alt="Episteme" height="25" style="margin-left: 20%;">
+ </a>
+ <ul class="nav navbar-nav navbar-right">
+ {% if request.user.is_authenticated %}
+ {% notifications_unread as unread_count %}
+ <li><a href="{% url 'user_home' request.user.username %}" title="{{request.user.username}}: Mon espace - {{ unread_count }} notification(s)">
+ Mon espace <span class="badge {% if unread_count %}badge-warning{% endif %}">
+ {{ unread_count }} <i class="fa fa-envelope-o" aria-hidden="true"></i> </span>
+ </a></li>
+ <li><a href="{% url 'account:logout' %}">Déconnexion</a></li>
+ {% else %}
+ <li><a href="{% url 'account:register' %}">Créer un compte</a></li>
+ <li><a href="{% url 'account:login' %}?next={{ request.path | urlencode }}">Connexion</a></li>
+ {% endif %}
+ </ul>
+ </div><!--/.nav-collapse -->
+ </div><!--/.container-fluid -->
+ </nav>
+ </section>
+</header>
+
+<div class="{% container_class %}">
+{% include "partials/header_breadcrumbs.html" %}
+</div>
--- a/src/iconolab_episteme/templatetags/iconolab_episteme_tags.py Thu Jun 28 18:50:20 2018 +0200
+++ b/src/iconolab_episteme/templatetags/iconolab_episteme_tags.py Tue Jul 03 13:38:28 2018 +0200
@@ -1,5 +1,8 @@
from django.template import Library
from django.conf import settings
+from iconolab.models import (Collection, ItemMetadata)
+
+from iconolab_episteme import __version__
register = Library()
@@ -7,3 +10,8 @@
def eso_link(item_metadata):
return settings.ESO_NOTICE_BASE_URL + item_metadata.raw_natural_key
+@register.simple_tag
+def episteme_version():
+ return __version__
+
+