diff --git a/bookwyrm/connectors/connector_manager.py b/bookwyrm/connectors/connector_manager.py index e5a2399d3..ee8fb0fc8 100644 --- a/bookwyrm/connectors/connector_manager.py +++ b/bookwyrm/connectors/connector_manager.py @@ -112,7 +112,7 @@ def first_search_result( def get_connectors() -> Iterator[abstract_connector.AbstractConnector]: """load all connectors""" queryset = models.Connector.objects.filter(active=True) - if models.SiteSettings.objects.get().disable_federation: + if models.SiteSettings.get().disable_federation: queryset = queryset.exclude(connector_file="bookwyrm_connector") for info in queryset.order_by("priority").all(): diff --git a/bookwyrm/context_processors.py b/bookwyrm/context_processors.py index bec704a2c..1dac54997 100644 --- a/bookwyrm/context_processors.py +++ b/bookwyrm/context_processors.py @@ -8,7 +8,7 @@ def site_settings(request): if not request.is_secure(): request_protocol = "http://" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() theme = "css/themes/bookwyrm-light.scss" if ( hasattr(request, "user") diff --git a/bookwyrm/emailing.py b/bookwyrm/emailing.py index ccc0aea61..4a0ae7423 100644 --- a/bookwyrm/emailing.py +++ b/bookwyrm/emailing.py @@ -9,7 +9,7 @@ from bookwyrm.settings import DOMAIN, BASE_URL def email_data(): """fields every email needs""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() return { "site_name": site.name, "logo": site.logo_small_url, diff --git a/bookwyrm/importers/importer.py b/bookwyrm/importers/importer.py index d2a11d7f2..e321303f1 100644 --- a/bookwyrm/importers/importer.py +++ b/bookwyrm/importers/importer.py @@ -141,7 +141,7 @@ class Importer: # pylint: disable=no-self-use def get_import_limit(self, user: User) -> tuple[int, int]: """check if import limit is set and return how many imports are left""" - site_settings = SiteSettings.objects.get() + site_settings = SiteSettings.get() import_size_limit = site_settings.import_size_limit import_limit_reset = site_settings.import_limit_reset enforce_limit = import_size_limit and import_limit_reset diff --git a/bookwyrm/management/commands/admin_code.py b/bookwyrm/management/commands/admin_code.py index ee69b78cb..75322163f 100644 --- a/bookwyrm/management/commands/admin_code.py +++ b/bookwyrm/management/commands/admin_code.py @@ -6,7 +6,7 @@ from bookwyrm import models def get_admin_code(): """get that code""" - return models.SiteSettings.objects.get().admin_code + return models.SiteSettings.get().admin_code class Command(BaseCommand): diff --git a/bookwyrm/models/site.py b/bookwyrm/models/site.py index 8d21998c2..609538dba 100644 --- a/bookwyrm/models/site.py +++ b/bookwyrm/models/site.py @@ -269,7 +269,7 @@ def preview_image(instance: SiteSettings, *args, **kwargs) -> None: @app.task(queue=MISC) def check_for_updates_task() -> None: """See if git remote knows about a new version""" - site = SiteSettings.objects.get() + site = SiteSettings.get() release = get_data(RELEASE_API, timeout=3, is_activitypub=False) available_version = release.get("tag_name", None) if available_version: diff --git a/bookwyrm/preview_images.py b/bookwyrm/preview_images.py index 66d2e2d4b..446199c39 100644 --- a/bookwyrm/preview_images.py +++ b/bookwyrm/preview_images.py @@ -172,7 +172,7 @@ def generate_instance_layer(content_width): """Places components for instance preview""" font_instance = get_font("light", size=28) - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() if site.logo_small: with Image.open(site.logo_small) as logo_img: @@ -426,7 +426,7 @@ def generate_site_preview_image_task(): if not settings.ENABLE_PREVIEW_IMAGES: return - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() if site.logo: logo = site.logo diff --git a/bookwyrm/tests/importers/test_bookwyrm_import.py b/bookwyrm/tests/importers/test_bookwyrm_import.py index 1f50e78a6..89ba65557 100644 --- a/bookwyrm/tests/importers/test_bookwyrm_import.py +++ b/bookwyrm/tests/importers/test_bookwyrm_import.py @@ -43,7 +43,6 @@ class BookwyrmBooksImport(TestCase): cls.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True ) - models.SiteSettings.objects.create() work = models.Work.objects.create(title="Test Work") cls.book = models.Edition.objects.create( title="Example Edition", diff --git a/bookwyrm/tests/importers/test_calibre_import.py b/bookwyrm/tests/importers/test_calibre_import.py index d7947e65e..214549112 100644 --- a/bookwyrm/tests/importers/test_calibre_import.py +++ b/bookwyrm/tests/importers/test_calibre_import.py @@ -37,7 +37,6 @@ class CalibreImport(TestCase): cls.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True ) - models.SiteSettings.objects.create() work = models.Work.objects.create(title="Test Work") cls.book = models.Edition.objects.create( title="Example Edition", diff --git a/bookwyrm/tests/importers/test_goodreads_import.py b/bookwyrm/tests/importers/test_goodreads_import.py index 81169ff10..9d52a5602 100644 --- a/bookwyrm/tests/importers/test_goodreads_import.py +++ b/bookwyrm/tests/importers/test_goodreads_import.py @@ -43,7 +43,6 @@ class GoodreadsImport(TestCase): cls.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True ) - models.SiteSettings.objects.create() work = models.Work.objects.create(title="Test Work") cls.book = models.Edition.objects.create( title="Example Edition", diff --git a/bookwyrm/tests/importers/test_importer.py b/bookwyrm/tests/importers/test_importer.py index 31e01d96a..857d51e3c 100644 --- a/bookwyrm/tests/importers/test_importer.py +++ b/bookwyrm/tests/importers/test_importer.py @@ -46,7 +46,6 @@ class GenericImporter(TestCase): cls.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True ) - models.SiteSettings.objects.create() work = models.Work.objects.create(title="Test Work") cls.book = models.Edition.objects.create( title="Example Edition", @@ -374,7 +373,7 @@ class GenericImporter(TestCase): def test_import_limit(self, *_): """checks if import limit works""" - site_settings = models.SiteSettings.objects.get() + site_settings = models.SiteSettings.get() site_settings.import_size_limit = 2 site_settings.import_limit_reset = 2 site_settings.save() diff --git a/bookwyrm/tests/importers/test_librarything_import.py b/bookwyrm/tests/importers/test_librarything_import.py index 6b145e2d6..f6d81b303 100644 --- a/bookwyrm/tests/importers/test_librarything_import.py +++ b/bookwyrm/tests/importers/test_librarything_import.py @@ -45,7 +45,6 @@ class LibrarythingImport(TestCase): cls.local_user = models.User.objects.create_user( "mmai", "mmai@mmai.mmai", "password", local=True ) - models.SiteSettings.objects.create() work = models.Work.objects.create(title="Test Work") cls.book = models.Edition.objects.create( title="Example Edition", diff --git a/bookwyrm/tests/importers/test_openlibrary_import.py b/bookwyrm/tests/importers/test_openlibrary_import.py index ceb83762d..aa330e229 100644 --- a/bookwyrm/tests/importers/test_openlibrary_import.py +++ b/bookwyrm/tests/importers/test_openlibrary_import.py @@ -43,7 +43,6 @@ class OpenLibraryImport(TestCase): cls.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True ) - models.SiteSettings.objects.create() work = models.Work.objects.create(title="Test Work") cls.book = models.Edition.objects.create( title="Example Edition", diff --git a/bookwyrm/tests/importers/test_storygraph_import.py b/bookwyrm/tests/importers/test_storygraph_import.py index 859760085..182fa794c 100644 --- a/bookwyrm/tests/importers/test_storygraph_import.py +++ b/bookwyrm/tests/importers/test_storygraph_import.py @@ -43,7 +43,6 @@ class StorygraphImport(TestCase): cls.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True ) - models.SiteSettings.objects.create() work = models.Work.objects.create(title="Test Work") cls.book = models.Edition.objects.create( title="Example Edition", diff --git a/bookwyrm/tests/test_context_processors.py b/bookwyrm/tests/test_context_processors.py index 7a58b05d8..7c1fbb1dd 100644 --- a/bookwyrm/tests/test_context_processors.py +++ b/bookwyrm/tests/test_context_processors.py @@ -28,7 +28,7 @@ class ContextProcessor(TestCase): ) cls.anonymous_user = AnonymousUser cls.anonymous_user.is_authenticated = False - cls.site = models.SiteSettings.objects.create() + cls.site = models.SiteSettings.get() def setUp(self): """other test data""" diff --git a/bookwyrm/tests/test_emailing.py b/bookwyrm/tests/test_emailing.py index c507a059f..186cce930 100644 --- a/bookwyrm/tests/test_emailing.py +++ b/bookwyrm/tests/test_emailing.py @@ -26,7 +26,6 @@ class Emailing(TestCase): local=True, localname="mouse", ) - models.SiteSettings.objects.create() def setUp(self): """other test data""" diff --git a/bookwyrm/tests/test_merge.py b/bookwyrm/tests/test_merge.py index 46f39384e..07313e47d 100644 --- a/bookwyrm/tests/test_merge.py +++ b/bookwyrm/tests/test_merge.py @@ -12,8 +12,6 @@ class MergeBookDataModel(TestCase): @classmethod def setUpTestData(cls): """shared data""" - models.SiteSettings.objects.create() - cls.jrr_tolkien = models.Author.objects.create( name="J.R.R. Tolkien", aliases=["JRR Tolkien", "Tolkien"], diff --git a/bookwyrm/tests/test_preview_images.py b/bookwyrm/tests/test_preview_images.py index 12fb56d07..726118de1 100644 --- a/bookwyrm/tests/test_preview_images.py +++ b/bookwyrm/tests/test_preview_images.py @@ -92,7 +92,7 @@ class PreviewImages(TestCase): parent_work=self.work, ) - self.site = models.SiteSettings.objects.create() + self.site = models.SiteSettings.get() settings.ENABLE_PREVIEW_IMAGES = True diff --git a/bookwyrm/tests/views/admin/test_announcements.py b/bookwyrm/tests/views/admin/test_announcements.py index 62fb86d16..7e8925d21 100644 --- a/bookwyrm/tests/views/admin/test_announcements.py +++ b/bookwyrm/tests/views/admin/test_announcements.py @@ -27,8 +27,6 @@ class AnnouncementViews(TestCase): localname="mouse", ) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/admin/test_automod.py b/bookwyrm/tests/views/admin/test_automod.py index 27f98163e..d1dbd7909 100644 --- a/bookwyrm/tests/views/admin/test_automod.py +++ b/bookwyrm/tests/views/admin/test_automod.py @@ -34,7 +34,6 @@ class AutomodViews(TestCase): initdb.init_permissions() group = Group.objects.get(name="moderator") cls.local_user.groups.set([group]) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/admin/test_celery.py b/bookwyrm/tests/views/admin/test_celery.py index 513d69944..9233552fa 100644 --- a/bookwyrm/tests/views/admin/test_celery.py +++ b/bookwyrm/tests/views/admin/test_celery.py @@ -33,7 +33,6 @@ class CeleryStatusViews(TestCase): initdb.init_permissions() group = Group.objects.get(name="admin") cls.local_user.groups.set([group]) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/admin/test_dashboard.py b/bookwyrm/tests/views/admin/test_dashboard.py index 35fcb25a4..3289ad9f6 100644 --- a/bookwyrm/tests/views/admin/test_dashboard.py +++ b/bookwyrm/tests/views/admin/test_dashboard.py @@ -34,8 +34,6 @@ class DashboardViews(TestCase): group = Group.objects.get(name="moderator") cls.local_user.groups.set([group]) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/admin/test_email_blocks.py b/bookwyrm/tests/views/admin/test_email_blocks.py index 08a131c3a..4315c40c9 100644 --- a/bookwyrm/tests/views/admin/test_email_blocks.py +++ b/bookwyrm/tests/views/admin/test_email_blocks.py @@ -34,8 +34,6 @@ class EmailBlocklistViews(TestCase): group = Group.objects.get(name="moderator") cls.local_user.groups.set([group]) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/admin/test_email_config.py b/bookwyrm/tests/views/admin/test_email_config.py index 22f4b7a05..b8218a284 100644 --- a/bookwyrm/tests/views/admin/test_email_config.py +++ b/bookwyrm/tests/views/admin/test_email_config.py @@ -33,7 +33,6 @@ class EmailConfigViews(TestCase): initdb.init_permissions() group = Group.objects.get(name="admin") cls.local_user.groups.set([group]) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/admin/test_federation.py b/bookwyrm/tests/views/admin/test_federation.py index 6dcd5535f..818c949f5 100644 --- a/bookwyrm/tests/views/admin/test_federation.py +++ b/bookwyrm/tests/views/admin/test_federation.py @@ -46,8 +46,6 @@ class FederationViews(TestCase): group = Group.objects.get(name="moderator") cls.local_user.groups.set([group]) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/admin/test_imports.py b/bookwyrm/tests/views/admin/test_imports.py index 211407ff6..a8fdfbf04 100644 --- a/bookwyrm/tests/views/admin/test_imports.py +++ b/bookwyrm/tests/views/admin/test_imports.py @@ -33,7 +33,6 @@ class ImportsAdminViews(TestCase): initdb.init_permissions() group = Group.objects.get(name="admin") cls.local_user.groups.set([group]) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/admin/test_ip_blocklist.py b/bookwyrm/tests/views/admin/test_ip_blocklist.py index 491915eda..dfbc06797 100644 --- a/bookwyrm/tests/views/admin/test_ip_blocklist.py +++ b/bookwyrm/tests/views/admin/test_ip_blocklist.py @@ -34,8 +34,6 @@ class IPBlocklistViews(TestCase): group = Group.objects.get(name="moderator") cls.local_user.groups.set([group]) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/admin/test_link_domains.py b/bookwyrm/tests/views/admin/test_link_domains.py index 20d28896f..57e909567 100644 --- a/bookwyrm/tests/views/admin/test_link_domains.py +++ b/bookwyrm/tests/views/admin/test_link_domains.py @@ -41,8 +41,6 @@ class LinkDomainViews(TestCase): added_by=cls.local_user, ) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/admin/test_reports.py b/bookwyrm/tests/views/admin/test_reports.py index 146e40a9b..8a6b03898 100644 --- a/bookwyrm/tests/views/admin/test_reports.py +++ b/bookwyrm/tests/views/admin/test_reports.py @@ -41,7 +41,6 @@ class ReportViews(TestCase): initdb.init_permissions() group = Group.objects.get(name="moderator") cls.local_user.groups.set([group]) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/admin/test_site.py b/bookwyrm/tests/views/admin/test_site.py index 277bfbc85..0804bfe89 100644 --- a/bookwyrm/tests/views/admin/test_site.py +++ b/bookwyrm/tests/views/admin/test_site.py @@ -34,7 +34,7 @@ class SiteSettingsViews(TestCase): group = Group.objects.get(name="admin") cls.local_user.groups.set([group]) - cls.site = models.SiteSettings.objects.create() + cls.site = models.SiteSettings.get() def setUp(self): """individual test setup""" @@ -73,7 +73,7 @@ class SiteSettingsViews(TestCase): validate_html(result.render()) self.assertEqual(result.status_code, 200) - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() self.assertEqual(site.name, "Name!") def test_site_post_invalid(self): diff --git a/bookwyrm/tests/views/admin/test_themes.py b/bookwyrm/tests/views/admin/test_themes.py index af46bf060..d7d4f8bf3 100644 --- a/bookwyrm/tests/views/admin/test_themes.py +++ b/bookwyrm/tests/views/admin/test_themes.py @@ -42,7 +42,7 @@ class AdminThemesViews(TestCase): group = Group.objects.get(name="admin") cls.local_user.groups.set([group]) - cls.site = models.SiteSettings.objects.create() + cls.site = models.SiteSettings.get() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/admin/test_user_admin.py b/bookwyrm/tests/views/admin/test_user_admin.py index 48fd7202e..f34c3157b 100644 --- a/bookwyrm/tests/views/admin/test_user_admin.py +++ b/bookwyrm/tests/views/admin/test_user_admin.py @@ -34,7 +34,6 @@ class UserAdminViews(TestCase): initdb.init_permissions() group = Group.objects.get(name="moderator") cls.local_user.groups.set([group]) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/books/test_book.py b/bookwyrm/tests/views/books/test_book.py index ee6e7d8b4..3adc2c088 100644 --- a/bookwyrm/tests/views/books/test_book.py +++ b/bookwyrm/tests/views/books/test_book.py @@ -52,8 +52,6 @@ class BookViews(TestCase): parent_work=cls.work, ) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/books/test_edit_book.py b/bookwyrm/tests/views/books/test_edit_book.py index 05a4d68ac..7270fd3c0 100644 --- a/bookwyrm/tests/views/books/test_edit_book.py +++ b/bookwyrm/tests/views/books/test_edit_book.py @@ -49,7 +49,6 @@ class EditBookViews(TestCase): remote_id="https://example.com/book/1", parent_work=cls.work, ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/books/test_editions.py b/bookwyrm/tests/views/books/test_editions.py index ef7404e51..e54f0eb13 100644 --- a/bookwyrm/tests/views/books/test_editions.py +++ b/bookwyrm/tests/views/books/test_editions.py @@ -37,8 +37,6 @@ class BookViews(TestCase): physical_format="paperback", ) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/books/test_links.py b/bookwyrm/tests/views/books/test_links.py index 299dea484..16b6a9f2b 100644 --- a/bookwyrm/tests/views/books/test_links.py +++ b/bookwyrm/tests/views/books/test_links.py @@ -47,8 +47,6 @@ class LinkViews(TestCase): parent_work=cls.work, ) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/imports/test_import.py b/bookwyrm/tests/views/imports/test_import.py index 763fcc19f..de73f4134 100644 --- a/bookwyrm/tests/views/imports/test_import.py +++ b/bookwyrm/tests/views/imports/test_import.py @@ -31,7 +31,6 @@ class ImportViews(TestCase): local=True, localname="mouse", ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/imports/test_import_review.py b/bookwyrm/tests/views/imports/test_import_review.py index 026efac11..989560c6a 100644 --- a/bookwyrm/tests/views/imports/test_import_review.py +++ b/bookwyrm/tests/views/imports/test_import_review.py @@ -26,7 +26,6 @@ class ImportManualReviewViews(TestCase): local=True, localname="mouse", ) - models.SiteSettings.objects.create() cls.job = models.ImportJob.objects.create(user=cls.local_user, mappings={}) work = models.Work.objects.create(title="Test Work") diff --git a/bookwyrm/tests/views/imports/test_import_troubleshoot.py b/bookwyrm/tests/views/imports/test_import_troubleshoot.py index 2e76da373..1ed04d208 100644 --- a/bookwyrm/tests/views/imports/test_import_troubleshoot.py +++ b/bookwyrm/tests/views/imports/test_import_troubleshoot.py @@ -27,7 +27,6 @@ class ImportTroubleshootViews(TestCase): local=True, localname="mouse", ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/imports/test_user_import.py b/bookwyrm/tests/views/imports/test_user_import.py index 3e097fb0f..f4f32c152 100644 --- a/bookwyrm/tests/views/imports/test_user_import.py +++ b/bookwyrm/tests/views/imports/test_user_import.py @@ -29,7 +29,6 @@ class ImportUserViews(TestCase): local=True, localname="mouse", ) - models.SiteSettings.objects.create() def test_get_user_import_page(self): """there are so many views, this just makes sure it LOADS""" diff --git a/bookwyrm/tests/views/inbox/test_inbox.py b/bookwyrm/tests/views/inbox/test_inbox.py index 6deae38b7..b3e69b4d6 100644 --- a/bookwyrm/tests/views/inbox/test_inbox.py +++ b/bookwyrm/tests/views/inbox/test_inbox.py @@ -54,7 +54,6 @@ class Inbox(TestCase): inbox="https://example.com/users/rat/inbox", outbox="https://example.com/users/rat/outbox", ) - models.SiteSettings.objects.create() def test_inbox_invalid_get(self): """shouldn't try to handle if the user is not found""" diff --git a/bookwyrm/tests/views/inbox/test_inbox_add.py b/bookwyrm/tests/views/inbox/test_inbox_add.py index b3d50fe46..3ada89ec2 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_add.py +++ b/bookwyrm/tests/views/inbox/test_inbox_add.py @@ -45,8 +45,6 @@ class InboxAdd(TestCase): parent_work=work, ) - models.SiteSettings.objects.create() - @responses.activate def test_handle_add_book_to_shelf(self): """shelving a book""" diff --git a/bookwyrm/tests/views/inbox/test_inbox_announce.py b/bookwyrm/tests/views/inbox/test_inbox_announce.py index 1bc508d11..6afb2e0e9 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_announce.py +++ b/bookwyrm/tests/views/inbox/test_inbox_announce.py @@ -48,8 +48,6 @@ class InboxActivities(TestCase): remote_id="https://example.com/status/1", ) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.create_json = { diff --git a/bookwyrm/tests/views/inbox/test_inbox_block.py b/bookwyrm/tests/views/inbox/test_inbox_block.py index 923a87a76..956c736b4 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_block.py +++ b/bookwyrm/tests/views/inbox/test_inbox_block.py @@ -37,8 +37,6 @@ class InboxBlock(TestCase): outbox="https://example.com/users/rat/outbox", ) - models.SiteSettings.objects.create() - def test_handle_blocks(self): """create a "block" database entry from an activity""" self.local_user.followers.add(self.remote_user) diff --git a/bookwyrm/tests/views/inbox/test_inbox_create.py b/bookwyrm/tests/views/inbox/test_inbox_create.py index 0bb3907af..73a35665a 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_create.py +++ b/bookwyrm/tests/views/inbox/test_inbox_create.py @@ -47,7 +47,6 @@ class TransactionInboxCreate(TransactionTestCase): "cc": ["https://example.com/user/mouse/followers"], "object": {}, } - models.SiteSettings.objects.create() def test_create_status_transaction(self, *_): """the "it justs works" mode""" diff --git a/bookwyrm/tests/views/inbox/test_inbox_delete.py b/bookwyrm/tests/views/inbox/test_inbox_delete.py index 8d7582a21..52b26e00a 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_delete.py +++ b/bookwyrm/tests/views/inbox/test_inbox_delete.py @@ -44,8 +44,6 @@ class InboxActivities(TestCase): remote_id="https://example.com/status/1", ) - models.SiteSettings.objects.create() - def test_delete_status(self): """remove a status""" self.assertFalse(self.status.deleted) diff --git a/bookwyrm/tests/views/inbox/test_inbox_follow.py b/bookwyrm/tests/views/inbox/test_inbox_follow.py index ccc58c974..058d66005 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_follow.py +++ b/bookwyrm/tests/views/inbox/test_inbox_follow.py @@ -38,8 +38,6 @@ class InboxRelationships(TestCase): outbox="https://example.com/users/rat/outbox", ) - models.SiteSettings.objects.create() - def test_follow(self): """remote user wants to follow local user""" activity = { diff --git a/bookwyrm/tests/views/inbox/test_inbox_like.py b/bookwyrm/tests/views/inbox/test_inbox_like.py index 88dc24fbb..3675e9176 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_like.py +++ b/bookwyrm/tests/views/inbox/test_inbox_like.py @@ -47,8 +47,6 @@ class InboxActivities(TestCase): remote_id="https://example.com/status/1", ) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.create_json = { diff --git a/bookwyrm/tests/views/inbox/test_inbox_remove.py b/bookwyrm/tests/views/inbox/test_inbox_remove.py index 89f66c9bb..4bd5840fb 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_remove.py +++ b/bookwyrm/tests/views/inbox/test_inbox_remove.py @@ -44,8 +44,6 @@ class InboxRemove(TestCase): parent_work=cls.work, ) - models.SiteSettings.objects.create() - def test_handle_unshelve_book(self): """remove a book from a shelf""" shelf = models.Shelf.objects.create(user=self.remote_user, name="Test Shelf") diff --git a/bookwyrm/tests/views/inbox/test_inbox_update.py b/bookwyrm/tests/views/inbox/test_inbox_update.py index a0f74a3fb..d22a59862 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_update.py +++ b/bookwyrm/tests/views/inbox/test_inbox_update.py @@ -39,8 +39,6 @@ class InboxUpdate(TestCase): outbox="https://example.com/users/rat/outbox", ) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.update_json = { diff --git a/bookwyrm/tests/views/landing/test_invite.py b/bookwyrm/tests/views/landing/test_invite.py index 8adc64f4f..eca0fa0b1 100644 --- a/bookwyrm/tests/views/landing/test_invite.py +++ b/bookwyrm/tests/views/landing/test_invite.py @@ -29,7 +29,6 @@ class InviteViews(TestCase): local=True, localname="mouse", ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/landing/test_landing.py b/bookwyrm/tests/views/landing/test_landing.py index c68c9cd53..26d9b4b93 100644 --- a/bookwyrm/tests/views/landing/test_landing.py +++ b/bookwyrm/tests/views/landing/test_landing.py @@ -29,7 +29,6 @@ class LandingViews(TestCase): local=True, localname="mouse", ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" @@ -94,7 +93,7 @@ class LandingViews(TestCase): def test_impressum_page_on(self): """there are so many views, this just makes sure it LOADS""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() site.show_impressum = True site.save() diff --git a/bookwyrm/tests/views/landing/test_login.py b/bookwyrm/tests/views/landing/test_login.py index 00e446855..a7c99f149 100644 --- a/bookwyrm/tests/views/landing/test_login.py +++ b/bookwyrm/tests/views/landing/test_login.py @@ -47,7 +47,9 @@ class LoginViews(TestCase): localname="badger", two_factor_auth=True, ) - models.SiteSettings.objects.create(id=1, require_confirm_email=False) + site = models.SiteSettings.get() + site.require_confirm_email = False + site.save() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/landing/test_password.py b/bookwyrm/tests/views/landing/test_password.py index ad3110b02..33ada7dd8 100644 --- a/bookwyrm/tests/views/landing/test_password.py +++ b/bookwyrm/tests/views/landing/test_password.py @@ -31,7 +31,6 @@ class PasswordViews(TestCase): local=True, localname="mouse", ) - models.SiteSettings.objects.create(id=1) def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/landing/test_register.py b/bookwyrm/tests/views/landing/test_register.py index 7db6775db..3c93da8f8 100644 --- a/bookwyrm/tests/views/landing/test_register.py +++ b/bookwyrm/tests/views/landing/test_register.py @@ -35,9 +35,10 @@ class RegisterViews(TestCase): local=True, localname="mouse", ) - cls.settings = models.SiteSettings.objects.create( - id=1, require_confirm_email=False, allow_registration=True - ) + cls.settings = models.SiteSettings.get() + cls.settings.require_confirm_email = False + cls.settings.allow_registration = True + cls.settings.save() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/lists/test_curate.py b/bookwyrm/tests/views/lists/test_curate.py index 458d0b1e8..bb6dfb060 100644 --- a/bookwyrm/tests/views/lists/test_curate.py +++ b/bookwyrm/tests/views/lists/test_curate.py @@ -43,8 +43,6 @@ class ListViews(TestCase): ): cls.list = models.List.objects.create(name="Test List", user=cls.local_user) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/lists/test_embed.py b/bookwyrm/tests/views/lists/test_embed.py index 69462a007..ea8760cbf 100644 --- a/bookwyrm/tests/views/lists/test_embed.py +++ b/bookwyrm/tests/views/lists/test_embed.py @@ -43,8 +43,6 @@ class ListViews(TestCase): ): cls.list = models.List.objects.create(name="Test List", user=cls.local_user) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/lists/test_list.py b/bookwyrm/tests/views/lists/test_list.py index 38af920a1..724d693de 100644 --- a/bookwyrm/tests/views/lists/test_list.py +++ b/bookwyrm/tests/views/lists/test_list.py @@ -72,8 +72,6 @@ class ListViews(TestCase): ): cls.list = models.List.objects.create(name="Test List", user=cls.local_user) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/lists/test_list_item.py b/bookwyrm/tests/views/lists/test_list_item.py index bb64329f0..bc7d82998 100644 --- a/bookwyrm/tests/views/lists/test_list_item.py +++ b/bookwyrm/tests/views/lists/test_list_item.py @@ -38,8 +38,6 @@ class ListItemViews(TestCase): ): cls.list = models.List.objects.create(name="Test List", user=cls.local_user) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/lists/test_lists.py b/bookwyrm/tests/views/lists/test_lists.py index 3f24f669d..32fe41d08 100644 --- a/bookwyrm/tests/views/lists/test_lists.py +++ b/bookwyrm/tests/views/lists/test_lists.py @@ -35,8 +35,6 @@ class ListViews(TestCase): "rat@local.com", "rat@rat.com", "ratword", local=True, localname="rat" ) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/preferences/test_block.py b/bookwyrm/tests/views/preferences/test_block.py index e20888659..0e3542533 100644 --- a/bookwyrm/tests/views/preferences/test_block.py +++ b/bookwyrm/tests/views/preferences/test_block.py @@ -39,8 +39,6 @@ class BlockViews(TestCase): outbox="https://example.com/users/rat/outbox", ) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/preferences/test_change_password.py b/bookwyrm/tests/views/preferences/test_change_password.py index 75a17e462..76ad5d8ef 100644 --- a/bookwyrm/tests/views/preferences/test_change_password.py +++ b/bookwyrm/tests/views/preferences/test_change_password.py @@ -27,7 +27,6 @@ class ChangePasswordViews(TestCase): local=True, localname="mouse", ) - models.SiteSettings.objects.create(id=1) def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/preferences/test_delete_user.py b/bookwyrm/tests/views/preferences/test_delete_user.py index 68a1ebc3b..5af838e25 100644 --- a/bookwyrm/tests/views/preferences/test_delete_user.py +++ b/bookwyrm/tests/views/preferences/test_delete_user.py @@ -52,8 +52,6 @@ class DeleteUserViews(TestCase): shelf=cls.local_user.shelf_set.first(), ) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/preferences/test_edit_user.py b/bookwyrm/tests/views/preferences/test_edit_user.py index c31c8237e..8c1b8c8d5 100644 --- a/bookwyrm/tests/views/preferences/test_edit_user.py +++ b/bookwyrm/tests/views/preferences/test_edit_user.py @@ -50,8 +50,6 @@ class EditUserViews(TestCase): shelf=cls.local_user.shelf_set.first(), ) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/preferences/test_export_user.py b/bookwyrm/tests/views/preferences/test_export_user.py index 1d844676a..ab494bc48 100644 --- a/bookwyrm/tests/views/preferences/test_export_user.py +++ b/bookwyrm/tests/views/preferences/test_export_user.py @@ -14,7 +14,6 @@ class ExportUserViews(TestCase): def setUp(self): self.factory = RequestFactory() - models.SiteSettings.objects.create() with ( patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch("bookwyrm.activitystreams.populate_stream_task.delay"), diff --git a/bookwyrm/tests/views/shelf/test_shelf.py b/bookwyrm/tests/views/shelf/test_shelf.py index 9c2b0a645..72c4fe9a2 100644 --- a/bookwyrm/tests/views/shelf/test_shelf.py +++ b/bookwyrm/tests/views/shelf/test_shelf.py @@ -46,7 +46,6 @@ class ShelfViews(TestCase): cls.shelf = models.Shelf.objects.create( name="Test Shelf", identifier="test-shelf", user=cls.local_user ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/shelf/test_shelf_actions.py b/bookwyrm/tests/views/shelf/test_shelf_actions.py index d4727d9c5..73155b61a 100644 --- a/bookwyrm/tests/views/shelf/test_shelf_actions.py +++ b/bookwyrm/tests/views/shelf/test_shelf_actions.py @@ -52,7 +52,6 @@ class ShelfActionViews(TestCase): cls.shelf = models.Shelf.objects.create( name="Test Shelf", identifier="test-shelf", user=cls.local_user ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_annual_summary.py b/bookwyrm/tests/views/test_annual_summary.py index 1ee4322f7..ff86cfa8d 100644 --- a/bookwyrm/tests/views/test_annual_summary.py +++ b/bookwyrm/tests/views/test_annual_summary.py @@ -44,7 +44,6 @@ class AnnualSummary(TestCase): parent_work=cls.work, pages=300, ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_author.py b/bookwyrm/tests/views/test_author.py index ed65fc30b..0d023f0ad 100644 --- a/bookwyrm/tests/views/test_author.py +++ b/bookwyrm/tests/views/test_author.py @@ -46,7 +46,6 @@ class AuthorViews(TestCase): remote_id="https://example.com/book/1", parent_work=cls.work, ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_directory.py b/bookwyrm/tests/views/test_directory.py index 3ea224154..96dcd3692 100644 --- a/bookwyrm/tests/views/test_directory.py +++ b/bookwyrm/tests/views/test_directory.py @@ -29,7 +29,6 @@ class DirectoryViews(TestCase): localname="mouse", remote_id="https://example.com/users/mouse", ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_discover.py b/bookwyrm/tests/views/test_discover.py index 15732b924..f93913df2 100644 --- a/bookwyrm/tests/views/test_discover.py +++ b/bookwyrm/tests/views/test_discover.py @@ -26,7 +26,6 @@ class DiscoverViews(TestCase): local=True, localname="mouse", ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_feed.py b/bookwyrm/tests/views/test_feed.py index be4956c64..28a8e1bd3 100644 --- a/bookwyrm/tests/views/test_feed.py +++ b/bookwyrm/tests/views/test_feed.py @@ -48,7 +48,6 @@ class FeedViews(TestCase): title="Example Edition", remote_id="https://example.com/book/1", ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_follow.py b/bookwyrm/tests/views/test_follow.py index c26a9372a..1074de118 100644 --- a/bookwyrm/tests/views/test_follow.py +++ b/bookwyrm/tests/views/test_follow.py @@ -20,7 +20,6 @@ class FollowViews(TestCase): @classmethod def setUpTestData(cls): """we need basic test data and mocks""" - models.SiteSettings.objects.create() with ( patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch("bookwyrm.activitystreams.populate_stream_task.delay"), diff --git a/bookwyrm/tests/views/test_get_started.py b/bookwyrm/tests/views/test_get_started.py index b33948c19..d84435df7 100644 --- a/bookwyrm/tests/views/test_get_started.py +++ b/bookwyrm/tests/views/test_get_started.py @@ -39,7 +39,6 @@ class GetStartedViews(TestCase): title="Example Edition", remote_id="https://example.com/book/1", ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_goal.py b/bookwyrm/tests/views/test_goal.py index d682b727d..a7309e4aa 100644 --- a/bookwyrm/tests/views/test_goal.py +++ b/bookwyrm/tests/views/test_goal.py @@ -43,7 +43,6 @@ class GoalViews(TestCase): title="Example Edition", remote_id="https://example.com/book/1", ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_group.py b/bookwyrm/tests/views/test_group.py index 90223f74a..a2989dbff 100644 --- a/bookwyrm/tests/views/test_group.py +++ b/bookwyrm/tests/views/test_group.py @@ -48,7 +48,6 @@ class GroupViews(TestCase): cls.membership = models.GroupMember.objects.create( group=cls.testgroup, user=cls.local_user ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_hashtag.py b/bookwyrm/tests/views/test_hashtag.py index d9679fe5a..ebf3662f8 100644 --- a/bookwyrm/tests/views/test_hashtag.py +++ b/bookwyrm/tests/views/test_hashtag.py @@ -67,8 +67,6 @@ class HashtagView(TestCase): for status in cls.statuses_bookclub: status.mention_hashtags.add(cls.hashtag_bookclub) - models.SiteSettings.objects.create() - def setUp(self): """individual test setup""" self.factory = RequestFactory() diff --git a/bookwyrm/tests/views/test_isbn.py b/bookwyrm/tests/views/test_isbn.py index 60a81f3a2..517090212 100644 --- a/bookwyrm/tests/views/test_isbn.py +++ b/bookwyrm/tests/views/test_isbn.py @@ -37,7 +37,6 @@ class IsbnViews(TestCase): remote_id="https://example.com/book/1", parent_work=cls.work, ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_notifications.py b/bookwyrm/tests/views/test_notifications.py index 878a64c2c..fe80a1dfe 100644 --- a/bookwyrm/tests/views/test_notifications.py +++ b/bookwyrm/tests/views/test_notifications.py @@ -32,7 +32,6 @@ class NotificationViews(TestCase): ) with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"): cls.status = models.Status.objects.create(content="hi", user=cls.local_user) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_report.py b/bookwyrm/tests/views/test_report.py index f07887bfe..4f545aa1e 100644 --- a/bookwyrm/tests/views/test_report.py +++ b/bookwyrm/tests/views/test_report.py @@ -41,7 +41,6 @@ class ReportViews(TestCase): user=cls.local_user, content="Test status", ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_rss_feed.py b/bookwyrm/tests/views/test_rss_feed.py index 790efe51b..99d98c652 100644 --- a/bookwyrm/tests/views/test_rss_feed.py +++ b/bookwyrm/tests/views/test_rss_feed.py @@ -28,7 +28,6 @@ class RssFeedView(TestCase): remote_id="https://example.com/book/1", parent_work=work, ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_search.py b/bookwyrm/tests/views/test_search.py index 3b3e78e17..8a1001820 100644 --- a/bookwyrm/tests/views/test_search.py +++ b/bookwyrm/tests/views/test_search.py @@ -39,7 +39,6 @@ class Views(TestCase): remote_id="https://example.com/book/1", parent_work=cls.work, ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_setup.py b/bookwyrm/tests/views/test_setup.py index 7547b5646..aeb01887a 100644 --- a/bookwyrm/tests/views/test_setup.py +++ b/bookwyrm/tests/views/test_setup.py @@ -16,7 +16,9 @@ class SetupViews(TestCase): @classmethod def setUpTestData(cls): """we need basic test data and mocks""" - cls.site = models.SiteSettings.objects.create(install_mode=True) + cls.site = models.SiteSettings.get() + cls.site.install_mode = True + cls.site.save() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_status.py b/bookwyrm/tests/views/test_status.py index af8a6dc3f..5d31ad4bc 100644 --- a/bookwyrm/tests/views/test_status.py +++ b/bookwyrm/tests/views/test_status.py @@ -118,7 +118,6 @@ class StatusViews(TestCase): remote_id="https://example.com/book/1", parent_work=work, ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_updates.py b/bookwyrm/tests/views/test_updates.py index 7230f3324..f35daf8c6 100644 --- a/bookwyrm/tests/views/test_updates.py +++ b/bookwyrm/tests/views/test_updates.py @@ -27,7 +27,6 @@ class UpdateViews(TestCase): local=True, localname="mouse", ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_user.py b/bookwyrm/tests/views/test_user.py index 362d04feb..010df23af 100644 --- a/bookwyrm/tests/views/test_user.py +++ b/bookwyrm/tests/views/test_user.py @@ -46,7 +46,6 @@ class UserViews(TestCase): user=cls.local_user, shelf=cls.local_user.shelf_set.first(), ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/tests/views/test_wellknown.py b/bookwyrm/tests/views/test_wellknown.py index 444d88d17..14309a87a 100644 --- a/bookwyrm/tests/views/test_wellknown.py +++ b/bookwyrm/tests/views/test_wellknown.py @@ -41,7 +41,6 @@ class WellknownViews(TestCase): inbox="https://example.com/users/rat/inbox", outbox="https://example.com/users/rat/outbox", ) - models.SiteSettings.objects.create() def setUp(self): """individual test setup""" diff --git a/bookwyrm/views/admin/dashboard.py b/bookwyrm/views/admin/dashboard.py index 87af434c5..85b781dc4 100644 --- a/bookwyrm/views/admin/dashboard.py +++ b/bookwyrm/views/admin/dashboard.py @@ -47,7 +47,7 @@ class Dashboard(View): "email_sender" ] = f"{settings.EMAIL_SENDER_NAME}@{settings.EMAIL_SENDER_DOMAIN}" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() # pylint: disable=protected-access data["missing_conduct"] = ( not site.code_of_conduct diff --git a/bookwyrm/views/admin/federation_settings.py b/bookwyrm/views/admin/federation_settings.py index 127f85a12..6230dd3ec 100644 --- a/bookwyrm/views/admin/federation_settings.py +++ b/bookwyrm/views/admin/federation_settings.py @@ -18,7 +18,7 @@ class FederationSettings(View): def get(self, request): """show the current settings""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() data = { "form": forms.FederationSettings(instance=site), } @@ -26,7 +26,7 @@ class FederationSettings(View): def post(self, request): """Update federation settings""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() form = forms.FederationSettings(request.POST, instance=site) if not form.is_valid(): data = {"form": form} diff --git a/bookwyrm/views/admin/imports.py b/bookwyrm/views/admin/imports.py index ad704a2e8..882ec3ea4 100644 --- a/bookwyrm/views/admin/imports.py +++ b/bookwyrm/views/admin/imports.py @@ -47,7 +47,7 @@ class ImportList(View): user_paginated = Paginator(user_imports, PAGE_LENGTH) user_page = user_paginated.get_page(request.GET.get("page")) - site_settings = models.SiteSettings.objects.get() + site_settings = models.SiteSettings.get() data = { "imports": page, "user_imports": user_page, @@ -75,7 +75,7 @@ class ImportList(View): # pylint: disable=unused-argument def disable_imports(request): """When you just need people to please stop starting imports""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() site.imports_enabled = False site.save(update_fields=["imports_enabled"]) return redirect("settings-imports") @@ -86,7 +86,7 @@ def disable_imports(request): # pylint: disable=unused-argument def enable_imports(request): """When you just need people to please stop starting imports""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() site.imports_enabled = True site.save(update_fields=["imports_enabled"]) return redirect("settings-imports") @@ -96,7 +96,7 @@ def enable_imports(request): @permission_required("bookwyrm.edit_instance_settings", raise_exception=True) def set_import_size_limit(request): """Limit the amount of books users can import at once""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() import_size_limit = int(request.POST.get("limit")) import_limit_reset = int(request.POST.get("reset")) site.import_size_limit = import_size_limit @@ -120,7 +120,7 @@ def set_user_import_completed(request, import_id): @permission_required("bookwyrm.edit_instance_settings", raise_exception=True) def set_user_import_limit(request): """Limit how ofter users can import and export their account""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() site.user_import_time_limit = int(request.POST.get("limit")) site.save(update_fields=["user_import_time_limit"]) return redirect("settings-imports") @@ -131,7 +131,7 @@ def set_user_import_limit(request): # pylint: disable=unused-argument def enable_user_exports(request): """Allow users to export account data""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() site.user_exports_enabled = True site.save(update_fields=["user_exports_enabled"]) return redirect("settings-imports") @@ -142,7 +142,7 @@ def enable_user_exports(request): # pylint: disable=unused-argument def disable_user_exports(request): """Don't allow users to export account data""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() site.user_exports_enabled = False site.save(update_fields=["user_exports_enabled"]) return redirect("settings-imports") diff --git a/bookwyrm/views/admin/site.py b/bookwyrm/views/admin/site.py index 4b0a9c7d8..3dfda91e4 100644 --- a/bookwyrm/views/admin/site.py +++ b/bookwyrm/views/admin/site.py @@ -18,13 +18,13 @@ class Site(View): def get(self, request): """edit form""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() data = {"site_form": forms.SiteForm(instance=site)} return TemplateResponse(request, "settings/site.html", data) def post(self, request): """edit the site settings""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() form = forms.SiteForm(request.POST, request.FILES, instance=site) if not form.is_valid(): data = {"site_form": form} @@ -45,13 +45,13 @@ class RegistrationLimited(View): def get(self, request): """edit form""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() data = {"form": forms.RegistrationLimitedForm(instance=site)} return TemplateResponse(request, "settings/registration_limited.html", data) def post(self, request): """edit the site settings""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() form = forms.RegistrationLimitedForm(request.POST, request.FILES, instance=site) if not form.is_valid(): data = {"form": form} @@ -72,13 +72,13 @@ class Registration(View): def get(self, request): """edit form""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() data = {"form": forms.RegistrationForm(instance=site)} return TemplateResponse(request, "settings/registration.html", data) def post(self, request): """edit the site settings""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() form = forms.RegistrationForm(request.POST, request.FILES, instance=site) if not form.is_valid(): data = {"form": form} diff --git a/bookwyrm/views/imports/import_data.py b/bookwyrm/views/imports/import_data.py index 59686c1f0..3a36237dd 100644 --- a/bookwyrm/views/imports/import_data.py +++ b/bookwyrm/views/imports/import_data.py @@ -54,7 +54,7 @@ class Import(View): elif seconds: data["recent_avg_minutes"] = seconds / 60 - site_settings = models.SiteSettings.objects.get() + site_settings = models.SiteSettings.get() time_range = timezone.now() - datetime.timedelta( days=site_settings.import_limit_reset ) @@ -71,7 +71,7 @@ class Import(View): def post(self, request): """ingest a book data csv""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() if not site.imports_enabled: raise PermissionDenied() @@ -149,7 +149,7 @@ class UserImport(View): jobs = BookwyrmImportJob.objects.filter(user=request.user).order_by( "-created_date" ) - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() hours = site.user_import_time_limit allowed = ( jobs.first().created_date < timezone.now() - datetime.timedelta(hours=hours) diff --git a/bookwyrm/views/landing/about.py b/bookwyrm/views/landing/about.py index 0bcdfd836..1beecf242 100644 --- a/bookwyrm/views/landing/about.py +++ b/bookwyrm/views/landing/about.py @@ -42,7 +42,7 @@ def privacy(request): @require_GET def impressum(request): """more information about the instance""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() if not site.show_impressum: raise Http404() return TemplateResponse(request, "about/impressum.html") diff --git a/bookwyrm/views/landing/landing.py b/bookwyrm/views/landing/landing.py index 87119f465..ca2b7ccc3 100644 --- a/bookwyrm/views/landing/landing.py +++ b/bookwyrm/views/landing/landing.py @@ -16,7 +16,7 @@ class Home(View): if request.user.is_authenticated: feed_view = Feed.as_view() return feed_view(request, "home") - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() if site.install_mode: return redirect("setup") diff --git a/bookwyrm/views/preferences/export.py b/bookwyrm/views/preferences/export.py index 32e7db06e..e3966fddc 100644 --- a/bookwyrm/views/preferences/export.py +++ b/bookwyrm/views/preferences/export.py @@ -166,7 +166,7 @@ class ExportUser(View): last_job = self.user_jobs.first() if not last_job: return None - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() blocked_until = last_job.created_date + timedelta( hours=site.user_import_time_limit ) diff --git a/bookwyrm/views/setup.py b/bookwyrm/views/setup.py index 37344300d..106db9944 100644 --- a/bookwyrm/views/setup.py +++ b/bookwyrm/views/setup.py @@ -22,7 +22,7 @@ class InstanceConfig(View): def get(self, request): """Check out this cool instance""" # only allow this view when an instance is being configured - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() if not site.install_mode: raise PermissionDenied() @@ -55,7 +55,7 @@ class CreateAdmin(View): def get(self, request): """Create admin user form""" # only allow this view when an instance is being configured - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() if not site.install_mode: raise PermissionDenied() @@ -65,7 +65,7 @@ class CreateAdmin(View): @transaction.atomic def post(self, request): """Create that user""" - site = models.SiteSettings.objects.get() + site = models.SiteSettings.get() # you can't create an admin user if you're in config mode if not site.install_mode: raise PermissionDenied()