mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2024-12-25 17:02:28 +00:00
Fix synthax
This commit is contained in:
parent
82efeba272
commit
001f40a033
@ -13,8 +13,6 @@ sleep 2
|
||||
python manage.py migrate
|
||||
python manage.py collectstatic --no-input
|
||||
|
||||
python manage.py runserver 0.0.0.0:8000
|
||||
|
||||
# harakiri parameter respawns processes taking more than 20 seconds
|
||||
# max-requests parameter respawns processes after serving 5000 requests
|
||||
# vacuum parameter cleans up when stopped
|
||||
|
@ -9,7 +9,7 @@ from reversion.admin import VersionAdmin
|
||||
|
||||
from med.admin import admin_site
|
||||
from .forms import MediaAdminForm
|
||||
from .models import Auteur, Emprunt, FutureMedia, Jeu, Media, Manga
|
||||
from .models import Auteur, Emprunt, FutureMedia, Jeu, Manga, Media
|
||||
|
||||
|
||||
class AuteurAdmin(VersionAdmin):
|
||||
|
@ -70,7 +70,8 @@ class MediaAdminForm(ModelForm):
|
||||
if 'publishedDate' in info:
|
||||
self.cleaned_data['publish_date'] = info['publishedDate']
|
||||
|
||||
if 'authors' not in self.cleaned_data or not self.cleaned_data['authors']:
|
||||
if 'authors' not in self.cleaned_data \
|
||||
or not self.cleaned_data['authors']:
|
||||
self.cleaned_data['authors'] = list()
|
||||
|
||||
if 'authors' in info:
|
||||
@ -143,7 +144,8 @@ class MediaAdminForm(ModelForm):
|
||||
.format(split[2], months.index(split[0])
|
||||
+ 1, int(split[1]), )
|
||||
|
||||
if 'authors' not in self.cleaned_data or not self.cleaned_data['authors']:
|
||||
if 'authors' not in self.cleaned_data \
|
||||
or not self.cleaned_data['authors']:
|
||||
self.cleaned_data['authors'] = list()
|
||||
|
||||
if 'authors' in data:
|
||||
|
@ -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)))
|
||||
|
17
media/migrations/0029_auto_20200521_1659.py
Normal file
17
media/migrations/0029_auto_20200521_1659.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by Django 2.2.10 on 2020-05-21 14:59
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('media', '0028_manga'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='manga',
|
||||
options={'ordering': ['title', 'subtitle'], 'verbose_name': 'manga', 'verbose_name_plural': 'mangas'},
|
||||
),
|
||||
]
|
Loading…
Reference in New Issue
Block a user