From 3f61675a0aa9a7546d9aee3aeb240931785e4d28 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 16 Feb 2021 19:35:43 -0800 Subject: [PATCH] Updates usage of resolve_remote_id --- bookwyrm/connectors/bookwyrm_connector.py | 2 +- bookwyrm/models/fields.py | 6 ++++-- bookwyrm/models/status.py | 2 +- bookwyrm/tests/activitypub/test_base_activity.py | 4 ++-- bookwyrm/views/helpers.py | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bookwyrm/connectors/bookwyrm_connector.py b/bookwyrm/connectors/bookwyrm_connector.py index 1f877993..00e6c62f 100644 --- a/bookwyrm/connectors/bookwyrm_connector.py +++ b/bookwyrm/connectors/bookwyrm_connector.py @@ -7,7 +7,7 @@ class Connector(AbstractMinimalConnector): ''' this is basically just for search ''' def get_or_create_book(self, remote_id): - edition = activitypub.resolve_remote_id(models.Edition, remote_id) + edition = activitypub.resolve_remote_id(remote_id, model=models.Edition) work = edition.parent_work work.default_edition = work.get_default_edition() work.save() diff --git a/bookwyrm/models/fields.py b/bookwyrm/models/fields.py index f2465fb6..029958bd 100644 --- a/bookwyrm/models/fields.py +++ b/bookwyrm/models/fields.py @@ -279,7 +279,8 @@ class ManyToManyField(ActivitypubFieldMixin, models.ManyToManyField): except ValidationError: continue items.append( - activitypub.resolve_remote_id(remote_id, model=self.related_model) + activitypub.resolve_remote_id( + remote_id, model=self.related_model) ) return items @@ -316,7 +317,8 @@ class TagField(ManyToManyField): # tags can contain multiple types continue items.append( - activitypub.resolve_remote_id(link.href, model=self.related_model) + activitypub.resolve_remote_id( + link.href, model=self.related_model) ) return items diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index d2dd7d5b..fbc94e9d 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -84,7 +84,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): related_status=self, ) - def delete(self, *args, **kwargs): + def delete(self, *args, **kwargs):#pylint: disable=unused-argument ''' "delete" a status ''' self.deleted = True self.deleted_date = timezone.now() diff --git a/bookwyrm/tests/activitypub/test_base_activity.py b/bookwyrm/tests/activitypub/test_base_activity.py index e84d7674..1d3e85d3 100644 --- a/bookwyrm/tests/activitypub/test_base_activity.py +++ b/bookwyrm/tests/activitypub/test_base_activity.py @@ -79,7 +79,7 @@ class BaseActivity(TestCase): def test_resolve_remote_id(self): ''' look up or load remote data ''' # existing item - result = resolve_remote_id(models.User, 'http://example.com/a/b') + result = resolve_remote_id('http://example.com/a/b', model=models.User) self.assertEqual(result, self.user) # remote item @@ -91,7 +91,7 @@ class BaseActivity(TestCase): with patch('bookwyrm.models.user.set_remote_server.delay'): result = resolve_remote_id( - models.User, 'https://example.com/user/mouse') + 'https://example.com/user/mouse', model=models.User) self.assertIsInstance(result, models.User) self.assertEqual(result.remote_id, 'https://example.com/user/mouse') self.assertEqual(result.name, 'MOUSE?? MOUSE!!') diff --git a/bookwyrm/views/helpers.py b/bookwyrm/views/helpers.py index 842b8d1c..89d99501 100644 --- a/bookwyrm/views/helpers.py +++ b/bookwyrm/views/helpers.py @@ -162,7 +162,7 @@ def handle_remote_webfinger(query): if link.get('rel') == 'self': try: user = activitypub.resolve_remote_id( - models.User, link['href'] + link['href'], model=models.User ) except KeyError: return None