##// END OF EJS Templates
AJAX-based thread creation
AJAX-based thread creation

File last commit:

r1866:fccf814a default
r1998:8255ca3c default
Show More
0059_auto_20170227_1156.py
31 lines | 968 B | text/x-python | PythonLexer
/ boards / migrations / 0059_auto_20170227_1156.py
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-27 09:56
from __future__ import unicode_literals
from django.db import migrations
from django.db.models import Q
from django.db import models
from boards.utils import get_file_mimetype
class Migration(migrations.Migration):
def extension_to_mimetype(apps, schema_editor):
Attachment = apps.get_model('boards', 'Attachment')
for attachment in Attachment.objects.filter(Q(url='') | Q(url=None)):
attachment.mimetype = get_file_mimetype(attachment.file)
attachment.save(update_fields=['mimetype'])
attachment.file.close()
dependencies = [
('boards', '0058_auto_20170224_2310'),
]
operations = [
migrations.AlterField(
model_name='attachment',
name='mimetype',
field=models.CharField(max_length=200, null=True),
),
migrations.RunPython(extension_to_mimetype),
]