From 1e01e76ac25d9bb064317f6cfce794cda6a95b86 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 12 Dec 2020 18:06:48 -0800 Subject: [PATCH 1/5] removes unneeded imports --- bookwyrm/models/author.py | 3 ++- bookwyrm/models/base_model.py | 1 + bookwyrm/models/import_job.py | 1 - bookwyrm/models/relationship.py | 2 +- bookwyrm/status.py | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bookwyrm/models/author.py b/bookwyrm/models/author.py index 79973a37..331d2dd6 100644 --- a/bookwyrm/models/author.py +++ b/bookwyrm/models/author.py @@ -16,7 +16,8 @@ class Author(ActivitypubMixin, BookWyrmModel): max_length=255, blank=True, null=True, deduplication_field=True) sync = models.BooleanField(default=True) last_sync_date = models.DateTimeField(default=timezone.now) - wikipedia_link = fields.CharField(max_length=255, blank=True, null=True, deduplication_field=True) + wikipedia_link = fields.CharField( + max_length=255, blank=True, null=True, deduplication_field=True) # idk probably other keys would be useful here? born = fields.DateTimeField(blank=True, null=True) died = fields.DateTimeField(blank=True, null=True) diff --git a/bookwyrm/models/base_model.py b/bookwyrm/models/base_model.py index f44797ab..dd3065c9 100644 --- a/bookwyrm/models/base_model.py +++ b/bookwyrm/models/base_model.py @@ -44,6 +44,7 @@ class BookWyrmModel(models.Model): @receiver(models.signals.post_save) +#pylint: disable=unused-argument def execute_after_save(sender, instance, created, *args, **kwargs): ''' set the remote_id after save (when the id is available) ''' if not created or not hasattr(instance, 'get_remote_id'): diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py index fe39325f..8b09216f 100644 --- a/bookwyrm/models/import_job.py +++ b/bookwyrm/models/import_job.py @@ -6,7 +6,6 @@ from django.db import models from django.utils import timezone from bookwyrm import books_manager -from bookwyrm.connectors import ConnectorException from bookwyrm.models import ReadThrough, User, Book from bookwyrm.utils.fields import JSONField from .base_model import PrivacyLevels diff --git a/bookwyrm/models/relationship.py b/bookwyrm/models/relationship.py index 8913b9ab..debe2ace 100644 --- a/bookwyrm/models/relationship.py +++ b/bookwyrm/models/relationship.py @@ -37,7 +37,7 @@ class UserRelationship(ActivitypubMixin, BookWyrmModel): activity_serializer = activitypub.Follow - def get_remote_id(self, status=None): + def get_remote_id(self, status=None):# pylint: disable=arguments-differ ''' use shelf identifier in remote_id ''' status = status or 'follows' base_path = self.user_subject.remote_id diff --git a/bookwyrm/status.py b/bookwyrm/status.py index 83a106e5..648f2e7d 100644 --- a/bookwyrm/status.py +++ b/bookwyrm/status.py @@ -1,7 +1,7 @@ ''' Handle user activity ''' from django.utils import timezone -from bookwyrm import activitypub, books_manager, models +from bookwyrm import models from bookwyrm.sanitize_html import InputHtmlParser From 2b3daa022711e6e7181cf2574cf95dc59b8cbb27 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 12 Dec 2020 18:13:00 -0800 Subject: [PATCH 2/5] disable some warnings --- bookwyrm/context_processors.py | 2 +- bookwyrm/forms.py | 3 ++- bookwyrm/goodreads_import.py | 2 +- bookwyrm/incoming.py | 3 --- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/bookwyrm/context_processors.py b/bookwyrm/context_processors.py index 72839dce..a1471ac4 100644 --- a/bookwyrm/context_processors.py +++ b/bookwyrm/context_processors.py @@ -1,7 +1,7 @@ ''' customize the info available in context for rendering templates ''' from bookwyrm import models -def site_settings(request): +def site_settings(request):# pylint: disable=unused-argument ''' include the custom info about the site ''' return { 'site': models.SiteSettings.objects.get() diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 784f1038..a2c3e24b 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -30,7 +30,7 @@ class CustomForm(ModelForm): visible.field.widget.attrs['rows'] = None visible.field.widget.attrs['class'] = css_classes[input_type] - +# pylint: disable=missing-class-docstring class LoginForm(CustomForm): class Meta: model = models.User @@ -131,6 +131,7 @@ class ImportForm(forms.Form): class ExpiryWidget(widgets.Select): def value_from_datadict(self, data, files, name): + ''' human-readable exiration time buckets ''' selected_string = super().value_from_datadict(data, files, name) if selected_string == 'day': diff --git a/bookwyrm/goodreads_import.py b/bookwyrm/goodreads_import.py index 3fd330ab..93fc1c48 100644 --- a/bookwyrm/goodreads_import.py +++ b/bookwyrm/goodreads_import.py @@ -53,7 +53,7 @@ def import_data(job_id): for item in job.items.all(): try: item.resolve() - except Exception as e: + except Exception as e:# pylint: disable=broad-except logger.exception(e) item.fail_reason = 'Error loading book' item.save() diff --git a/bookwyrm/incoming.py b/bookwyrm/incoming.py index bbbebf0f..4964d393 100644 --- a/bookwyrm/incoming.py +++ b/bookwyrm/incoming.py @@ -17,9 +17,6 @@ from bookwyrm.signatures import Signature @csrf_exempt def inbox(request, username): ''' incoming activitypub events ''' - # TODO: should do some kind of checking if the user accepts - # this action from the sender probably? idk - # but this will just throw a 404 if the user doesn't exist try: models.User.objects.get(localname=username) except models.User.DoesNotExist: From 1e08eeb4c295b79e8cce1aff6e411f32352ea442 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 12 Dec 2020 18:25:04 -0800 Subject: [PATCH 3/5] Renames custom template tags file --- bookwyrm/templates/author.html | 2 +- bookwyrm/templates/book.html | 2 +- bookwyrm/templates/editions.html | 2 +- bookwyrm/templates/feed.html | 2 +- bookwyrm/templates/followers.html | 2 +- bookwyrm/templates/following.html | 2 +- bookwyrm/templates/import_status.html | 2 +- bookwyrm/templates/layout.html | 2 +- bookwyrm/templates/notifications.html | 2 +- bookwyrm/templates/shelf.html | 2 +- bookwyrm/templates/snippets/avatar.html | 2 +- bookwyrm/templates/snippets/book_cover.html | 2 +- bookwyrm/templates/snippets/book_preview.html | 2 +- bookwyrm/templates/snippets/boost_button.html | 2 +- bookwyrm/templates/snippets/cover_alt.html | 2 +- bookwyrm/templates/snippets/create_status.html | 2 +- bookwyrm/templates/snippets/fav_button.html | 2 +- bookwyrm/templates/snippets/finish_reading_modal.html | 2 +- bookwyrm/templates/snippets/follow_request_buttons.html | 2 +- bookwyrm/templates/snippets/privacy_select.html | 2 +- bookwyrm/templates/snippets/rate_action.html | 2 +- bookwyrm/templates/snippets/reply_form.html | 2 +- bookwyrm/templates/snippets/shelf.html | 2 +- bookwyrm/templates/snippets/shelve_button.html | 2 +- bookwyrm/templates/snippets/status.html | 2 +- bookwyrm/templates/snippets/status_body.html | 2 +- bookwyrm/templates/snippets/status_content.html | 2 +- bookwyrm/templates/snippets/status_header.html | 2 +- bookwyrm/templates/snippets/thread.html | 2 +- bookwyrm/templates/snippets/trimmed_text.html | 2 +- bookwyrm/templates/snippets/user_header.html | 2 +- bookwyrm/templates/snippets/username.html | 2 +- bookwyrm/templates/tag.html | 2 +- bookwyrm/templatetags/{fr_display.py => bookwyrm_tags.py} | 2 +- 34 files changed, 34 insertions(+), 34 deletions(-) rename bookwyrm/templatetags/{fr_display.py => bookwyrm_tags.py} (98%) diff --git a/bookwyrm/templates/author.html b/bookwyrm/templates/author.html index 3e3e0018..9a7a20ab 100644 --- a/bookwyrm/templates/author.html +++ b/bookwyrm/templates/author.html @@ -1,5 +1,5 @@ {% extends 'layout.html' %} -{% load fr_display %} +{% load bookwyrm_tags %} {% block content %}

