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