##// END OF EJS Templates
Do not try to add an attachment ref for external attachment if there is an internal and external attachment in the same post
Do not try to add an attachment ref for external attachment if there is an internal and external attachment in the same post

File last commit:

r983:c3e4aa3e default
r1839:4c8bff54 default
Show More
0010_auto_20150208_1451.py
44 lines | 1.4 KiB | text/x-python | PythonLexer
/ boards / migrations / 0010_auto_20150208_1451.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
def clean_duplicate_tags(apps, schema_editor):
Tag = apps.get_model('boards', 'Tag')
for tag in Tag.objects.all():
tags_with_same_name = Tag.objects.filter(name=tag.name).all()
if len(tags_with_same_name) > 1:
for tag_duplicate in tags_with_same_name[1:]:
threads = tag_duplicate.thread_set.all()
for thread in threads:
thread.tags.add(tag)
tag_duplicate.delete()
dependencies = [
('boards', '0009_post_thread'),
]
operations = [
migrations.AlterField(
model_name='post',
name='thread',
field=models.ForeignKey(to='boards.Thread', related_name='pt+'),
preserve_default=True,
),
migrations.RunPython(clean_duplicate_tags),
migrations.AlterField(
model_name='tag',
name='name',
field=models.CharField(db_index=True, unique=True, max_length=100),
preserve_default=True,
),
migrations.AlterField(
model_name='tag',
name='required',
field=models.BooleanField(db_index=True, default=False),
preserve_default=True,
),
]