{{ author.name }}

diff --git a/bookwyrm/templates/book.html b/bookwyrm/templates/book.html index 8b21b88c..10c2a27b 100644 --- a/bookwyrm/templates/book.html +++ b/bookwyrm/templates/book.html @@ -1,5 +1,5 @@ {% extends 'layout.html' %} -{% load fr_display %} +{% load bookwyrm_tags %} {% load humanize %} {% block content %} diff --git a/bookwyrm/templates/editions.html b/bookwyrm/templates/editions.html index 273b2cd6..619ceafb 100644 --- a/bookwyrm/templates/editions.html +++ b/bookwyrm/templates/editions.html @@ -1,5 +1,5 @@ {% extends 'layout.html' %} -{% load fr_display %} +{% load bookwyrm_tags %} {% block content %}

Editions of "{{ work.title }}"

diff --git a/bookwyrm/templates/feed.html b/bookwyrm/templates/feed.html index 6e49943a..07ad8d0f 100644 --- a/bookwyrm/templates/feed.html +++ b/bookwyrm/templates/feed.html @@ -1,5 +1,5 @@ {% extends 'layout.html' %} -{% load fr_display %} +{% load bookwyrm_tags %} {% block content %}
diff --git a/bookwyrm/templates/followers.html b/bookwyrm/templates/followers.html index 645e46a1..00cb13ca 100644 --- a/bookwyrm/templates/followers.html +++ b/bookwyrm/templates/followers.html @@ -1,5 +1,5 @@ {% extends 'layout.html' %} -{% load fr_display %} +{% load bookwyrm_tags %} {% block content %}

diff --git a/bookwyrm/templates/following.html b/bookwyrm/templates/following.html index 2cca9127..478ca813 100644 --- a/bookwyrm/templates/following.html +++ b/bookwyrm/templates/following.html @@ -1,5 +1,5 @@ {% extends 'layout.html' %} -{% load fr_display %} +{% load bookwyrm_tags %} {% block content %}

diff --git a/bookwyrm/templates/import_status.html b/bookwyrm/templates/import_status.html index f91e2cce..6bb903b0 100644 --- a/bookwyrm/templates/import_status.html +++ b/bookwyrm/templates/import_status.html @@ -1,5 +1,5 @@ {% extends 'layout.html' %} -{% load fr_display %} +{% load bookwyrm_tags %} {% load humanize %} {% block content %}
diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index b37c9cda..bcbdca2a 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -1,4 +1,4 @@ -{% load fr_display %} +{% load bookwyrm_tags %} diff --git a/bookwyrm/templates/notifications.html b/bookwyrm/templates/notifications.html index f9494c31..f31df76d 100644 --- a/bookwyrm/templates/notifications.html +++ b/bookwyrm/templates/notifications.html @@ -1,6 +1,6 @@ {% extends 'layout.html' %} {% load humanize %} -{% load fr_display %} +{% load bookwyrm_tags %} {% block content %}

Notifications

diff --git a/bookwyrm/templates/shelf.html b/bookwyrm/templates/shelf.html index d6842d13..390b9fc6 100644 --- a/bookwyrm/templates/shelf.html +++ b/bookwyrm/templates/shelf.html @@ -1,5 +1,5 @@ {% extends 'layout.html' %} -{% load fr_display %} +{% load bookwyrm_tags %} {% block content %}
diff --git a/bookwyrm/templates/snippets/avatar.html b/bookwyrm/templates/snippets/avatar.html index cb0a12ea..da4b5fd2 100644 --- a/bookwyrm/templates/snippets/avatar.html +++ b/bookwyrm/templates/snippets/avatar.html @@ -1,3 +1,3 @@ -{% load fr_display %} +{% load bookwyrm_tags %} avatar for {{ user|username }} diff --git a/bookwyrm/templates/snippets/book_cover.html b/bookwyrm/templates/snippets/book_cover.html index 3fd83616..ceeef426 100644 --- a/bookwyrm/templates/snippets/book_cover.html +++ b/bookwyrm/templates/snippets/book_cover.html @@ -1,4 +1,4 @@ -{% load fr_display %} +{% load bookwyrm_tags %}
{% if book.cover %} {% include 'snippets/cover_alt.html' with book=book %} diff --git a/bookwyrm/templates/snippets/book_preview.html b/bookwyrm/templates/snippets/book_preview.html index c675c45f..e7eca455 100644 --- a/bookwyrm/templates/snippets/book_preview.html +++ b/bookwyrm/templates/snippets/book_preview.html @@ -1,4 +1,4 @@ -{% load fr_display %} +{% load bookwyrm_tags %}
diff --git a/bookwyrm/templates/snippets/boost_button.html b/bookwyrm/templates/snippets/boost_button.html index 57765bed..bf06cef7 100644 --- a/bookwyrm/templates/snippets/boost_button.html +++ b/bookwyrm/templates/snippets/boost_button.html @@ -1,4 +1,4 @@ -{% load fr_display %} +{% load bookwyrm_tags %} {% with status.id|uuid as uuid %}
{% csrf_token %} diff --git a/bookwyrm/templates/snippets/cover_alt.html b/bookwyrm/templates/snippets/cover_alt.html index 52bd52f2..0cccc2e1 100644 --- a/bookwyrm/templates/snippets/cover_alt.html +++ b/bookwyrm/templates/snippets/cover_alt.html @@ -1,2 +1,2 @@ -{% load fr_display %} +{% load bookwyrm_tags %} '{{ book.title }}' Cover ({{ book|edition_info }}) diff --git a/bookwyrm/templates/snippets/create_status.html b/bookwyrm/templates/snippets/create_status.html index e36b1b19..ac8c0b75 100644 --- a/bookwyrm/templates/snippets/create_status.html +++ b/bookwyrm/templates/snippets/create_status.html @@ -1,5 +1,5 @@ {% load humanize %} -{% load fr_display %} +{% load bookwyrm_tags %}
    diff --git a/bookwyrm/templates/snippets/fav_button.html b/bookwyrm/templates/snippets/fav_button.html index 58ece1e4..11e03cdb 100644 --- a/bookwyrm/templates/snippets/fav_button.html +++ b/bookwyrm/templates/snippets/fav_button.html @@ -1,4 +1,4 @@ -{% load fr_display %} +{% load bookwyrm_tags %} {% with status.id|uuid as uuid %} {% csrf_token %} diff --git a/bookwyrm/templates/snippets/finish_reading_modal.html b/bookwyrm/templates/snippets/finish_reading_modal.html index 8f8aeeff..d04d508d 100644 --- a/bookwyrm/templates/snippets/finish_reading_modal.html +++ b/bookwyrm/templates/snippets/finish_reading_modal.html @@ -1,4 +1,4 @@ -{% load fr_display %} +{% load bookwyrm_tags %}