diff --git a/bookwyrm/connectors/abstract_connector.py b/bookwyrm/connectors/abstract_connector.py index 767188232..db80677f3 100644 --- a/bookwyrm/connectors/abstract_connector.py +++ b/bookwyrm/connectors/abstract_connector.py @@ -217,6 +217,10 @@ def dict_from_mappings(data, mappings): the subclass""" result = {} for mapping in mappings: + # sometimes there are multiple mappings for one field, don't + # overwrite earlier writes in that case + if mapping.local_field in result and result[mapping.local_field]: + continue result[mapping.local_field] = mapping.get_value(data) return result diff --git a/bookwyrm/connectors/inventaire.py b/bookwyrm/connectors/inventaire.py index dc27f2c02..c13ef7f8a 100644 --- a/bookwyrm/connectors/inventaire.py +++ b/bookwyrm/connectors/inventaire.py @@ -21,6 +21,7 @@ class Connector(AbstractConnector): ] self.book_mappings = [ Mapping("title", remote_field="wdt:P1476", formatter=get_first), + Mapping("title", remote_field="labels", formatter=get_language_code), Mapping("subtitle", remote_field="wdt:P1680", formatter=get_first), Mapping("inventaireId", remote_field="uri"), Mapping( @@ -211,4 +212,8 @@ class Connector(AbstractConnector): def get_language_code(options, code="en"): """when there are a bunch of translation but we need a single field""" - return options.get(code) + result = options.get(code) + if result: + return result + values = list(options.values()) + return values[0] if values else None diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 980061840..40da64861 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -155,9 +155,12 @@ {% if user_authenticated %} +
{% trans "rated it" %}
+ + {% include 'snippets/stars.html' with rating=rating.rating %} +{% trans "rated it" %}
- - {% include 'snippets/stars.html' with rating=rating.rating %} -