3 from south.db import db
4 from south.v2 import DataMigration
5 from django.db import models
6 from forum.migrations import ProgressBar
8 class Migration(DataMigration):
10 def forwards(self, orm):
11 n_count = orm.Node.objects.all().count()
12 print "\nReseting %d nodes:" % n_count
13 progress = ProgressBar(n_count)
15 for n in orm.Node.objects.all():
17 d = orm.Action.objects.get(node=n, action_type="delete", canceled=False)
22 if orm.Action.objects.filter(node=n, action_type="revise").count() > 0:
23 n.last_edited_id = orm.Action.objects.filter(node=n, action_type="revise").order_by('-action_date')[0].id
28 if n.node_type == "answer" and n.marked:
29 n.extra_action_id = orm.Action.objects.get(node=n, action_type="acceptanswer", canceled=False).id
31 if n.node_type == "question" and n.marked:
32 n.extra_action_id = orm.Action.objects.get(node=n, action_type="close", canceled=False).id
41 def backwards(self, orm):
42 "Write your backwards methods here."
46 'Meta': {'object_name': 'Group'},
47 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
48 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
49 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'})
52 'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
53 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
54 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
55 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
56 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
59 'Meta': {'object_name': 'User'},
60 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
61 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
62 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
63 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'blank': 'True'}),
64 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
65 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
66 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
67 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
68 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
69 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
70 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
71 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'}),
72 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
74 'contenttypes.contenttype': {
75 'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
76 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
77 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
78 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
79 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
82 'Meta': {'object_name': 'Action'},
83 'action_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
84 'action_type': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
85 'canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
86 'canceled_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
87 'canceled_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'canceled_actions'", 'null': 'True', 'to': "orm['forum.User']"}),
88 'extra': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
89 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
90 'ip': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
91 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'null': 'True', 'to': "orm['forum.Node']"}),
92 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'to': "orm['forum.User']"})
94 'forum.actionrepute': {
95 'Meta': {'object_name': 'ActionRepute'},
96 'action': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'to': "orm['forum.Action']"}),
97 'by_canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
98 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
99 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'to': "orm['forum.User']"}),
100 'value': ('django.db.models.fields.IntegerField', [], {'default': '0'})
103 'Meta': {'object_name': 'Activity', 'db_table': "u'activity'"},
104 'active_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
105 'activity_type': ('django.db.models.fields.SmallIntegerField', [], {}),
106 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
107 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
108 'is_auditted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
109 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
110 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
112 'forum.authkeyuserassociation': {
113 'Meta': {'object_name': 'AuthKeyUserAssociation'},
114 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
115 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
116 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
117 'provider': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
118 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'auth_keys'", 'to': "orm['forum.User']"})
121 'Meta': {'object_name': 'Award', 'db_table': "u'award'"},
122 'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
123 'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_badge'", 'to': "orm['forum.Badge']"}),
124 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
125 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
126 'notified': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
127 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
128 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'awards'", 'to': "orm['forum.User']"})
131 'Meta': {'unique_together': "(('name', 'type'),)", 'object_name': 'Badge', 'db_table': "u'badge'"},
132 'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
133 'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'through': "'Award'", 'to': "orm['forum.User']"}),
134 'description': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
135 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
136 'multiple': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
137 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
138 'slug': ('django.db.models.fields.SlugField', [], {'db_index': 'True', 'max_length': '50', 'blank': 'True'}),
139 'type': ('django.db.models.fields.SmallIntegerField', [], {})
142 'Meta': {'object_name': 'KeyValue'},
143 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
144 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
145 'value': ('forum.models.utils.PickledObjectField', [], {})
148 'Meta': {'object_name': 'MarkedTag'},
149 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
150 'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
151 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['forum.Tag']"}),
152 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['forum.User']"})
155 'Meta': {'object_name': 'Node'},
156 'abs_parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'all_children'", 'null': 'True', 'to': "orm['forum.Node']"}),
157 'active_revision': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'active'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.NodeRevision']"}),
158 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
159 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'nodes'", 'to': "orm['forum.User']"}),
160 'body': ('django.db.models.fields.TextField', [], {}),
161 'deleted': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'deleted_node'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.Action']"}),
162 'extra_action': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'extra_node'", 'null': 'True', 'to': "orm['forum.Action']"}),
163 'extra_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
164 'extra_ref': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']", 'null': 'True'}),
165 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
166 'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
167 'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']", 'null': 'True'}),
168 'last_edited': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'edited_node'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.Action']"}),
169 'marked': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
170 'node_type': ('django.db.models.fields.CharField', [], {'default': "'node'", 'max_length': '16'}),
171 'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'children'", 'null': 'True', 'to': "orm['forum.Node']"}),
172 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
173 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
174 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'nodes'", 'to': "orm['forum.Tag']"}),
175 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
176 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'})
178 'forum.noderevision': {
179 'Meta': {'unique_together': "(('node', 'revision'),)", 'object_name': 'NodeRevision'},
180 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'noderevisions'", 'to': "orm['forum.User']"}),
181 'body': ('django.db.models.fields.TextField', [], {}),
182 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
183 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'revisions'", 'to': "orm['forum.Node']"}),
184 'revised_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
185 'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),
186 'summary': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
187 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
188 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'})
190 'forum.openidassociation': {
191 'Meta': {'object_name': 'OpenIdAssociation'},
192 'assoc_type': ('django.db.models.fields.TextField', [], {'max_length': '64'}),
193 'handle': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
194 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
195 'issued': ('django.db.models.fields.IntegerField', [], {}),
196 'lifetime': ('django.db.models.fields.IntegerField', [], {}),
197 'secret': ('django.db.models.fields.TextField', [], {'max_length': '255'}),
198 'server_url': ('django.db.models.fields.TextField', [], {'max_length': '2047'})
200 'forum.openidnonce': {
201 'Meta': {'object_name': 'OpenIdNonce'},
202 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
203 'salt': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
204 'server_url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
205 'timestamp': ('django.db.models.fields.IntegerField', [], {})
207 'forum.questionsubscription': {
208 'Meta': {'object_name': 'QuestionSubscription'},
209 'auto_subscription': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
210 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
211 'last_view': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 4, 28, 23, 55, 36, 647000)'}),
212 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']"}),
213 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
215 'forum.subscriptionsettings': {
216 'Meta': {'object_name': 'SubscriptionSettings'},
217 'all_questions': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
218 'all_questions_watched_tags': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
219 'enable_notifications': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
220 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
221 'member_joins': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),
222 'new_question': ('django.db.models.fields.CharField', [], {'default': "'d'", 'max_length': '1'}),
223 'new_question_watched_tags': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),
224 'notify_accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
225 'notify_answers': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
226 'notify_comments': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
227 'notify_comments_own_post': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
228 'notify_reply_to_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
229 'questions_answered': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
230 'questions_asked': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
231 'questions_commented': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
232 'questions_viewed': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
233 'subscribed_questions': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),
234 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'subscription_settings'", 'unique': 'True', 'to': "orm['forum.User']"})
237 'Meta': {'object_name': 'Tag', 'db_table': "u'tag'"},
238 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['forum.User']"}),
239 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
240 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
241 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_tags'", 'null': 'True', 'to': "orm['forum.User']"}),
242 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
243 'marked_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'marked_tags'", 'through': "'MarkedTag'", 'to': "orm['forum.User']"}),
244 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
245 'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
248 'Meta': {'object_name': 'User', '_ormbases': ['auth.User']},
249 'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
250 'bronze': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
251 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
252 'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
253 'email_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
254 'gold': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
255 'hide_ignored_questions': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
256 'is_approved': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
257 'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
258 'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
259 'questions_per_page': ('django.db.models.fields.SmallIntegerField', [], {'default': '10'}),
260 'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
261 'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
262 'silver': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
263 'subscriptions': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subscribers'", 'through': "'QuestionSubscription'", 'to': "orm['forum.Node']"}),
264 'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'}),
265 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
267 'forum.validationhash': {
268 'Meta': {'unique_together': "(('user', 'type'),)", 'object_name': 'ValidationHash'},
269 'expiration': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 4, 29, 23, 55, 36, 708000)'}),
270 'hash_code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
271 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
272 'seed': ('django.db.models.fields.CharField', [], {'max_length': '12'}),
273 'type': ('django.db.models.fields.CharField', [], {'max_length': '12'}),
274 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
278 complete_apps = ['forum']