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.count()
12 print "\nConverting %s node states:" % n_count
13 progress = ProgressBar(n_count)
15 for n in orm.Node.objects.all():
22 state_type = "deleted"
29 action = orm.Action.objects.get(node=n, action_type="wikify")
40 if n.node_type == "question" and n.extra_action:
43 action = n.extra_action,
49 if n.node_type == "answer" and n.extra_action:
52 action = n.extra_action,
53 state_type = "accepted"
67 def backwards(self, orm):
68 "Write your backwards methods here."
72 'Meta': {'object_name': 'Group'},
73 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
74 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
75 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
78 'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
79 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
80 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
81 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
82 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
85 'Meta': {'object_name': 'User'},
86 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
87 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
88 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
89 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
90 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
91 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
92 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
93 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
94 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
95 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
96 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
97 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
98 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
100 'contenttypes.contenttype': {
101 'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
102 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
103 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
104 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
105 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
108 'Meta': {'object_name': 'Action'},
109 'action_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
110 'action_type': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
111 'canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
112 'canceled_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
113 'canceled_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'canceled_actions'", 'null': 'True', 'to': "orm['forum.User']"}),
114 'canceled_ip': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
115 'extra': ('forum.models.utils.PickledObjectField', [], {'null': 'True'}),
116 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
117 'ip': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
118 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'null': 'True', 'to': "orm['forum.Node']"}),
119 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'to': "orm['forum.User']"})
121 'forum.actionrepute': {
122 'Meta': {'object_name': 'ActionRepute'},
123 'action': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'to': "orm['forum.Action']"}),
124 'by_canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
125 'date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
126 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
127 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'to': "orm['forum.User']"}),
128 'value': ('django.db.models.fields.IntegerField', [], {'default': '0'})
130 'forum.authkeyuserassociation': {
131 'Meta': {'object_name': 'AuthKeyUserAssociation'},
132 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
133 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
134 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
135 'provider': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
136 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'auth_keys'", 'to': "orm['forum.User']"})
139 'Meta': {'unique_together': "(('user', 'badge', 'node'),)", 'object_name': 'Award'},
140 'action': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'award'", 'unique': 'True', 'to': "orm['forum.Action']"}),
141 'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
142 'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'awards'", 'to': "orm['forum.Badge']"}),
143 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
144 'node': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']", 'null': 'True'}),
145 'trigger': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'awards'", 'null': 'True', 'to': "orm['forum.Action']"}),
146 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
149 'Meta': {'object_name': 'Badge'},
150 'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
151 'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'symmetrical': 'False', 'through': "orm['forum.Award']", 'to': "orm['forum.User']"}),
152 'cls': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'}),
153 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
154 'type': ('django.db.models.fields.SmallIntegerField', [], {})
157 'Meta': {'unique_together': "(('user', 'node'),)", 'object_name': 'Flag'},
158 'action': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'flag'", 'unique': 'True', 'to': "orm['forum.Action']"}),
159 'flagged_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
160 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
161 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'flags'", 'to': "orm['forum.Node']"}),
162 'reason': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
163 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'flags'", 'to': "orm['forum.User']"})
166 'Meta': {'object_name': 'KeyValue'},
167 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
168 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
169 'value': ('forum.models.utils.PickledObjectField', [], {'null': 'True'})
172 'Meta': {'object_name': 'MarkedTag'},
173 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
174 'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
175 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['forum.Tag']"}),
176 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['forum.User']"})
179 'Meta': {'object_name': 'Node'},
180 'abs_parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'all_children'", 'null': 'True', 'to': "orm['forum.Node']"}),
181 'active_revision': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'active'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.NodeRevision']"}),
182 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
183 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'nodes'", 'to': "orm['forum.User']"}),
184 'body': ('django.db.models.fields.TextField', [], {}),
185 'deleted': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'deleted_node'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.Action']"}),
186 'extra_action': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'extra_node'", 'null': 'True', 'to': "orm['forum.Action']"}),
187 'extra_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
188 'extra_ref': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']", 'null': 'True'}),
189 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
190 'in_moderation': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'moderated_node'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.Action']"}),
191 'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
192 'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']", 'null': 'True'}),
193 'last_edited': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'edited_node'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.Action']"}),
194 'marked': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
195 'node_type': ('django.db.models.fields.CharField', [], {'default': "'node'", 'max_length': '16'}),
196 'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'children'", 'null': 'True', 'to': "orm['forum.Node']"}),
197 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
198 'state_string': ('django.db.models.fields.TextField', [], {'default': "''"}),
199 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
200 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'nodes'", 'symmetrical': 'False', 'to': "orm['forum.Tag']"}),
201 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
202 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'})
204 'forum.noderevision': {
205 'Meta': {'unique_together': "(('node', 'revision'),)", 'object_name': 'NodeRevision'},
206 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'noderevisions'", 'to': "orm['forum.User']"}),
207 'body': ('django.db.models.fields.TextField', [], {}),
208 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
209 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'revisions'", 'to': "orm['forum.Node']"}),
210 'revised_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
211 'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),
212 'summary': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
213 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
214 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'})
217 'Meta': {'unique_together': "(('node', 'state_type'),)", 'object_name': 'NodeState'},
218 'action': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'node_state'", 'unique': 'True', 'to': "orm['forum.Action']"}),
219 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
220 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'state'", 'to': "orm['forum.Node']"}),
221 'state_type': ('django.db.models.fields.CharField', [], {'max_length': '16'})
223 'forum.openidassociation': {
224 'Meta': {'object_name': 'OpenIdAssociation'},
225 'assoc_type': ('django.db.models.fields.TextField', [], {'max_length': '64'}),
226 'handle': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
227 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
228 'issued': ('django.db.models.fields.IntegerField', [], {}),
229 'lifetime': ('django.db.models.fields.IntegerField', [], {}),
230 'secret': ('django.db.models.fields.TextField', [], {'max_length': '255'}),
231 'server_url': ('django.db.models.fields.TextField', [], {'max_length': '2047'})
233 'forum.openidnonce': {
234 'Meta': {'object_name': 'OpenIdNonce'},
235 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
236 'salt': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
237 'server_url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
238 'timestamp': ('django.db.models.fields.IntegerField', [], {})
240 'forum.questionsubscription': {
241 'Meta': {'object_name': 'QuestionSubscription'},
242 'auto_subscription': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
243 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
244 'last_view': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 5, 24, 12, 26, 33, 742000)'}),
245 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']"}),
246 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
248 'forum.subscriptionsettings': {
249 'Meta': {'object_name': 'SubscriptionSettings'},
250 'all_questions': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
251 'all_questions_watched_tags': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
252 'enable_notifications': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
253 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
254 'member_joins': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),
255 'new_question': ('django.db.models.fields.CharField', [], {'default': "'d'", 'max_length': '1'}),
256 'new_question_watched_tags': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),
257 'notify_accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
258 'notify_answers': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
259 'notify_comments': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
260 'notify_comments_own_post': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
261 'notify_reply_to_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
262 'questions_answered': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
263 'questions_asked': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
264 'questions_commented': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
265 'questions_viewed': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
266 'subscribed_questions': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),
267 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'subscription_settings'", 'unique': 'True', 'to': "orm['forum.User']"})
270 'Meta': {'object_name': 'Tag'},
271 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['forum.User']"}),
272 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
273 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
274 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_tags'", 'null': 'True', 'to': "orm['forum.User']"}),
275 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
276 'marked_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'marked_tags'", 'symmetrical': 'False', 'through': "orm['forum.MarkedTag']", 'to': "orm['forum.User']"}),
277 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
278 'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
281 'Meta': {'object_name': 'User', '_ormbases': ['auth.User']},
282 'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
283 'bronze': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
284 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
285 'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
286 'gold': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
287 'is_approved': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
288 'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
289 'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
290 'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
291 'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
292 'silver': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
293 'subscriptions': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subscribers'", 'symmetrical': 'False', 'through': "orm['forum.QuestionSubscription']", 'to': "orm['forum.Node']"}),
294 'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'}),
295 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
297 'forum.validationhash': {
298 'Meta': {'unique_together': "(('user', 'type'),)", 'object_name': 'ValidationHash'},
299 'expiration': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 5, 25, 12, 26, 33, 797000)'}),
300 'hash_code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
301 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
302 'seed': ('django.db.models.fields.CharField', [], {'max_length': '12'}),
303 'type': ('django.db.models.fields.CharField', [], {'max_length': '12'}),
304 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
307 'Meta': {'unique_together': "(('user', 'node'),)", 'object_name': 'Vote'},
308 'action': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'vote'", 'unique': 'True', 'to': "orm['forum.Action']"}),
309 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
310 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['forum.Node']"}),
311 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['forum.User']"}),
312 'value': ('django.db.models.fields.SmallIntegerField', [], {}),
313 'voted_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'})
317 complete_apps = ['forum']