1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-12-25 05:42:24 +00:00
This commit is contained in:
Yohann D'ANELLO 2021-11-02 12:39:53 +01:00
parent c424c7c040
commit d75250f436
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

@ -1,10 +1,9 @@
from django.core.management import BaseCommand
from django.db import transaction
from django.utils.translation import gettext_lazy as _
from tqdm import tqdm
from media.models import CD, Comic, Game, Manga, Novel, Review, Vinyl, \
OldCD, OldComic, OldGame, OldManga, OldNovel, OldReview, OldVinyl
from tqdm import tqdm
class Command(BaseCommand):
@ -17,7 +16,7 @@ class Command(BaseCommand):
help="Actually do the mogration.")
@transaction.atomic
def handle(self, *args, **options):
def handle(self, *args, **options): # noqa: C901
# Migrate books
for old_book_class, book_class in [(OldComic, Comic),
(OldManga, Manga),
@ -39,7 +38,7 @@ class Command(BaseCommand):
)
new_book.authors.set(book.authors.all())
new_book.save()
except:
except Exception:
self.stderr.write(f"There was an error with {name} "
f"{book} ({book.pk})")
raise
@ -57,7 +56,7 @@ class Command(BaseCommand):
)
new_cd.authors.set(cd.authors.all())
new_cd.save()
except:
except Exception:
self.stderr.write(f"There was an error with {cd} ({cd.pk})")
raise
@ -74,7 +73,7 @@ class Command(BaseCommand):
)
new_vinyl.authors.set(vinyl.authors.all())
new_vinyl.save()
except:
except Exception:
self.stderr.write(f"There was an error with {vinyl} "
f"({vinyl.pk})")
raise
@ -94,7 +93,7 @@ class Command(BaseCommand):
double=review.double,
present=review.present,
)
except:
except Exception:
self.stderr.write(f"There was an error with {review} "
f"({review.pk})")
raise
@ -113,7 +112,7 @@ class Command(BaseCommand):
players_max=game.players_max,
comment=game.comment,
)
except:
except Exception:
self.stderr.write(f"There was an error with {game} "
f"({game.pk})")
raise