mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 03:21:05 +00:00
Linter fixes for models
This commit is contained in:
parent
d8d6f57373
commit
59938e2d46
6 changed files with 19 additions and 15 deletions
2
.github/workflows/black.yml
vendored
2
.github/workflows/black.yml
vendored
|
@ -1,4 +1,4 @@
|
|||
name: Lint Python
|
||||
name: Python Formmating (run ./bw-dev black to fix)
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ from bookwyrm import models, preview_images
|
|||
# pylint: disable=line-too-long
|
||||
class Command(BaseCommand):
|
||||
"""Creates previews for existing objects"""
|
||||
|
||||
help = "Generate preview images"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
|
|
|
@ -8,8 +8,7 @@ from model_utils.managers import InheritanceManager
|
|||
|
||||
from bookwyrm import activitypub
|
||||
from bookwyrm.preview_images import generate_edition_preview_image_task
|
||||
from bookwyrm.settings import DOMAIN, DEFAULT_LANGUAGE
|
||||
from bookwyrm.tasks import app
|
||||
from bookwyrm.settings import DOMAIN, DEFAULT_LANGUAGE, ENABLE_PREVIEW_IMAGES
|
||||
|
||||
from .activitypub_mixin import OrderedCollectionPageMixin, ObjectMixin
|
||||
from .base_model import BookWyrmModel
|
||||
|
@ -303,9 +302,12 @@ def isbn_13_to_10(isbn_13):
|
|||
return converted + str(checkdigit)
|
||||
|
||||
|
||||
@receiver(models.signals.post_save, sender=Edition)
|
||||
# pylint: disable=unused-argument
|
||||
@receiver(models.signals.post_save, sender=Edition)
|
||||
def preview_image(instance, *args, **kwargs):
|
||||
"""create preview image on book create"""
|
||||
if not ENABLE_PREVIEW_IMAGES:
|
||||
return
|
||||
changed_fields = {}
|
||||
if instance.field_tracker:
|
||||
changed_fields = instance.field_tracker.changed()
|
||||
|
|
|
@ -9,8 +9,7 @@ from django.utils import timezone
|
|||
from model_utils import FieldTracker
|
||||
|
||||
from bookwyrm.preview_images import generate_site_preview_image_task
|
||||
from bookwyrm.settings import DOMAIN
|
||||
from bookwyrm.tasks import app
|
||||
from bookwyrm.settings import DOMAIN, ENABLE_PREVIEW_IMAGES
|
||||
from .base_model import BookWyrmModel
|
||||
from .user import User
|
||||
|
||||
|
@ -130,9 +129,12 @@ class PasswordReset(models.Model):
|
|||
return "https://{}/password-reset/{}".format(DOMAIN, self.code)
|
||||
|
||||
|
||||
@receiver(models.signals.post_save, sender=SiteSettings)
|
||||
# pylint: disable=unused-argument
|
||||
@receiver(models.signals.post_save, sender=SiteSettings)
|
||||
def preview_image(instance, *args, **kwargs):
|
||||
"""Update image preview for the default site image"""
|
||||
if not ENABLE_PREVIEW_IMAGES:
|
||||
return
|
||||
changed_fields = instance.field_tracker.changed()
|
||||
|
||||
if len(changed_fields) > 0:
|
||||
|
|
|
@ -17,7 +17,7 @@ from bookwyrm.connectors import get_data, ConnectorException
|
|||
from bookwyrm.models.shelf import Shelf
|
||||
from bookwyrm.models.status import Status, Review
|
||||
from bookwyrm.preview_images import generate_user_preview_image_task
|
||||
from bookwyrm.settings import DOMAIN
|
||||
from bookwyrm.settings import DOMAIN, ENABLE_PREVIEW_IMAGES
|
||||
from bookwyrm.signatures import create_key_pair
|
||||
from bookwyrm.tasks import app
|
||||
from bookwyrm.utils import regex
|
||||
|
@ -452,9 +452,12 @@ def get_remote_reviews(outbox):
|
|||
activitypub.Review(**activity).to_model()
|
||||
|
||||
|
||||
@receiver(models.signals.post_save, sender=User)
|
||||
# pylint: disable=unused-argument
|
||||
@receiver(models.signals.post_save, sender=User)
|
||||
def preview_image(instance, *args, **kwargs):
|
||||
"""create preview images when user is updated"""
|
||||
if not ENABLE_PREVIEW_IMAGES:
|
||||
return
|
||||
changed_fields = instance.field_tracker.changed()
|
||||
|
||||
if len(changed_fields) > 0:
|
||||
|
|
|
@ -166,9 +166,7 @@ def generate_rating_layer(rating, content_width):
|
|||
rating_layer_base = Image.new(
|
||||
"RGBA", (content_width, icon_size), color=TRANSPARENT_COLOR
|
||||
)
|
||||
rating_layer_color = Image.new(
|
||||
"RGBA", (content_width, icon_size), color=TEXT_COLOR
|
||||
)
|
||||
rating_layer_color = Image.new("RGBA", (content_width, icon_size), color=TEXT_COLOR)
|
||||
rating_layer_mask = Image.new(
|
||||
"RGBA", (content_width, icon_size), color=TRANSPARENT_COLOR
|
||||
)
|
||||
|
@ -369,9 +367,7 @@ def generate_site_preview_image_task():
|
|||
"text_three": site.instance_tagline,
|
||||
}
|
||||
|
||||
image = generate_preview_image(
|
||||
texts=texts, picture=logo, show_instance_layer=False
|
||||
)
|
||||
image = generate_preview_image(texts=texts, picture=logo, show_instance_layer=False)
|
||||
|
||||
save_and_cleanup(image, instance=site)
|
||||
|
||||
|
|
Loading…
Reference in a new issue