mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-17 05:36:34 +00:00
display isni bio with existing author name
If an existing author has an isni on record and it matches an author from the isni api call, display the isni short description to aid with identifying the appropriate author.
This commit is contained in:
parent
30a959dfce
commit
37148c5127
3 changed files with 19 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
{% extends 'layout.html' %}
|
{% extends 'layout.html' %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load humanize %}
|
{% load humanize %}
|
||||||
|
{% load utilities %}
|
||||||
|
|
||||||
{% block title %}{% if book %}{% blocktrans with book_title=book.title %}Edit "{{ book_title }}"{% endblocktrans %}{% else %}{% trans "Add Book" %}{% endif %}{% endblock %}
|
{% block title %}{% if book %}{% blocktrans with book_title=book.title %}Edit "{{ book_title }}"{% endblocktrans %}{% else %}{% trans "Add Book" %}{% endif %}{% endblock %}
|
||||||
|
|
||||||
|
@ -75,6 +76,9 @@
|
||||||
<p class="help ml-5 mb-2">
|
<p class="help ml-5 mb-2">
|
||||||
<a href="{{ match.local_path }}" target="_blank">{% blocktrans with book_title=match.book_set.first.title %}Author of <em>{{ book_title }}</em>{% endblocktrans %}</a>
|
<a href="{{ match.local_path }}" target="_blank">{% blocktrans with book_title=match.book_set.first.title %}Author of <em>{{ book_title }}</em>{% endblocktrans %}</a>
|
||||||
</p>
|
</p>
|
||||||
|
<p class="help ml-5">
|
||||||
|
{{ author.existing_isnis|get_isni_bio:match }}
|
||||||
|
</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<label class="label mt-2">
|
<label class="label mt-2">
|
||||||
<input type="radio" name="author_match-{{ counter }}" value="{{ author.name }}" required> {% trans "This is a new author" %}
|
<input type="radio" name="author_match-{{ counter }}" value="{{ author.name }}" required> {% trans "This is a new author" %}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
""" template filters for really common utilities """
|
""" template filters for really common utilities """
|
||||||
import os
|
import os
|
||||||
|
from functools import reduce
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from django import template
|
from django import template
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
@ -66,3 +67,14 @@ def get_book_cover_thumbnail(book, size="medium", ext="jpg"):
|
||||||
return cover_thumbnail.url
|
return cover_thumbnail.url
|
||||||
except OSError:
|
except OSError:
|
||||||
return static("images/no_cover.jpg")
|
return static("images/no_cover.jpg")
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter(name="get_isni_bio")
|
||||||
|
def get_isni_bio(existing, author):
|
||||||
|
"""Returns the isni bio string if an existing author has an isni listed"""
|
||||||
|
if len(existing) == 0:
|
||||||
|
return ""
|
||||||
|
match = reduce(
|
||||||
|
(lambda a: a if a.hasattr("bio") and author.isni == a.isni else ""), existing
|
||||||
|
)
|
||||||
|
return match["bio"]
|
||||||
|
|
|
@ -75,11 +75,14 @@ class EditBook(View):
|
||||||
for a in author_matches
|
for a in author_matches
|
||||||
if i["isni"] == a.isni
|
if i["isni"] == a.isni
|
||||||
]
|
]
|
||||||
|
|
||||||
isni_matches = list(filter(lambda x: x not in exists, isni_authors))
|
isni_matches = list(filter(lambda x: x not in exists, isni_authors))
|
||||||
|
|
||||||
data["author_matches"].append(
|
data["author_matches"].append(
|
||||||
{
|
{
|
||||||
"name": author.strip(),
|
"name": author.strip(),
|
||||||
"matches": author_matches,
|
"matches": author_matches,
|
||||||
|
"existing_isnis": exists,
|
||||||
"isni_matches": isni_matches,
|
"isni_matches": isni_matches,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue