user_logged_in = django.dispatch.Signal(providing_args=["user", "old_session"])
user_updated = django.dispatch.Signal(providing_args=["instance", "updated_by"])
-def post_stored_anonymous_content(user,old_session,**kwargs):
- from forum.models import AnonymousQuestion, AnonymousAnswer
- aq_list = AnonymousQuestion.objects.filter(session_key = old_session)
- aa_list = AnonymousAnswer.objects.filter(session_key = old_session)
- import settings
- if settings.EMAIL_VALIDATION == 'on':#add user to the record
- for aq in aq_list:
- aq.author = user
- aq.save()
- for aa in aa_list:
- aa.author = user
- aa.save()
- #maybe add pending posts message?
- else: #just publish the questions
- for aq in aq_list:
- aq.publish(user)
- for aa in aa_list:
- aa.publish(user)
-
-user_logged_in.connect(post_stored_anonymous_content)
\ No newline at end of file
+#def post_stored_anonymous_content(user,old_session,**kwargs):
+# from forum.models import AnonymousQuestion, AnonymousAnswer
+# aq_list = AnonymousQuestion.objects.filter(session_key = old_session)
+# aa_list = AnonymousAnswer.objects.filter(session_key = old_session)
+# import settings
+# if settings.EMAIL_VALIDATION == 'on':#add user to the record
+# for aq in aq_list:
+# aq.author = user
+# aq.save()
+# for aa in aa_list:
+# aa.author = user
+# aa.save()
+# #maybe add pending posts message?
+# else: #just publish the questions
+# for aq in aq_list:
+# aq.publish(user)
+# for aa in aa_list:
+# aa.publish(user)
+#
+#user_logged_in.connect(post_stored_anonymous_content)
\ No newline at end of file
print "\nConverting %d comments:" % c_count\r
progress = ProgressBar(c_count)\r
\r
+ id_map = {}\r
+\r
for c in orm.Comment.objects.all():\r
node = orm.Node(\r
node_type='comment',\r
)\r
node.save()\r
\r
+ id_map[c.id] = node\r
+\r
revision = orm.NodeRevision(\r
summary="Initial revsion",\r
revision=1,\r
progress.update()\r
\r
print "\n...done\n"\r
+\r
+ ctype = orm['contenttypes.ContentType'].objects.get(name="comment").id\r
+ ntype = orm['contenttypes.ContentType'].objects.get(name="node").id\r
+\r
+ #Converting activity\r
+ activities = orm.Activity.objects.filter(content_type__id=ctype)\r
+ activity_count = activities.count()\r
+ print "Converting %d activity references:" % activity_count\r
+ progress = ProgressBar(activity_count)\r
+\r
+ for a in activities:\r
+ node = id_map.get(a.object_id, None)\r
+ if node:\r
+ a.content_type_id = ntype\r
+ a.object_id = node.id\r
+ a.save()\r
+\r
+ progress.update()\r
+\r
+ print "\n...done\n"\r
\r
\r
def backwards(self, orm):\r
--- /dev/null
+# encoding: utf-8\r
+import datetime\r
+from south.db import db\r
+from south.v2 import SchemaMigration\r
+from django.db import models\r
+\r
+class Migration(SchemaMigration):\r
+ \r
+ def forwards(self, orm):\r
+ \r
+ # Deleting model 'LikedComment'\r
+ db.delete_table('forum_likedcomment')\r
+\r
+ # Deleting model 'Comment'\r
+ db.delete_table(u'comment')\r
+\r
+ # Adding field 'Node.abs_parent'\r
+ db.add_column('forum_node', 'abs_parent', self.gf('django.db.models.fields.related.ForeignKey')(related_name='all_children', null=True, to=orm['forum.Node']), keep_default=False)\r
+\r
+ # Changing field 'Question.last_activity_by'\r
+ db.alter_column(u'question', 'last_activity_by_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['forum.User']))\r
+ \r
+ \r
+ def backwards(self, orm):\r
+ \r
+ # Adding model 'LikedComment'\r
+ db.create_table('forum_likedcomment', (\r
+ ('comment', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['forum.Comment'])),\r
+ ('canceled', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True)),\r
+ ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['forum.User'])),\r
+ ('added_at', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),\r
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),\r
+ ))\r
+ db.send_create_signal('forum', ['LikedComment'])\r
+\r
+ # Adding model 'Comment'\r
+ db.create_table(u'comment', (\r
+ ('comment', self.gf('django.db.models.fields.CharField')(max_length=300)),\r
+ ('node', self.gf('django.db.models.fields.related.ForeignKey')(related_name='comments', null=True, to=orm['forum.Node'])),\r
+ ('deleted', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True)),\r
+ ('added_at', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),\r
+ ('deleted_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='deleted_comments', null=True, to=orm['forum.User'], blank=True)),\r
+ ('score', self.gf('django.db.models.fields.IntegerField')(default=0)),\r
+ ('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='comments', to=orm['forum.User'])),\r
+ ('deleted_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),\r
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),\r
+ ))\r
+ db.send_create_signal('forum', ['Comment'])\r
+\r
+ # Deleting field 'Node.abs_parent'\r
+ db.delete_column('forum_node', 'abs_parent_id')\r
+\r
+ # Changing field 'Question.last_activity_by'\r
+ db.alter_column(u'question', 'last_activity_by_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['forum.User']))\r
+ \r
+ \r
+ models = {\r
+ 'auth.group': {\r
+ 'Meta': {'object_name': 'Group'},\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),\r
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'})\r
+ },\r
+ 'auth.permission': {\r
+ 'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},\r
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\r
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})\r
+ },\r
+ 'auth.user': {\r
+ 'Meta': {'object_name': 'User'},\r
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),\r
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\r
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'blank': 'True'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\r
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),\r
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'}),\r
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})\r
+ },\r
+ 'contenttypes.contenttype': {\r
+ 'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},\r
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\r
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})\r
+ },\r
+ 'forum.activity': {\r
+ 'Meta': {'object_name': 'Activity', 'db_table': "u'activity'"},\r
+ 'active_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'activity_type': ('django.db.models.fields.SmallIntegerField', [], {}),\r
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'is_auditted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.anonymousnode': {\r
+ 'Meta': {'object_name': 'AnonymousNode', '_ormbases': ['forum.Node']},\r
+ 'convertible_to': ('django.db.models.fields.CharField', [], {'default': "'node'", 'max_length': '16'}),\r
+ 'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['forum.Node']", 'unique': 'True', 'primary_key': 'True'}),\r
+ 'validation_hash': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'anonymous_content'", 'to': "orm['forum.Node']"})\r
+ },\r
+ 'forum.answer': {\r
+ 'Meta': {'object_name': 'Answer', 'db_table': "u'answer'"},\r
+ 'accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'accepted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'accepted_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']", 'null': 'True'}),\r
+ 'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['forum.Node']", 'unique': 'True', 'primary_key': 'True'}),\r
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})\r
+ },\r
+ 'forum.authkeyuserassociation': {\r
+ 'Meta': {'object_name': 'AuthKeyUserAssociation'},\r
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),\r
+ 'provider': ('django.db.models.fields.CharField', [], {'max_length': '64'}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'auth_keys'", 'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.award': {\r
+ 'Meta': {'unique_together': "(('content_type', 'object_id', 'user', 'badge'),)", 'object_name': 'Award', 'db_table': "u'award'"},\r
+ 'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_badge'", 'to': "orm['forum.Badge']"}),\r
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'notified': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'awards'", 'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.badge': {\r
+ 'Meta': {'unique_together': "(('name', 'type'),)", 'object_name': 'Badge', 'db_table': "u'badge'"},\r
+ 'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),\r
+ 'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'through': "'Award'", 'to': "orm['forum.User']"}),\r
+ 'description': ('django.db.models.fields.CharField', [], {'max_length': '300'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'multiple': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),\r
+ 'slug': ('django.db.models.fields.SlugField', [], {'db_index': 'True', 'max_length': '50', 'blank': 'True'}),\r
+ 'type': ('django.db.models.fields.SmallIntegerField', [], {})\r
+ },\r
+ 'forum.favoritequestion': {\r
+ 'Meta': {'unique_together': "(('question', 'user'),)", 'object_name': 'FavoriteQuestion', 'db_table': "u'favorite_question'"},\r
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Question']"}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_favorite_questions'", 'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.flaggeditem': {\r
+ 'Meta': {'object_name': 'FlaggedItem', 'db_table': "u'flagged_item'"},\r
+ 'canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'flagged_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'flaggeditems'", 'null': 'True', 'to': "orm['forum.Node']"}),\r
+ 'reason': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True'}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'flaggeditems'", 'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.keyvalue': {\r
+ 'Meta': {'object_name': 'KeyValue'},\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),\r
+ 'value': ('forum.models.utils.PickledObjectField', [], {})\r
+ },\r
+ 'forum.markedtag': {\r
+ 'Meta': {'object_name': 'MarkedTag'},\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),\r
+ 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['forum.Tag']"}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.node': {\r
+ 'Meta': {'object_name': 'Node'},\r
+ 'abs_parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'all_children'", 'null': 'True', 'to': "orm['forum.Node']"}),\r
+ 'active_revision': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'active'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.NodeRevision']"}),\r
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'nodes'", 'to': "orm['forum.User']"}),\r
+ 'body': ('django.db.models.fields.TextField', [], {}),\r
+ 'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),\r
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_nodes'", 'null': 'True', 'to': "orm['forum.User']"}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_nodes'", 'null': 'True', 'to': "orm['forum.User']"}),\r
+ 'node_type': ('django.db.models.fields.CharField', [], {'default': "'node'", 'max_length': '16'}),\r
+ 'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),\r
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'children'", 'null': 'True', 'to': "orm['forum.Node']"}),\r
+ 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),\r
+ 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),\r
+ 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'nodes'", 'to': "orm['forum.Tag']"}),\r
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),\r
+ 'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),\r
+ 'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'})\r
+ },\r
+ 'forum.noderevision': {\r
+ 'Meta': {'unique_together': "(('node', 'revision'),)", 'object_name': 'NodeRevision'},\r
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'noderevisions'", 'to': "orm['forum.User']"}),\r
+ 'body': ('django.db.models.fields.TextField', [], {}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'revisions'", 'to': "orm['forum.Node']"}),\r
+ 'revised_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),\r
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '300'}),\r
+ 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),\r
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'})\r
+ },\r
+ 'forum.question': {\r
+ 'Meta': {'object_name': 'Question', 'db_table': "u'question'"},\r
+ 'accepted_answer': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'question_accepting'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.Answer']"}),\r
+ 'answer_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),\r
+ 'close_reason': ('django.db.models.fields.SmallIntegerField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'closed': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'closed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'closed_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'closed_questions'", 'null': 'True', 'to': "orm['forum.User']"}),\r
+ 'favorited_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'favorite_questions'", 'through': "'FavoriteQuestion'", 'to': "orm['forum.User']"}),\r
+ 'favourite_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),\r
+ 'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'last_active_in_questions'", 'null': 'True', 'to': "orm['forum.User']"}),\r
+ 'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['forum.Node']", 'unique': 'True'}),\r
+ 'subscribers': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subscriptions'", 'through': "'QuestionSubscription'", 'to': "orm['forum.User']"}),\r
+ 'view_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),\r
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})\r
+ },\r
+ 'forum.questionsubscription': {\r
+ 'Meta': {'object_name': 'QuestionSubscription'},\r
+ 'auto_subscription': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'last_view': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 4, 17, 1, 11, 40, 975000)'}),\r
+ 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Question']"}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.repute': {\r
+ 'Meta': {'object_name': 'Repute', 'db_table': "u'repute'"},\r
+ 'canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'null': 'True', 'to': "orm['forum.Node']"}),\r
+ 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Question']"}),\r
+ 'reputation_type': ('django.db.models.fields.SmallIntegerField', [], {}),\r
+ 'reputed_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'to': "orm['forum.User']"}),\r
+ 'user_previous_rep': ('django.db.models.fields.IntegerField', [], {'default': '0'}),\r
+ 'value': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'})\r
+ },\r
+ 'forum.subscriptionsettings': {\r
+ 'Meta': {'object_name': 'SubscriptionSettings'},\r
+ 'all_questions': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'all_questions_watched_tags': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'enable_notifications': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'member_joins': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),\r
+ 'new_question': ('django.db.models.fields.CharField', [], {'default': "'d'", 'max_length': '1'}),\r
+ 'new_question_watched_tags': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),\r
+ 'notify_accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'notify_answers': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'notify_comments': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'notify_comments_own_post': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'notify_reply_to_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'questions_answered': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'questions_asked': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'questions_commented': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'questions_viewed': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'subscribed_questions': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),\r
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'subscription_settings'", 'unique': 'True', 'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.tag': {\r
+ 'Meta': {'object_name': 'Tag', 'db_table': "u'tag'"},\r
+ 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['forum.User']"}),\r
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_tags'", 'null': 'True', 'to': "orm['forum.User']"}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'marked_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'marked_tags'", 'through': "'MarkedTag'", 'to': "orm['forum.User']"}),\r
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),\r
+ 'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})\r
+ },\r
+ 'forum.user': {\r
+ 'Meta': {'object_name': 'User', '_ormbases': ['auth.User']},\r
+ 'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),\r
+ 'bronze': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),\r
+ 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'email_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),\r
+ 'gold': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),\r
+ 'hide_ignored_questions': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'is_approved': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),\r
+ 'questions_per_page': ('django.db.models.fields.SmallIntegerField', [], {'default': '10'}),\r
+ 'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),\r
+ 'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),\r
+ 'silver': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),\r
+ 'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'}),\r
+ 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})\r
+ },\r
+ 'forum.validationhash': {\r
+ 'Meta': {'unique_together': "(('user', 'type'),)", 'object_name': 'ValidationHash'},\r
+ 'expiration': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 4, 18, 1, 11, 41, 269000)'}),\r
+ 'hash_code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'seed': ('django.db.models.fields.CharField', [], {'max_length': '12'}),\r
+ 'type': ('django.db.models.fields.CharField', [], {'max_length': '12'}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.vote': {\r
+ 'Meta': {'object_name': 'Vote', 'db_table': "u'vote'"},\r
+ 'canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'null': 'True', 'to': "orm['forum.Node']"}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['forum.User']"}),\r
+ 'vote': ('django.db.models.fields.SmallIntegerField', [], {}),\r
+ 'voted_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'})\r
+ }\r
+ }\r
+ \r
+ complete_apps = ['forum']\r
--- /dev/null
+# encoding: utf-8\r
+import datetime\r
+from south.db import db\r
+from south.v2 import DataMigration\r
+from django.db import models\r
+from forum.migrations import ProgressBar\r
+\r
+class Migration(DataMigration):\r
+ \r
+ def forwards(self, orm):\r
+ def get_abs_par(n):\r
+ if n.parent:\r
+ return get_abs_par(n.parent)\r
+ else:\r
+ return n\r
+\r
+ n_count = orm.Node.objects.count()\r
+ print "\nConverting %d nodes:" % n_count\r
+ progress = ProgressBar(n_count)\r
+\r
+ for n in orm.Node.objects.all():\r
+ if n.parent:\r
+ n.abs_parent = get_abs_par(n)\r
+ else:\r
+ n.abs_parent = None\r
+ n.save()\r
+ progress.update()\r
+\r
+ print "\n...done\n"\r
+ \r
+ \r
+ def backwards(self, orm):\r
+ "Write your backwards methods here."\r
+ \r
+ models = {\r
+ 'auth.group': {\r
+ 'Meta': {'object_name': 'Group'},\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),\r
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'})\r
+ },\r
+ 'auth.permission': {\r
+ 'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},\r
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\r
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})\r
+ },\r
+ 'auth.user': {\r
+ 'Meta': {'object_name': 'User'},\r
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),\r
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\r
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'blank': 'True'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\r
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),\r
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'}),\r
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})\r
+ },\r
+ 'contenttypes.contenttype': {\r
+ 'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},\r
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\r
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})\r
+ },\r
+ 'forum.activity': {\r
+ 'Meta': {'object_name': 'Activity', 'db_table': "u'activity'"},\r
+ 'active_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'activity_type': ('django.db.models.fields.SmallIntegerField', [], {}),\r
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'is_auditted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.anonymousnode': {\r
+ 'Meta': {'object_name': 'AnonymousNode', '_ormbases': ['forum.Node']},\r
+ 'convertible_to': ('django.db.models.fields.CharField', [], {'default': "'node'", 'max_length': '16'}),\r
+ 'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['forum.Node']", 'unique': 'True', 'primary_key': 'True'}),\r
+ 'validation_hash': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'anonymous_content'", 'to': "orm['forum.Node']"})\r
+ },\r
+ 'forum.answer': {\r
+ 'Meta': {'object_name': 'Answer', 'db_table': "u'answer'"},\r
+ 'accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'accepted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'accepted_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']", 'null': 'True'}),\r
+ 'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['forum.Node']", 'unique': 'True', 'primary_key': 'True'}),\r
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})\r
+ },\r
+ 'forum.authkeyuserassociation': {\r
+ 'Meta': {'object_name': 'AuthKeyUserAssociation'},\r
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),\r
+ 'provider': ('django.db.models.fields.CharField', [], {'max_length': '64'}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'auth_keys'", 'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.award': {\r
+ 'Meta': {'unique_together': "(('content_type', 'object_id', 'user', 'badge'),)", 'object_name': 'Award', 'db_table': "u'award'"},\r
+ 'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_badge'", 'to': "orm['forum.Badge']"}),\r
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'notified': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'awards'", 'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.badge': {\r
+ 'Meta': {'unique_together': "(('name', 'type'),)", 'object_name': 'Badge', 'db_table': "u'badge'"},\r
+ 'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),\r
+ 'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'through': "'Award'", 'to': "orm['forum.User']"}),\r
+ 'description': ('django.db.models.fields.CharField', [], {'max_length': '300'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'multiple': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),\r
+ 'slug': ('django.db.models.fields.SlugField', [], {'db_index': 'True', 'max_length': '50', 'blank': 'True'}),\r
+ 'type': ('django.db.models.fields.SmallIntegerField', [], {})\r
+ },\r
+ 'forum.favoritequestion': {\r
+ 'Meta': {'unique_together': "(('question', 'user'),)", 'object_name': 'FavoriteQuestion', 'db_table': "u'favorite_question'"},\r
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Question']"}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_favorite_questions'", 'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.flaggeditem': {\r
+ 'Meta': {'object_name': 'FlaggedItem', 'db_table': "u'flagged_item'"},\r
+ 'canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'flagged_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'flaggeditems'", 'null': 'True', 'to': "orm['forum.Node']"}),\r
+ 'reason': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True'}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'flaggeditems'", 'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.keyvalue': {\r
+ 'Meta': {'object_name': 'KeyValue'},\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),\r
+ 'value': ('forum.models.utils.PickledObjectField', [], {})\r
+ },\r
+ 'forum.markedtag': {\r
+ 'Meta': {'object_name': 'MarkedTag'},\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),\r
+ 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['forum.Tag']"}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.node': {\r
+ 'Meta': {'object_name': 'Node'},\r
+ 'abs_parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'all_children'", 'null': 'True', 'to': "orm['forum.Node']"}),\r
+ 'active_revision': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'active'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.NodeRevision']"}),\r
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'nodes'", 'to': "orm['forum.User']"}),\r
+ 'body': ('django.db.models.fields.TextField', [], {}),\r
+ 'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),\r
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_nodes'", 'null': 'True', 'to': "orm['forum.User']"}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_nodes'", 'null': 'True', 'to': "orm['forum.User']"}),\r
+ 'node_type': ('django.db.models.fields.CharField', [], {'default': "'node'", 'max_length': '16'}),\r
+ 'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),\r
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'children'", 'null': 'True', 'to': "orm['forum.Node']"}),\r
+ 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),\r
+ 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),\r
+ 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'nodes'", 'to': "orm['forum.Tag']"}),\r
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),\r
+ 'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),\r
+ 'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'})\r
+ },\r
+ 'forum.noderevision': {\r
+ 'Meta': {'unique_together': "(('node', 'revision'),)", 'object_name': 'NodeRevision'},\r
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'noderevisions'", 'to': "orm['forum.User']"}),\r
+ 'body': ('django.db.models.fields.TextField', [], {}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'revisions'", 'to': "orm['forum.Node']"}),\r
+ 'revised_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),\r
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '300'}),\r
+ 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),\r
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'})\r
+ },\r
+ 'forum.question': {\r
+ 'Meta': {'object_name': 'Question', 'db_table': "u'question'"},\r
+ 'accepted_answer': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'question_accepting'", 'unique': 'True', 'null': 'True', 'to': "orm['forum.Answer']"}),\r
+ 'answer_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),\r
+ 'close_reason': ('django.db.models.fields.SmallIntegerField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'closed': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'closed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'closed_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'closed_questions'", 'null': 'True', 'to': "orm['forum.User']"}),\r
+ 'favorited_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'favorite_questions'", 'through': "'FavoriteQuestion'", 'to': "orm['forum.User']"}),\r
+ 'favourite_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),\r
+ 'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'last_active_in_questions'", 'null': 'True', 'to': "orm['forum.User']"}),\r
+ 'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['forum.Node']", 'unique': 'True'}),\r
+ 'subscribers': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subscriptions'", 'through': "'QuestionSubscription'", 'to': "orm['forum.User']"}),\r
+ 'view_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),\r
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})\r
+ },\r
+ 'forum.questionsubscription': {\r
+ 'Meta': {'object_name': 'QuestionSubscription'},\r
+ 'auto_subscription': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'last_view': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 4, 17, 1, 20, 29, 905000)'}),\r
+ 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Question']"}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.repute': {\r
+ 'Meta': {'object_name': 'Repute', 'db_table': "u'repute'"},\r
+ 'canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'null': 'True', 'to': "orm['forum.Node']"}),\r
+ 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.Question']"}),\r
+ 'reputation_type': ('django.db.models.fields.SmallIntegerField', [], {}),\r
+ 'reputed_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'reputes'", 'to': "orm['forum.User']"}),\r
+ 'user_previous_rep': ('django.db.models.fields.IntegerField', [], {'default': '0'}),\r
+ 'value': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'})\r
+ },\r
+ 'forum.subscriptionsettings': {\r
+ 'Meta': {'object_name': 'SubscriptionSettings'},\r
+ 'all_questions': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'all_questions_watched_tags': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'enable_notifications': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'member_joins': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),\r
+ 'new_question': ('django.db.models.fields.CharField', [], {'default': "'d'", 'max_length': '1'}),\r
+ 'new_question_watched_tags': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),\r
+ 'notify_accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'notify_answers': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'notify_comments': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'notify_comments_own_post': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'notify_reply_to_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'questions_answered': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'questions_asked': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\r
+ 'questions_commented': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'questions_viewed': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'subscribed_questions': ('django.db.models.fields.CharField', [], {'default': "'i'", 'max_length': '1'}),\r
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'subscription_settings'", 'unique': 'True', 'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.tag': {\r
+ 'Meta': {'object_name': 'Tag', 'db_table': "u'tag'"},\r
+ 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['forum.User']"}),\r
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_tags'", 'null': 'True', 'to': "orm['forum.User']"}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'marked_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'marked_tags'", 'through': "'MarkedTag'", 'to': "orm['forum.User']"}),\r
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),\r
+ 'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})\r
+ },\r
+ 'forum.user': {\r
+ 'Meta': {'object_name': 'User', '_ormbases': ['auth.User']},\r
+ 'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),\r
+ 'bronze': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),\r
+ 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),\r
+ 'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'email_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),\r
+ 'gold': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),\r
+ 'hide_ignored_questions': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'is_approved': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\r
+ 'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),\r
+ 'questions_per_page': ('django.db.models.fields.SmallIntegerField', [], {'default': '10'}),\r
+ 'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),\r
+ 'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),\r
+ 'silver': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),\r
+ 'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'}),\r
+ 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})\r
+ },\r
+ 'forum.validationhash': {\r
+ 'Meta': {'unique_together': "(('user', 'type'),)", 'object_name': 'ValidationHash'},\r
+ 'expiration': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 4, 18, 1, 20, 29, 974000)'}),\r
+ 'hash_code': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'seed': ('django.db.models.fields.CharField', [], {'max_length': '12'}),\r
+ 'type': ('django.db.models.fields.CharField', [], {'max_length': '12'}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['forum.User']"})\r
+ },\r
+ 'forum.vote': {\r
+ 'Meta': {'object_name': 'Vote', 'db_table': "u'vote'"},\r
+ 'canceled': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\r
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\r
+ 'node': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'null': 'True', 'to': "orm['forum.Node']"}),\r
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['forum.User']"}),\r
+ 'vote': ('django.db.models.fields.SmallIntegerField', [], {}),\r
+ 'voted_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'})\r
+ }\r
+ }\r
+ \r
+ complete_apps = ['forum']\r
self._update_parent_comment_count(1)\r
\r
def is_reply_to(self, user):\r
- inreply = re.search('@\w+', self.comment)\r
+ inreply = re.search('@\w+', self.body)\r
if inreply is not None:\r
return user.username.startswith(inreply.group(0))\r
\r
return False\r
\r
+ def get_absolute_url(self):\r
+ return self.absolute_parent.get_absolute_url() + "#%d" % self.id\r
+\r
def __unicode__(self):\r
return self.body\r
\r
\r
node_type = models.CharField(max_length=16, default='node')\r
parent = models.ForeignKey('Node', related_name='children', null=True)\r
+ abs_parent = models.ForeignKey('Node', related_name='all_children', null=True)\r
\r
added_at = models.DateTimeField(default=datetime.datetime.now)\r
\r
def leaf(self):\r
return NodeMetaClass.types[self.node_type].objects.get(id=self.id)\r
\r
+ @property \r
+ def absolute_parent(self):\r
+ if not self.abs_parent_id:\r
+ return self.leaf\r
+\r
+ return self.abs_parent.leaf\r
+\r
@property\r
def summary(self):\r
return strip_tags(self.html)[:300]\r
def save(self, *args, **kwargs):\r
if not self.id:\r
self.node_type = self.__class__.__name__.lower()\r
+\r
+ if self.parent_id and not self.abs_parent_id:\r
+ self.abs_parent = self.parent.absolute_parent\r
\r
tags = self.get_tag_list_if_changed()\r
super(Node, self).save(*args, **kwargs)\r
@property\r
def node(self):\r
if self.activity_type in (const.TYPE_ACTIVITY_ANSWER, const.TYPE_ACTIVITY_ASK_QUESTION,\r
- const.TYPE_ACTIVITY_MARK_ANSWER):\r
- return self.content_object\r
-\r
- if self.activity_type in (const.TYPE_ACTIVITY_COMMENT_QUESTION, const.TYPE_ACTIVITY_COMMENT_ANSWER):\r
- return self.content_object.parent.leaf\r
+ const.TYPE_ACTIVITY_MARK_ANSWER, const.TYPE_ACTIVITY_COMMENT_QUESTION, const.TYPE_ACTIVITY_COMMENT_ANSWER):\r
+ return self.content_object.leaf\r
\r
if self.activity_type in (const.TYPE_ACTIVITY_UPDATE_ANSWER, const.TYPE_ACTIVITY_UPDATE_QUESTION):\r
return self.content_object.node.leaf \r
\r
<div class="comments-container" id="comments-container-{{ post.id }}">\r
{% for comment in comments %}\r
+ <a name="{{ comment.id }}"></a>\r
<table class="comment{% if not comment.top_scorer %} not_top_scorer{% endif %}" id="comment-{{comment.id}}">\r
<tr>\r
<td rowspan="2" class="comment-score" id="comment-{{ comment.id }}-score">\r
if settings.DATABASE_ENGINE in ('postgresql_psycopg2', 'postgresql', ):
from django.db.models.signals import post_syncdb
- def install_pg_fts():
+ def install_pg_fts(**kwargs):
f = open(os.path.join(os.path.dirname(__file__), 'pg_fts_install.sql'), 'r')
try: