forked from mirrors/bookwyrm
Lint
This commit is contained in:
parent
61367c3f4f
commit
08cebd7051
2 changed files with 30 additions and 17 deletions
|
@ -10,48 +10,55 @@ class Command(BaseCommand):
|
||||||
help = "Generate preview images"
|
help = "Generate preview images"
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
parser.add_argument('--all', '-a', action="store_true", help="Generates images for ALL types: site, users and books. Can use a lot of computing power.")
|
parser.add_argument(
|
||||||
|
"--all",
|
||||||
|
"-a",
|
||||||
|
action="store_true",
|
||||||
|
help="Generates images for ALL types: site, users and books. Can use a lot of computing power.",
|
||||||
|
)
|
||||||
|
|
||||||
# pylint: disable=no-self-use,unused-argument
|
# pylint: disable=no-self-use,unused-argument
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
"""generate preview images"""
|
"""generate preview images"""
|
||||||
self.stdout.write(" | Hello! I will be generating preview images for your instance.")
|
self.stdout.write(
|
||||||
if options['all']:
|
" | Hello! I will be generating preview images for your instance."
|
||||||
|
)
|
||||||
|
if options["all"]:
|
||||||
self.stdout.write(
|
self.stdout.write(
|
||||||
"🧑🎨 ⎨ This might take quite long if your instance has a lot of books and users."
|
"🧑🎨 ⎨ This might take quite long if your instance has a lot of books and users."
|
||||||
)
|
)
|
||||||
self.stdout.write(" | ✧ Thank you for your patience ✧")
|
self.stdout.write(" | ✧ Thank you for your patience ✧")
|
||||||
else:
|
else:
|
||||||
self.stdout.write(
|
self.stdout.write("🧑🎨 ⎨ I will only generate the instance preview image.")
|
||||||
"🧑🎨 ⎨ I will only generate the instance preview image."
|
|
||||||
)
|
|
||||||
self.stdout.write(" | ✧ Be right back! ✧")
|
self.stdout.write(" | ✧ Be right back! ✧")
|
||||||
|
|
||||||
# Site
|
# Site
|
||||||
self.stdout.write(" → Site preview image: ", ending='')
|
self.stdout.write(" → Site preview image: ", ending="")
|
||||||
preview_images.generate_site_preview_image_task.delay()
|
preview_images.generate_site_preview_image_task.delay()
|
||||||
self.stdout.write(" OK 🖼")
|
self.stdout.write(" OK 🖼")
|
||||||
|
|
||||||
if options['all']:
|
if options["all"]:
|
||||||
# Users
|
# Users
|
||||||
users = models.User.objects.filter(
|
users = models.User.objects.filter(
|
||||||
local=True,
|
local=True,
|
||||||
is_active=True,
|
is_active=True,
|
||||||
)
|
)
|
||||||
self.stdout.write(" → User preview images ({}): ".format(len(users)), ending='')
|
self.stdout.write(
|
||||||
|
" → User preview images ({}): ".format(len(users)), ending=""
|
||||||
|
)
|
||||||
for user in users:
|
for user in users:
|
||||||
preview_images.generate_user_preview_image_task.delay(user.id)
|
preview_images.generate_user_preview_image_task.delay(user.id)
|
||||||
self.stdout.write(".", ending='')
|
self.stdout.write(".", ending="")
|
||||||
self.stdout.write(" OK 🖼")
|
self.stdout.write(" OK 🖼")
|
||||||
|
|
||||||
# Books
|
# Books
|
||||||
books = models.Book.objects.select_subclasses().filter()
|
books = models.Book.objects.select_subclasses().filter()
|
||||||
self.stdout.write(" → Book preview images ({}): ".format(len(books)), ending='')
|
self.stdout.write(
|
||||||
|
" → Book preview images ({}): ".format(len(books)), ending=""
|
||||||
|
)
|
||||||
for book in books:
|
for book in books:
|
||||||
preview_images.generate_edition_preview_image_task.delay(book.id)
|
preview_images.generate_edition_preview_image_task.delay(book.id)
|
||||||
self.stdout.write(".", ending='')
|
self.stdout.write(".", ending="")
|
||||||
self.stdout.write(" OK 🖼")
|
self.stdout.write(" OK 🖼")
|
||||||
|
|
||||||
self.stdout.write("🧑🎨 ⎨ I’m all done! ✧ Enjoy ✧")
|
self.stdout.write("🧑🎨 ⎨ I’m all done! ✧ Enjoy ✧")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -126,11 +126,15 @@ def generate_instance_layer(content_width):
|
||||||
|
|
||||||
|
|
||||||
def generate_rating_layer(rating, content_width):
|
def generate_rating_layer(rating, content_width):
|
||||||
icon_star_full = Image.open(os.path.join(settings.STATIC_ROOT, "images/icons/star-full.png"))
|
icon_star_full = Image.open(
|
||||||
|
os.path.join(settings.STATIC_ROOT, "images/icons/star-full.png")
|
||||||
|
)
|
||||||
icon_star_empty = Image.open(
|
icon_star_empty = Image.open(
|
||||||
os.path.join(settings.STATIC_ROOT, "images/icons/star-empty.png")
|
os.path.join(settings.STATIC_ROOT, "images/icons/star-empty.png")
|
||||||
)
|
)
|
||||||
icon_star_half = Image.open(os.path.join(settings.STATIC_ROOT, "images/icons/star-half.png"))
|
icon_star_half = Image.open(
|
||||||
|
os.path.join(settings.STATIC_ROOT, "images/icons/star-half.png")
|
||||||
|
)
|
||||||
|
|
||||||
icon_size = 64
|
icon_size = 64
|
||||||
icon_margin = 10
|
icon_margin = 10
|
||||||
|
@ -321,7 +325,9 @@ def generate_site_preview_image_task():
|
||||||
"text_three": site.instance_tagline,
|
"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)
|
save_and_cleanup(image, instance=site)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue