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,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):