Browse Source

Corrige bug na migração dos banners dos eventos

pull/166/head
Sesóstris Vieira 1 year ago
parent
commit
c2ceb845db
  1. 6
      sigi/apps/eventos/migrations/0045_alter_evento_banner.py

6
sigi/apps/eventos/migrations/0045_alter_evento_banner.py

@ -11,7 +11,8 @@ def forwards(apps, schema_editor):
for e in Evento.objects.exclude(banner="").exclude(banner=None):
old_file = Path(e.banner.path)
if old_file.exists():
new_file = upload_to / e.banner.name
new_file = upload_to / old_file.name
if not old_file.samefile(new_file):
old_file.rename(new_file)
e.banner = str(new_file.resolve())
else:
@ -24,7 +25,8 @@ def backwards(apps, schema_editor):
for e in Evento.objects.exclude(banner="").exclude(banner=None):
new_file = Path(e.banner.path)
if new_file.exists():
old_file = settings.MEDIA_ROOT / e.banner.name
old_file = settings.MEDIA_ROOT / new_file.name
if not old_file.samefile(new_file):
new_file.rename(old_file)
e.banner = str(old_file.resolve())
else:

Loading…
Cancel
Save