Show More
@@ -1,81 +1,75 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | import datetime |
|
3 | 3 | from south.db import db |
|
4 | 4 | from south.v2 import SchemaMigration |
|
5 | 5 | from django.db import models |
|
6 | 6 | from boards.models import Post, NO_PARENT |
|
7 | 7 | |
|
8 | 8 | |
|
9 | 9 | class Migration(SchemaMigration): |
|
10 | 10 | |
|
11 | 11 | def forwards(self, orm): |
|
12 | 12 | # Adding M2M table for field replies on 'Post' |
|
13 | 13 | m2m_table_name = db.shorten_name(u'boards_post_replies') |
|
14 | 14 | db.create_table(m2m_table_name, ( |
|
15 | 15 | ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), |
|
16 | 16 | ('from_post', models.ForeignKey(orm[u'boards.post'], null=False)), |
|
17 | 17 | ('to_post', models.ForeignKey(orm[u'boards.post'], null=False)) |
|
18 | 18 | )) |
|
19 | 19 | db.create_unique(m2m_table_name, ['from_post_id', 'to_post_id']) |
|
20 | 20 | |
|
21 | for post in Post.objects.all(): | |
|
22 | if post.parent != NO_PARENT: | |
|
23 | parent = Post.objects.get(id=post.parent) | |
|
24 | parent.replies.add(post) | |
|
25 | ||
|
26 | ||
|
27 | 21 | def backwards(self, orm): |
|
28 | 22 | # Removing M2M table for field replies on 'Post' |
|
29 | 23 | db.delete_table(db.shorten_name(u'boards_post_replies')) |
|
30 | 24 | |
|
31 | 25 | |
|
32 | 26 | models = { |
|
33 | 27 | u'boards.ban': { |
|
34 | 28 | 'Meta': {'object_name': 'Ban'}, |
|
35 | 29 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|
36 | 30 | 'ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}) |
|
37 | 31 | }, |
|
38 | 32 | u'boards.post': { |
|
39 | 33 | 'Meta': {'object_name': 'Post'}, |
|
40 | 34 | '_text_rendered': ('django.db.models.fields.TextField', [], {}), |
|
41 | 35 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|
42 | 36 | 'image': ('boards.thumbs.ImageWithThumbsField', [], {'max_length': '100', 'blank': 'True'}), |
|
43 | 37 | 'image_height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), |
|
44 | 38 | 'image_width': ('django.db.models.fields.IntegerField', [], {'default': '0'}), |
|
45 | 39 | 'last_edit_time': ('django.db.models.fields.DateTimeField', [], {}), |
|
46 | 40 | 'parent': ('django.db.models.fields.BigIntegerField', [], {}), |
|
47 | 41 | 'poster_ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}), |
|
48 | 42 | 'poster_user_agent': ('django.db.models.fields.TextField', [], {}), |
|
49 | 43 | 'pub_time': ('django.db.models.fields.DateTimeField', [], {}), |
|
50 | 44 | 'replies': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'re+'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['boards.Post']"}), |
|
51 | 45 | 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['boards.Tag']", 'symmetrical': 'False'}), |
|
52 | 46 | 'text': ('markupfield.fields.MarkupField', [], {'rendered_field': 'True'}), |
|
53 | 47 | 'text_markup_type': ('django.db.models.fields.CharField', [], {'default': "'markdown'", 'max_length': '30'}), |
|
54 | 48 | 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}), |
|
55 | 49 | 'user': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['boards.User']", 'null': 'True'}) |
|
56 | 50 | }, |
|
57 | 51 | u'boards.setting': { |
|
58 | 52 | 'Meta': {'object_name': 'Setting'}, |
|
59 | 53 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|
60 | 54 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}), |
|
61 | 55 | 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['boards.User']"}), |
|
62 | 56 | 'value': ('django.db.models.fields.CharField', [], {'max_length': '50'}) |
|
63 | 57 | }, |
|
64 | 58 | u'boards.tag': { |
|
65 | 59 | 'Meta': {'object_name': 'Tag'}, |
|
66 | 60 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|
67 | 61 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) |
|
68 | 62 | }, |
|
69 | 63 | u'boards.user': { |
|
70 | 64 | 'Meta': {'object_name': 'User'}, |
|
71 | 65 | 'fav_tags': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['boards.Tag']", 'null': 'True', 'blank': 'True'}), |
|
72 | 66 | 'fav_threads': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['boards.Post']"}), |
|
73 | 67 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|
74 | 68 | 'last_access_time': ('django.db.models.fields.DateTimeField', [], {}), |
|
75 | 69 | 'rank': ('django.db.models.fields.IntegerField', [], {}), |
|
76 | 70 | 'registration_time': ('django.db.models.fields.DateTimeField', [], {}), |
|
77 | 71 | 'user_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}) |
|
78 | 72 | } |
|
79 | 73 | } |
|
80 | 74 | |
|
81 | 75 | complete_apps = ['boards'] No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now