##// END OF EJS Templates
Use proper settings for max landing threads. Show thread last update time instead of number of posts
Use proper settings for max landing threads. Show thread last update time instead of number of posts

File last commit:

r1986:0b41439a default
r2001:6d66389f 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',
neko259
Adapt to django-2.0
r1986 field=models.ForeignKey(on_delete=models.CASCADE, to='boards.Thread', related_name='pt+'),
neko259
Made tag name field unique. Added index to "required" field for tag
r983 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,
),
]