mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2025-06-21 16:38:21 +02:00
Fix synthax
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from django.core.management import BaseCommand
|
||||
|
||||
from media.forms import MediaAdminForm
|
||||
from media.models import Media, Manga
|
||||
from media.models import Manga, Media
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@ -15,11 +15,13 @@ class Command(BaseCommand):
|
||||
|
||||
for media in Media.objects.all():
|
||||
self.stdout.write(str(media))
|
||||
form = MediaAdminForm(instance=media, data={"isbn": media.isbn, "_isbn": True, })
|
||||
form = MediaAdminForm(instance=media,
|
||||
data={"isbn": media.isbn, "_isbn": True, })
|
||||
form.full_clean()
|
||||
|
||||
if not "format" in form.cleaned_data:
|
||||
self.stdout.write("Format not specified. Assume it is a comic strip.")
|
||||
if "format" not in form.cleaned_data:
|
||||
self.stdout.write("Format not specified."
|
||||
" Assume it is a comic strip.")
|
||||
continue
|
||||
|
||||
format = form.cleaned_data["format"]
|
||||
@ -27,7 +29,9 @@ class Command(BaseCommand):
|
||||
|
||||
if not options["view_only"]:
|
||||
if format == "manga":
|
||||
self.stdout.write(self.style.WARNING("This media is a manga. Transfer it into a new object..."))
|
||||
self.stdout.write(self.style.WARNING(
|
||||
"This media is a manga. "
|
||||
"Transfer it into a new object..."))
|
||||
manga = Manga.objects.create(
|
||||
isbn=media.isbn,
|
||||
title=media.title,
|
||||
@ -41,10 +45,12 @@ class Command(BaseCommand):
|
||||
manga.authors.set(media.authors.all())
|
||||
manga.save()
|
||||
|
||||
self.stdout.write(self.style.SUCCESS("Manga successfully saved. Deleting old medium..."))
|
||||
self.stdout.write(self.style.SUCCESS(
|
||||
"Manga successfully saved. Deleting old medium..."))
|
||||
|
||||
media.delete()
|
||||
self.stdout.write(self.style.SUCCESS("Medium deleted"))
|
||||
|
||||
converted += 1
|
||||
self.stdout.write(self.style.SUCCESS("Successfully saved {:d} mangas".format(converted)))
|
||||
self.stdout.write(self.style.SUCCESS(
|
||||
"Successfully saved {:d} mangas".format(converted)))
|
||||
|
Reference in New Issue
Block a user