4 from south.db import db
5 from south.v2 import DataMigration
6 from django.db import models
7 from forum.migrations import ProgressBar
10 from django.utils.safestring import mark_safe
11 from django.utils.html import strip_tags
12 from forum.utils.html import sanitize_html
14 class Migration(DataMigration):
16 def forwards(self, orm):
17 sys.path.append(os.path.join(os.path.dirname(__file__),'../markdownext'))
19 count = orm.Node.objects.count()
20 progress = ProgressBar(count)
22 for node in orm.Node.objects.all():
23 rev = node.active_revision
27 rev = node.revisions.order_by('-revision')[0]
30 node.body = sanitize_html(markdown.markdown(rev.body, ['urlize']))
34 def backwards(self, orm):
35 "Write your backwards methods here."
40 'Meta': {'object_name': 'Group'},
41 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
42 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
43 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
46 'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
47 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
48 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
49 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
50 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
53 'Meta': {'object_name': 'User'},
54 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
55 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
56 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
57 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
58 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
59 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
60 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
61 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
62 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
63 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
64 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
65 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
66 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
68 'contenttypes.contenttype': {
69 'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
70 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
71 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
72 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
73 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
76 'Meta': {'object_name': 'Action'},
77 'action_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
78 'action_type': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
79 'canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
80 'canceled_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
81 'canceled_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'canceled_actions'", 'null': 'True', 'to': "orm['forum.User']"}),
82 'canceled_ip': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
83 'extra': ('forum.models.utils.PickledObjectField', [], {'null': 'True'}),
84 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
85 'ip': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
86 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'null': 'True', 'to': "orm['forum.Node']"}),
87 'real_user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'proxied_actions'", 'null': 'True', 'to': "orm['forum.User']"}),
88 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'to': "orm['forum.User']"})
90 'forum.actionrepute': {
91 'Meta': {'object_name': 'ActionRepute'},
92 'action': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'to': "orm['forum.Action']"}),
93 'by_canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
94 'date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
95 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
96 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'to': "orm['forum.User']"}),
97 'value': ('django.db.models.fields.IntegerField', [], {'default': '0'})
99 'forum.authkeyuserassociation': {
100 'Meta': {'object_name': 'AuthKeyUserAssociation'},
101 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
102 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
103 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
104 'provider': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
105 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'auth_keys'", 'to': "orm['forum.User']"})
108 'Meta': {'unique_together': "(('user', 'badge', 'node'),)", 'object_name': 'Award'},
109 'action': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'award'", 'unique': 'True', 'to': "orm['forum.Action']"}),
110 'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
111 'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'awards'", 'to': "orm['forum.Badge']"}),
112 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
113 'node': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']", 'null': 'True'}),
114 'trigger': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'awards'", 'null': 'True', 'to': "orm['forum.Action']"}),
115 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
118 'Meta': {'object_name': 'Badge'},
119 'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
120 'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'symmetrical': 'False', 'through': "orm['forum.Award']", 'to': "orm['forum.User']"}),
121 'cls': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'}),
122 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
123 'type': ('django.db.models.fields.SmallIntegerField', [], {})
126 'Meta': {'unique_together': "(('user', 'node'),)", 'object_name': 'Flag'},
127 'action': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'flag'", 'unique': 'True', 'to': "orm['forum.Action']"}),
128 'flagged_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
129 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
130 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'flags'", 'to': "orm['forum.Node']"}),
131 'reason': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
132 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'flags'", 'to': "orm['forum.User']"})
135 'Meta': {'object_name': 'KeyValue'},
136 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
137 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
138 'value': ('forum.models.utils.PickledObjectField', [], {'null': 'True'})
141 'Meta': {'object_name': 'MarkedTag'},
142 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
143 'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
144 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['forum.Tag']"}),
145 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['forum.User']"})
148 'Meta': {'object_name': 'Node'},
149 'abs_parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'all_children'", 'null': 'True', 'to': "orm['forum.Node']"}),
150 'active_revision': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'active'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.NodeRevision']"}),
151 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
152 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'nodes'", 'to': "orm['forum.User']"}),
153 'body': ('django.db.models.fields.TextField', [], {}),
154 'extra': ('forum.models.utils.PickledObjectField', [], {'null': 'True'}),
155 'extra_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
156 'extra_ref': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']", 'null': 'True'}),
157 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
158 'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
159 'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']", 'null': 'True'}),
160 'last_edited': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'edited_node'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.Action']"}),
161 'marked': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
162 'node_type': ('django.db.models.fields.CharField', [], {'default': "'node'", 'max_length': '16'}),
163 'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'children'", 'null': 'True', 'to': "orm['forum.Node']"}),
164 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
165 'state_string': ('django.db.models.fields.TextField', [], {'default': "''"}),
166 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
167 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'nodes'", 'symmetrical': 'False', 'to': "orm['forum.Tag']"}),
168 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'})
170 'forum.noderevision': {
171 'Meta': {'unique_together': "(('node', 'revision'),)", 'object_name': 'NodeRevision'},
172 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'noderevisions'", 'to': "orm['forum.User']"}),
173 'body': ('django.db.models.fields.TextField', [], {}),
174 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
175 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'revisions'", 'to': "orm['forum.Node']"}),
176 'revised_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
177 'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),
178 'summary': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
179 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
180 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'})
183 'Meta': {'unique_together': "(('node', 'state_type'),)", 'object_name': 'NodeState'},
184 'action': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'node_state'", 'unique': 'True', 'to': "orm['forum.Action']"}),
185 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
186 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'states'", 'to': "orm['forum.Node']"}),
187 'state_type': ('django.db.models.fields.CharField', [], {'max_length': '16'})
189 'forum.questionsubscription': {
190 'Meta': {'object_name': 'QuestionSubscription'},
191 'auto_subscription': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
192 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
193 'last_view': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 12, 22, 17, 54, 20, 862306)'}),
194 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Node']"}),
195 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
197 'forum.subscriptionsettings': {
198 'Meta': {'object_name': 'SubscriptionSettings'},
199 'all_questions': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
200 'all_questions_watched_tags': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
201 'enable_notifications': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
202 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
203 'member_joins': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),
204 'new_question': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),
205 'new_question_watched_tags': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),
206 'notify_accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
207 'notify_answers': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
208 'notify_comments': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
209 'notify_comments_own_post': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
210 'notify_reply_to_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
211 'questions_answered': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
212 'questions_asked': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
213 'questions_commented': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
214 'questions_viewed': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
215 'send_digest': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
216 'subscribed_questions': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),
217 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'subscription_settings'", 'unique': 'True', 'to': "orm['forum.User']"})
220 'Meta': {'object_name': 'Tag'},
221 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['forum.User']"}),
222 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
223 'marked_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'marked_tags'", 'symmetrical': 'False', 'through': "orm['forum.MarkedTag']", 'to': "orm['forum.User']"}),
224 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
225 'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
228 'Meta': {'object_name': 'User', '_ormbases': ['auth.User']},
229 'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
230 'bronze': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
231 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
232 'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
233 'gold': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
234 'is_approved': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
235 'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
236 'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
237 'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
238 'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
239 'silver': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
240 'subscriptions': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subscribers'", 'symmetrical': 'False', 'through': "orm['forum.QuestionSubscription']", 'to': "orm['forum.Node']"}),
241 'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'}),
242 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
244 'forum.userproperty': {
245 'Meta': {'unique_together': "(('user', 'key'),)", 'object_name': 'UserProperty'},
246 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
247 'key': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
248 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'properties'", 'to': "orm['forum.User']"}),
249 'value': ('forum.models.utils.PickledObjectField', [], {'null': 'True'})
251 'forum.validationhash': {
252 'Meta': {'unique_together': "(('user', 'type'),)", 'object_name': 'ValidationHash'},
253 'expiration': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 12, 23, 17, 54, 20, 937539)'}),
254 'hash_code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
255 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
256 'seed': ('django.db.models.fields.CharField', [], {'max_length': '12'}),
257 'type': ('django.db.models.fields.CharField', [], {'max_length': '12'}),
258 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})
261 'Meta': {'unique_together': "(('user', 'node'),)", 'object_name': 'Vote'},
262 'action': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'vote'", 'unique': 'True', 'to': "orm['forum.Action']"}),
263 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
264 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['forum.Node']"}),
265 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['forum.User']"}),
266 'value': ('django.db.models.fields.SmallIntegerField', [], {}),
267 'voted_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'})
271 complete_apps = ['forum']