33 lines
852 B
Python
33 lines
852 B
Python
|
# -*- coding: utf-8 -*-
|
||
|
# Generated by Django 1.10.4 on 2017-01-20 18:44
|
||
|
from __future__ import unicode_literals
|
||
|
|
||
|
from django.db import migrations, models
|
||
|
|
||
|
def copy_filehash(apps, schema_editor):
|
||
|
DBFile = apps.get_model('dbfilestorage', 'DBFile')
|
||
|
for dbf in DBFile.objects.all():
|
||
|
dbf.filehash = dbf.name
|
||
|
dbf.save()
|
||
|
|
||
|
def fix_filename(apps, schema_editor):
|
||
|
DBFile = apps.get_model('dbfilestorage', 'DBFile')
|
||
|
for dbf in DBFile.objects.all():
|
||
|
ext = dbf.content_type.split("/")[0]
|
||
|
dbf.name = "{name}.{ext}".format(
|
||
|
name=dbf.name,
|
||
|
ext=ext)
|
||
|
dbf.save()
|
||
|
|
||
|
|
||
|
class Migration(migrations.Migration):
|
||
|
|
||
|
dependencies = [
|
||
|
('dbfilestorage', '0001_initial'),
|
||
|
]
|
||
|
|
||
|
operations = [
|
||
|
migrations.RunPython(copy_filehash),
|
||
|
migrations.RunPython(fix_filename),
|
||
|
]
|