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 a_count = orm.Action.objects.filter(action_type="bonusrep").count()
12 print "\nConverting %s bonus actions:" % a_count
13 progress = ProgressBar(a_count)
15 for a in orm.Action.objects.filter(action_type="bonusrep"):
16 a.user = orm.User.objects.get(id=a.extra['awarding_user'])
24 s_count = orm.Action.objects.filter(action_type="suspend").count()
25 print "\nConverting %s suspend actions:" % a_count
26 progress = ProgressBar(s_count)
28 for a in orm.Action.objects.filter(action_type="suspend"):
31 a.user = orm.User.objects.get(id=a.extra['suspender'])
34 rep = orm.ActionRepute(user=suspended, action=a, value=0, date=a.action_date)
41 a_count = orm.Action.objects.filter(action_type="award").count()
42 print "\nConverting %s award actions:" % a_count
43 progress = ProgressBar(a_count)
45 for a in orm.Action.objects.filter(action_type="award"):
55 def backwards(self, orm):
56 "Write your backwards methods here."
61 'Meta': {'object_name': 'Group'},
62 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
63 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
64 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
67 'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
68 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
69 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
70 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
71 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
74 'Meta': {'object_name': 'User'},
75 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
76 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
77 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
78 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
79 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
80 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
81 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
82 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
83 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
84 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
85 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
86 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
87 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
89 'contenttypes.contenttype': {
90 'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
91 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
92 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
93 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
94 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
97 'Meta': {'object_name': 'Action'},
98 'action_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
99 'action_type': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
100 'canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
101 'canceled_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
102 'canceled_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'canceled_actions'", 'null': 'True', 'to': "orm['forum.User']"}),
103 'canceled_ip': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
104 'extra': ('forum.models.utils.PickledObjectField', [], {'null': 'True'}),
105 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
106 'ip': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
107 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'null': 'True', 'to': "orm['forum.Node']"}),
108 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'to': "orm['forum.User']"})
110 'forum.actionrepute': {
111 'Meta': {'object_name': 'ActionRepute'},
112 'action': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'to': "orm['forum.Action']"}),
113 'by_canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
114 'date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
115 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
116 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'to': "orm['forum.User']"}),
117 'value': ('django.db.models.fields.IntegerField', [], {'default': '0'})
119 'forum.authkeyuserassociation': {
120 'Meta': {'object_name': 'AuthKeyUserAssociation'},
121 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
122 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
123 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
124 'provider': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
125 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'auth_keys'", 'to': "orm['forum.User']"})
128 'Meta': {'unique_together': "(('user', 'badge', 'node'),)", 'object_name': 'Award'},
129 'action': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'award'", 'unique': 'True', 'to': "orm['forum.Action']"}),
130 'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
131 'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'awards'", 'to': "orm['forum.Badge']"}),
132 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
133 'node': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']", 'null': 'True'}),
134 'trigger': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'awards'", 'null': 'True', 'to': "orm['forum.Action']"}),
135 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
138 'Meta': {'object_name': 'Badge'},
139 'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
140 'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'symmetrical': 'False', 'through': "orm['forum.Award']", 'to': "orm['forum.User']"}),
141 'cls': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'}),
142 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
143 'type': ('django.db.models.fields.SmallIntegerField', [], {})
146 'Meta': {'unique_together': "(('user', 'node'),)", 'object_name': 'Flag'},
147 'action': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'flag'", 'unique': 'True', 'to': "orm['forum.Action']"}),
148 'flagged_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
149 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
150 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'flags'", 'to': "orm['forum.Node']"}),
151 'reason': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
152 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'flags'", 'to': "orm['forum.User']"})
155 'Meta': {'object_name': 'KeyValue'},
156 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
157 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
158 'value': ('forum.models.utils.PickledObjectField', [], {'null': 'True'})
161 'Meta': {'object_name': 'MarkedTag'},
162 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
163 'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
164 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['forum.Tag']"}),
165 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['forum.User']"})
168 'Meta': {'object_name': 'Node'},
169 'abs_parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'all_children'", 'null': 'True', 'to': "orm['forum.Node']"}),
170 'active_revision': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'active'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.NodeRevision']"}),
171 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
172 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'nodes'", 'to': "orm['forum.User']"}),
173 'body': ('django.db.models.fields.TextField', [], {}),
174 'extra': ('forum.models.utils.PickledObjectField', [], {'null': 'True'}),
175 'extra_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
176 'extra_ref': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']", 'null': 'True'}),
177 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
178 'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
179 'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']", 'null': 'True'}),
180 'last_edited': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'edited_node'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.Action']"}),
181 'marked': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
182 'node_type': ('django.db.models.fields.CharField', [], {'default': "'node'", 'max_length': '16'}),
183 'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'children'", 'null': 'True', 'to': "orm['forum.Node']"}),
184 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
185 'state_string': ('django.db.models.fields.TextField', [], {'default': "''"}),
186 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
187 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'nodes'", 'symmetrical': 'False', 'to': "orm['forum.Tag']"}),
188 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'})
190 'forum.noderevision': {
191 'Meta': {'unique_together': "(('node', 'revision'),)", 'object_name': 'NodeRevision'},
192 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'noderevisions'", 'to': "orm['forum.User']"}),
193 'body': ('django.db.models.fields.TextField', [], {}),
194 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
195 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'revisions'", 'to': "orm['forum.Node']"}),
196 'revised_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
197 'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),
198 'summary': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
199 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
200 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'})
203 'Meta': {'unique_together': "(('node', 'state_type'),)", 'object_name': 'NodeState'},
204 'action': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'node_state'", 'unique': 'True', 'to': "orm['forum.Action']"}),
205 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
206 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'states'", 'to': "orm['forum.Node']"}),
207 'state_type': ('django.db.models.fields.CharField', [], {'max_length': '16'})
209 'forum.openidassociation': {
210 'Meta': {'object_name': 'OpenIdAssociation'},
211 'assoc_type': ('django.db.models.fields.TextField', [], {'max_length': '64'}),
212 'handle': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
213 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
214 'issued': ('django.db.models.fields.IntegerField', [], {}),
215 'lifetime': ('django.db.models.fields.IntegerField', [], {}),
216 'secret': ('django.db.models.fields.TextField', [], {'max_length': '255'}),
217 'server_url': ('django.db.models.fields.TextField', [], {'max_length': '2047'})
219 'forum.openidnonce': {
220 'Meta': {'object_name': 'OpenIdNonce'},
221 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
222 'salt': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
223 'server_url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
224 'timestamp': ('django.db.models.fields.IntegerField', [], {})
226 'forum.questionsubscription': {
227 'Meta': {'object_name': 'QuestionSubscription'},
228 'auto_subscription': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
229 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
230 'last_view': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 6, 13, 16, 42, 20, 908594)'}),
231 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']"}),
232 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
234 'forum.subscriptionsettings': {
235 'Meta': {'object_name': 'SubscriptionSettings'},
236 'all_questions': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
237 'all_questions_watched_tags': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
238 'enable_notifications': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
239 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
240 'member_joins': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),
241 'new_question': ('django.db.models.fields.CharField', [], {'default': "'d'", 'max_length': '1'}),
242 'new_question_watched_tags': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),
243 'notify_accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
244 'notify_answers': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
245 'notify_comments': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
246 'notify_comments_own_post': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
247 'notify_reply_to_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
248 'questions_answered': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
249 'questions_asked': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
250 'questions_commented': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
251 'questions_viewed': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
252 'subscribed_questions': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),
253 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'subscription_settings'", 'unique': 'True', 'to': "orm['forum.User']"})
256 'Meta': {'object_name': 'Tag'},
257 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['forum.User']"}),
258 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
259 'marked_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'marked_tags'", 'symmetrical': 'False', 'through': "orm['forum.MarkedTag']", 'to': "orm['forum.User']"}),
260 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
261 'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
264 'Meta': {'object_name': 'User', '_ormbases': ['auth.User']},
265 'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
266 'bronze': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
267 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
268 'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
269 'gold': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
270 'is_approved': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
271 'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
272 'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
273 'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
274 'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
275 'silver': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
276 'subscriptions': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subscribers'", 'symmetrical': 'False', 'through': "orm['forum.QuestionSubscription']", 'to': "orm['forum.Node']"}),
277 'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'}),
278 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
280 'forum.validationhash': {
281 'Meta': {'unique_together': "(('user', 'type'),)", 'object_name': 'ValidationHash'},
282 'expiration': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 6, 14, 16, 42, 20, 944052)'}),
283 'hash_code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
284 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
285 'seed': ('django.db.models.fields.CharField', [], {'max_length': '12'}),
286 'type': ('django.db.models.fields.CharField', [], {'max_length': '12'}),
287 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
290 'Meta': {'unique_together': "(('user', 'node'),)", 'object_name': 'Vote'},
291 'action': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'vote'", 'unique': 'True', 'to': "orm['forum.Action']"}),
292 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
293 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['forum.Node']"}),
294 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['forum.User']"}),
295 'value': ('django.db.models.fields.SmallIntegerField', [], {}),
296 'voted_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'})
300 complete_apps = ['forum']