1
0
Fork 0

Merge branch 'bookwyrm-social:main' into fix-form-submit

This commit is contained in:
Jascha Urbach 2022-12-18 22:53:36 +01:00 committed by GitHub
commit 7c88f7081c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 4381 additions and 2503 deletions

View file

@ -318,6 +318,10 @@ def add_status_on_create_command(sender, instance, created):
if instance.published_date < timezone.now() - timedelta(
days=1
) or instance.created_date < instance.published_date - timedelta(days=1):
# a backdated status from a local user is an import, don't add it
if instance.user.local:
return
# an out of date remote status is a low priority but should be added
priority = LOW
add_status_task.apply_async(

View file

@ -19,7 +19,7 @@ from bookwyrm.models import (
Review,
ReviewRating,
)
from bookwyrm.tasks import app, LOW
from bookwyrm.tasks import app, LOW, IMPORTS
from .fields import PrivacyLevels
@ -74,8 +74,7 @@ class ImportJob(models.Model):
task = start_import_task.delay(self.id)
self.task_id = task.id
self.status = "active"
self.save(update_fields=["status", "task_id"])
self.save(update_fields=["task_id"])
def complete_job(self):
"""Report that the job has completed"""
@ -328,10 +327,12 @@ class ImportItem(models.Model):
)
@app.task(queue=LOW)
@app.task(queue=IMPORTS)
def start_import_task(job_id):
"""trigger the child tasks for each row"""
job = ImportJob.objects.get(id=job_id)
job.status = "active"
job.save(update_fields=["status"])
# don't start the job if it was stopped from the UI
if job.complete:
return
@ -345,7 +346,7 @@ def start_import_task(job_id):
job.save()
@app.task(queue=LOW)
@app.task(queue=IMPORTS)
def import_item_task(item_id):
"""resolve a row into a book"""
item = ImportItem.objects.get(id=item_id)

View file

@ -373,6 +373,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
"""We don't actually delete the database entry"""
# pylint: disable=attribute-defined-outside-init
self.is_active = False
self.avatar = ""
# skip the logic in this class's save()
super().save(*args, **kwargs)

View file

@ -14,3 +14,5 @@ app = Celery(
LOW = "low_priority"
MEDIUM = "medium_priority"
HIGH = "high_priority"
# import items get their own queue because they're such a pain in the ass
IMPORTS = "imports"

View file

@ -123,16 +123,18 @@
</h2>
<p class="subtitle is-5">{% trans "Thats great!" %}</p>
<p class="title is-4 is-serif">
{% blocktrans with pages=pages_average|intcomma %}That makes an average of {{ pages }} pages per book.{% endblocktrans %}
</p>
{% if pages > 0 %}
<p class="title is-4 is-serif">
{% blocktrans with pages=pages_average|intcomma %}That makes an average of {{ pages }} pages per book.{% endblocktrans %}
</p>
{% endif %}
{% if no_page_number %}
<p class="subtitle is-6">
{% blocktrans trimmed count counter=no_page_number %}
({{ no_page_number }} book doesnt have pages)
(No page data was available for {{ no_page_number }} book)
{% plural %}
({{ no_page_number }} books dont have pages)
(No page data was available for {{ no_page_number }} books)
{% endblocktrans %}
</p>
{% endif %}

View file

@ -41,7 +41,7 @@
</dl>
</div>
{% if not job.complete and show_progress %}
{% if job.status == "active" and show_progress %}
<div class="box is-processing">
<div class="block">
<span class="icon icon-spinner is-pulled-left" aria-hidden="true"></span>

View file

@ -10,7 +10,7 @@
{% csrf_token %}
<p>
{% blocktrans trimmed with username=user.localname %}
Are you sure you want to delete <strong>{{ username}}</strong>'s account? This action cannot be undone. To proceed, please enter your password to confirm deletion.
Are you sure you want to delete <strong>{{username}}</strong>'s account? This action cannot be undone. To proceed, please enter your password to confirm deletion.
{% endblocktrans %}
</p>
<div class="field">

View file

@ -63,7 +63,7 @@ class TransactionInboxCreate(TransactionTestCase):
with patch("bookwyrm.activitystreams.add_status_task.apply_async") as mock:
views.inbox.activity_task(activity)
self.assertEqual(mock.call_count, 2)
self.assertEqual(mock.call_count, 0)
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")