##// END OF EJS Templates
Show localized tags under the proper letter section in all tags list. Cache localized tag name, not the whole view
Show localized tags under the proper letter section in all tags list. Cache localized tag name, not the whole view

File last commit:

r1866:fccf814a default
r1892:0808e889 default
Show More
0059_auto_20170227_1156.py
31 lines | 968 B | text/x-python | PythonLexer
/ boards / migrations / 0059_auto_20170227_1156.py
neko259
Use mimetype instead of extensions for file type wherever it is used
r1866 # -*- 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),
]