Merge branch 'main' into book-format-choices

This commit is contained in:
Mouse Reeve
2021-09-27 10:28:05 -07:00
199 changed files with 7647 additions and 3289 deletions

View File

@ -101,7 +101,7 @@ class ActivityObject:
except KeyError:
if field.default == MISSING and field.default_factory == MISSING:
raise ActivitySerializerError(
"Missing required field: %s" % field.name
f"Missing required field: {field.name}"
)
value = field.default
setattr(self, field.name, value)
@ -213,14 +213,14 @@ class ActivityObject:
return data
@app.task
@app.task(queue="medium_priority")
@transaction.atomic
def set_related_field(
model_name, origin_model_name, related_field_name, related_remote_id, data
):
"""load reverse related fields (editions, attachments) without blocking"""
model = apps.get_model("bookwyrm.%s" % model_name, require_ready=True)
origin_model = apps.get_model("bookwyrm.%s" % origin_model_name, require_ready=True)
model = apps.get_model(f"bookwyrm.{model_name}", require_ready=True)
origin_model = apps.get_model(f"bookwyrm.{origin_model_name}", require_ready=True)
with transaction.atomic():
if isinstance(data, str):
@ -234,7 +234,7 @@ def set_related_field(
# this must exist because it's the object that triggered this function
instance = origin_model.find_existing_by_remote_id(related_remote_id)
if not instance:
raise ValueError("Invalid related remote id: %s" % related_remote_id)
raise ValueError(f"Invalid related remote id: {related_remote_id}")
# set the origin's remote id on the activity so it will be there when
# the model instance is created
@ -265,7 +265,7 @@ def get_model_from_type(activity_type):
]
if not model:
raise ActivitySerializerError(
'No model found for activity type "%s"' % activity_type
f'No model found for activity type "{activity_type}"'
)
return model[0]
@ -286,7 +286,7 @@ def resolve_remote_id(
data = get_data(remote_id)
except ConnectorException:
raise ActivitySerializerError(
"Could not connect to host for remote_id in: %s" % (remote_id)
f"Could not connect to host for remote_id: {remote_id}"
)
# determine the model implicitly, if not provided
# or if it's a model with subclasses like Status, check again