##// END OF EJS Templates
Show thread OPs in the landing page instead of link and title list
Show thread OPs in the landing page instead of link and title list

File last commit:

r983:c3e4aa3e default
r1793:9acfb664 default
Show More
0010_auto_20150208_1451.py
44 lines | 1.4 KiB | text/x-python | PythonLexer
/ boards / migrations / 0010_auto_20150208_1451.py
neko259
Made tag name field unique. Added index to "required" field for tag
r983 # -*- 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,
),
]