improve path info migration

This commit is contained in:
j 2013-02-08 19:19:46 +00:00
parent 459ab5ea97
commit a253d29d1a

View file

@ -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."