Skip to content

Commit

Permalink
openaire: openaire link on record detail page
Browse files Browse the repository at this point in the history
* Adds link from record to OpenAIRE version of record. (closes #1115)
  • Loading branch information
lnielsen committed Jun 1, 2017
1 parent 809e08d commit 31ac6a8
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 6 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
'zenodo_communities = zenodo.modules.communities.views:blueprint',
'zenodo_deposit = zenodo.modules.deposit.views:blueprint',
'zenodo_frontpage = zenodo.modules.frontpage.views:blueprint',
'zenodo_openaire = zenodo.modules.openaire.views:blueprint',
'zenodo_redirector = zenodo.modules.redirector.views:blueprint',
'zenodo_search_ui = zenodo.modules.search_ui.views:blueprint',
'zenodo_theme = zenodo.modules.theme.views:blueprint',
Expand Down
61 changes: 61 additions & 0 deletions zenodo/modules/openaire/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
#
# This file is part of Zenodo.
# Copyright (C) 2017 CERN.
#
# Zenodo is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Zenodo is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Zenodo; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
#
# In applying this license, CERN does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.

"""Blueprint for OpenAIRE."""

from __future__ import absolute_import, print_function

import copy
from operator import itemgetter

import idutils
import six
from flask import Blueprint, current_app, render_template, request
from flask_principal import ActionNeed

from .helpers import is_openaire_dataset, is_openaire_publication, \
openaire_link

blueprint = Blueprint(
'zenodo_openaire',
__name__
)


@blueprint.app_template_filter('is_openaire_publication')
def is_publication(record):
"""Test if record is an OpenAIRE publication."""
return is_openaire_publication(record)


@blueprint.app_template_filter('is_openaire_dataset')
def is_dataset(record):
"""Test if record is an OpenAIRE dataset."""
return is_openaire_publication(record)


@blueprint.app_template_filter('openaire_link')
def link(record):
"""Generate an OpenAIRE link."""
return openaire_link(record)
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@
# as an Intergovernmental Organization or submit itself to any jurisdiction.
-#}

{% set published_in = record|zenodo_related_links(all_pending_comms + all_accepted_comms) %}
{%- set published_in = record|zenodo_related_links(all_pending_comms + all_accepted_comms) %}
{%- set is_openaire = record|is_openaire_publication %}

{% if published_in %}
{%- if published_in or is_openaire %}
<div class="well metadata">
{% for item in published_in %}
<small class="text-muted">{{item.text}}</small>
<a href="{{item.link}}"><img src="{{ url_for('static', filename=item.image) }}" class="img-thumbnail" width="100%" /></a>{% endfor %}
{%- for item in published_in %}
<small class="text-muted">{{item.text}}</small>
<a href="{{item.link}}"><img src="{{ url_for('static', filename=item.image) }}" class="img-thumbnail" width="100%" /></a>
{%- endfor %}
{%- if is_openaire %}
<small class="text-muted">{{_('Available in')}}</small>
<a href="{{record|openaire_link}}">
<img src="{{ url_for('static', filename='img/openaire-horizontal.png') }}" class="img-thumbnail" width="100%" />
</a>
{%- endif %}
</div>
{% endif %}
{%- endif %}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 31ac6a8

Please sign in to comment.