forked from mirrors/bookwyrm
Merge branch 'import-field-names' of github.com:bookwyrm-social/bookwyrm into import-field-names
This commit is contained in:
commit
c614f638fd
6 changed files with 43 additions and 1 deletions
|
@ -205,3 +205,5 @@ def handle_imported_book(item):
|
|||
)
|
||||
# only broadcast this review to other bookwyrm instances
|
||||
review.save(software="bookwyrm", priority=LOW)
|
||||
item.linked_review = review
|
||||
item.save()
|
||||
|
|
24
bookwyrm/migrations/0115_importitem_linked_review.py
Normal file
24
bookwyrm/migrations/0115_importitem_linked_review.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Generated by Django 3.2.5 on 2021-11-13 19:35
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bookwyrm", "0114_importjob_source"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="importitem",
|
||||
name="linked_review",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
to="bookwyrm.review",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -62,6 +62,9 @@ class ImportItem(models.Model):
|
|||
related_name="book_guess",
|
||||
)
|
||||
fail_reason = models.TextField(null=True)
|
||||
linked_review = models.ForeignKey(
|
||||
"Review", on_delete=models.SET_NULL, null=True, blank=True
|
||||
)
|
||||
|
||||
def resolve(self):
|
||||
"""try various ways to lookup a book"""
|
||||
|
|
|
@ -134,8 +134,15 @@
|
|||
{{ item.normalized_data.shelf }}
|
||||
</td>
|
||||
<td>
|
||||
{% if item.rating %}
|
||||
<p>{% include 'snippets/stars.html' with rating=item.rating %}</p>
|
||||
{% endif %}
|
||||
{% if item.review %}
|
||||
<p>{{ item.review|truncatechars:100 }}</p>
|
||||
{% endif %}
|
||||
{% if item.linked_review %}
|
||||
<a href="{{ item.linked_review.remote_id }}" target="_blank">{% trans "View imported review" %}</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% block import_cols %}
|
||||
<td>
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
{% csrf_token %}
|
||||
<button type="submit" class="button is-danger is-light is-outlined">
|
||||
<span class="icon icon-x m-0-mobile" aria-hidden="true"></span>
|
||||
<span class="is-sr-only-mobile">{% trans "Delete" %}</span>
|
||||
<span class="is-sr-only-mobile">{% trans "Reject" %}</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -233,6 +233,9 @@ class GenericImporter(TestCase):
|
|||
self.assertEqual(review.rating, 2.0)
|
||||
self.assertEqual(review.privacy, "unlisted")
|
||||
|
||||
import_item.refresh_from_db()
|
||||
self.assertEqual(import_item.linked_review, review)
|
||||
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
def test_handle_imported_book_rating(self, *_):
|
||||
"""rating import"""
|
||||
|
@ -250,6 +253,9 @@ class GenericImporter(TestCase):
|
|||
self.assertEqual(review.rating, 3.0)
|
||||
self.assertEqual(review.privacy, "unlisted")
|
||||
|
||||
import_item.refresh_from_db()
|
||||
self.assertEqual(import_item.linked_review.id, review.id)
|
||||
|
||||
def test_handle_imported_book_reviews_disabled(self, *_):
|
||||
"""review import"""
|
||||
import_job = self.importer.create_job(
|
||||
|
|
Loading…
Reference in a new issue