mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-11 04:19:25 +00:00
Migrate albums and pictures to their own tables
This commit is contained in:
@ -109,7 +109,6 @@ class Command(BaseCommand):
|
||||
p.save(force_lock=True)
|
||||
|
||||
club_root = SithFile.objects.create(name="clubs", owner=root)
|
||||
sas = SithFile.objects.create(name="SAS", owner=root)
|
||||
main_club = Club.objects.create(
|
||||
id=1, name="AE", address="6 Boulevard Anatole France, 90000 Belfort"
|
||||
)
|
||||
@ -692,14 +691,7 @@ class Command(BaseCommand):
|
||||
# SAS
|
||||
for f in self.SAS_FIXTURE_PATH.glob("*"):
|
||||
if f.is_dir():
|
||||
album = Album(
|
||||
parent=sas,
|
||||
name=f.name,
|
||||
owner=root,
|
||||
is_folder=True,
|
||||
is_in_sas=True,
|
||||
is_moderated=True,
|
||||
)
|
||||
album = Album(name=f.name)
|
||||
album.clean()
|
||||
album.save()
|
||||
for p in f.iterdir():
|
||||
@ -707,17 +699,13 @@ class Command(BaseCommand):
|
||||
pict = Picture(
|
||||
parent=album,
|
||||
name=p.name,
|
||||
file=file,
|
||||
original=file,
|
||||
owner=root,
|
||||
is_folder=False,
|
||||
is_in_sas=True,
|
||||
is_moderated=True,
|
||||
mime_type="image/webp",
|
||||
size=file.size,
|
||||
)
|
||||
pict.file.name = p.name
|
||||
pict.full_clean()
|
||||
pict.original.name = pict.name
|
||||
pict.generate_thumbnails()
|
||||
pict.full_clean()
|
||||
pict.save()
|
||||
|
||||
img_skia = Picture.objects.get(name="skia.jpg")
|
||||
|
Reference in New Issue
Block a user