forked from 0x2620/pandora
improve path info migration
This commit is contained in:
parent
459ab5ea97
commit
a253d29d1a
1 changed files with 11 additions and 4 deletions
|
@ -7,9 +7,16 @@ from django.db import models
|
|||
class Migration(DataMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
for f in orm['archive.File'].objects.exclude(path_info={}):
|
||||
for f in orm['archive.File'].objects.all():
|
||||
update = False
|
||||
if f.path_info:
|
||||
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):
|
||||
|
|
Loading…
Reference in a new issue