improve path info migration
This commit is contained in:
parent
459ab5ea97
commit
a253d29d1a
1 changed files with 11 additions and 4 deletions
|
@ -7,10 +7,17 @@ from django.db import models
|
||||||
class Migration(DataMigration):
|
class Migration(DataMigration):
|
||||||
|
|
||||||
def forwards(self, orm):
|
def forwards(self, orm):
|
||||||
for f in orm['archive.File'].objects.exclude(path_info={}):
|
for f in orm['archive.File'].objects.all():
|
||||||
f.info.update(f.path_info)
|
update = False
|
||||||
f.path_info = {}
|
if f.path_info:
|
||||||
f.save()
|
f.info.update(f.path_info)
|
||||||
|
f.path_info = {}
|
||||||
|
update = True
|
||||||
|
if not 'extension' in f.info and f.path:
|
||||||
|
f.info['extension'] = f.path.split('.')[-1]
|
||||||
|
update = True
|
||||||
|
if update:
|
||||||
|
f.save()
|
||||||
|
|
||||||
def backwards(self, orm):
|
def backwards(self, orm):
|
||||||
"Write your backwards methods here."
|
"Write your backwards methods here."
|
||||||
|
|
Loading…
Reference in a new issue