summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zielinski <tomasz.zielinski@pyconsultant.eu>2011-12-30 00:38:13 +0100
committerTomasz Zielinski <tomasz.zielinski@pyconsultant.eu>2011-12-30 00:38:13 +0100
commit857bb4a7d27635184c9f69118547107b1860ebcf (patch)
tree99223fe5edecbc4845ad714a039797ada229e80e
parent1e646e24c1a008a20254cb14f405c1babbf0cb33 (diff)
downloadaskbot-857bb4a7d27635184c9f69118547107b1860ebcf.tar.gz
askbot-857bb4a7d27635184c9f69118547107b1860ebcf.tar.bz2
askbot-857bb4a7d27635184c9f69118547107b1860ebcf.zip
BigMigration: Question, Answer, Comment models REMOVED; Initial adjustements of the codebase to make `questions()` and `question()` views roughly work
-rw-r--r--askbot/admin.py16
-rw-r--r--askbot/auth.py2
-rw-r--r--askbot/feed.py2
-rw-r--r--askbot/migrations/0100_auto__del_field_post_self_question__del_field_post_self_answer__del_fi.py347
-rw-r--r--askbot/migrations/0101_megadeath_of_q_a_c.py352
-rw-r--r--askbot/migrations/0102_rename_post_fields_back_1.py267
-rw-r--r--askbot/migrations/0103_rename_post_fields_back_2.py267
-rw-r--r--askbot/models/__init__.py99
-rw-r--r--askbot/models/answer.py12
-rw-r--r--askbot/models/badges.py1
-rw-r--r--askbot/models/content.py30
-rw-r--r--askbot/models/meta.py488
-rw-r--r--askbot/models/post.py72
-rw-r--r--askbot/models/question.py62
-rw-r--r--askbot/models/user.py2
-rw-r--r--askbot/sitemap.py2
-rw-r--r--askbot/skins/default/templates/answer_edit.html2
-rw-r--r--askbot/skins/default/templates/macros.html2
-rw-r--r--askbot/skins/default/templates/question.html92
-rw-r--r--askbot/skins/default/templates/question/javascript.html2
-rw-r--r--askbot/skins/default/templates/question/sidebar.html4
-rw-r--r--askbot/skins/default/templates/question_edit.html2
-rw-r--r--askbot/skins/default/templates/question_retag.html2
-rw-r--r--askbot/skins/default/templates/revisions.html4
-rw-r--r--askbot/skins/default/templates/user_profile/user_stats.html4
-rw-r--r--askbot/skins/default/templates/widgets/question_summary.html2
-rw-r--r--askbot/utils/mysql.py6
-rw-r--r--askbot/views/readers.py53
-rw-r--r--askbot/views/users.py22
-rw-r--r--askbot/views/writers.py21
30 files changed, 1698 insertions, 541 deletions
diff --git a/askbot/admin.py b/askbot/admin.py
index 34722416..8e97a89d 100644
--- a/askbot/admin.py
+++ b/askbot/admin.py
@@ -13,18 +13,9 @@ from askbot import models
class AnonymousQuestionAdmin(admin.ModelAdmin):
"""AnonymousQuestion admin class"""
-class QuestionAdmin(admin.ModelAdmin):
- """Question admin class"""
-
class TagAdmin(admin.ModelAdmin):
"""Tag admin class"""
-class AnswerAdmin(admin.ModelAdmin):
- """Answer admin class"""
-
-class CommentAdmin(admin.ModelAdmin):
- """ admin class"""
-
class VoteAdmin(admin.ModelAdmin):
""" admin class"""
@@ -43,16 +34,11 @@ class ReputeAdmin(admin.ModelAdmin):
class ActivityAdmin(admin.ModelAdmin):
""" admin class"""
-admin.site.register(models.Question, QuestionAdmin)
+admin.site.register(models.Post)
admin.site.register(models.Tag, TagAdmin)
-admin.site.register(models.Answer, AnswerAdmin)
-admin.site.register(models.Comment, CommentAdmin)
admin.site.register(models.Vote, VoteAdmin)
admin.site.register(models.FavoriteQuestion, FavoriteQuestionAdmin)
admin.site.register(models.PostRevision, PostRevisionAdmin)
admin.site.register(models.Award, AwardAdmin)
admin.site.register(models.Repute, ReputeAdmin)
admin.site.register(models.Activity, ActivityAdmin)
-#admin.site.register(Book, BookAdmin)
-#admin.site.register(BookAuthorInfo, BookAuthorInfoAdmin)
-#admin.site.register(BookAuthorRss, BookAuthorRssAdmin)
diff --git a/askbot/auth.py b/askbot/auth.py
index 62714bd0..5227e678 100644
--- a/askbot/auth.py
+++ b/askbot/auth.py
@@ -10,7 +10,7 @@ User.assert_can...
import datetime
from django.db import transaction
from askbot.models import Repute
-from askbot.models import Answer
+#from askbot.models import Answer
from askbot.models import signals
from askbot.conf import settings as askbot_settings
diff --git a/askbot/feed.py b/askbot/feed.py
index d7a3d513..8dfc17f2 100644
--- a/askbot/feed.py
+++ b/askbot/feed.py
@@ -16,7 +16,7 @@ from django.contrib.syndication.feeds import Feed
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext as _
from django.core.exceptions import ObjectDoesNotExist
-from askbot.models import Question, Answer, Comment
+#from askbot.models import Question, Answer, Comment
from askbot.conf import settings as askbot_settings
import itertools
diff --git a/askbot/migrations/0100_auto__del_field_post_self_question__del_field_post_self_answer__del_fi.py b/askbot/migrations/0100_auto__del_field_post_self_question__del_field_post_self_answer__del_fi.py
new file mode 100644
index 00000000..08552f15
--- /dev/null
+++ b/askbot/migrations/0100_auto__del_field_post_self_question__del_field_post_self_answer__del_fi.py
@@ -0,0 +1,347 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Deleting field 'Post.self_question'
+ db.delete_column('askbot_post', 'self_question_id')
+
+ # Deleting field 'Post.self_answer'
+ db.delete_column('askbot_post', 'self_answer_id')
+
+ # Deleting field 'Post.self_comment'
+ db.delete_column('askbot_post', 'self_comment_id')
+
+
+ def backwards(self, orm):
+
+ # Adding field 'Post.self_question'
+ db.add_column('askbot_post', 'self_question', self.gf('django.db.models.fields.related.ForeignKey')(related_name='+', null=True, to=orm['askbot.Question'], blank=True), keep_default=False)
+
+ # Adding field 'Post.self_answer'
+ db.add_column('askbot_post', 'self_answer', self.gf('django.db.models.fields.related.ForeignKey')(related_name='+', null=True, to=orm['askbot.Answer'], blank=True), keep_default=False)
+
+ # Adding field 'Post.self_comment'
+ db.add_column('askbot_post', 'self_comment', self.gf('django.db.models.fields.related.ForeignKey')(related_name='+', null=True, to=orm['askbot.Comment'], blank=True), keep_default=False)
+
+
+ models = {
+ 'askbot.activity': {
+ 'Meta': {'object_name': 'Activity', 'db_table': "u'activity'"},
+ 'active_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'activity_type': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_auditted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Post']", 'null': 'True'}),
+ 'receiving_users': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'received_activity'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
+ 'recipients': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'incoming_activity'", 'symmetrical': 'False', 'through': "orm['askbot.ActivityAuditStatus']", 'to': "orm['auth.User']"}),
+ 'summary': ('django.db.models.fields.TextField', [], {'default': "''"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'askbot.activityauditstatus': {
+ 'Meta': {'unique_together': "(('user', 'activity'),)", 'object_name': 'ActivityAuditStatus'},
+ 'activity': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Activity']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'status': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'askbot.anonymousanswer': {
+ 'Meta': {'object_name': 'AnonymousAnswer'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ip_addr': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'anonymous_answers'", 'to': "orm['askbot.Post']"}),
+ 'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'text': ('django.db.models.fields.TextField', [], {}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+ },
+ 'askbot.anonymousquestion': {
+ 'Meta': {'object_name': 'AnonymousQuestion'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ip_addr': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
+ 'text': ('django.db.models.fields.TextField', [], {}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+ },
+ 'askbot.answer': {
+ 'Meta': {'object_name': 'Answer', 'db_table': "u'answer'"},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'answers'", 'to': "orm['auth.User']"}),
+ 'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_answers'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'html': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_answers'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'locked_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'locked_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locked_answers'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'question': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'answers'", 'to': "orm['askbot.Question']"}),
+ 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'text': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
+ },
+ 'askbot.award': {
+ 'Meta': {'object_name': 'Award', 'db_table': "u'award'"},
+ 'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_badge'", 'to': "orm['askbot.BadgeData']"}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_user'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.badgedata': {
+ 'Meta': {'ordering': "('slug',)", 'object_name': 'BadgeData'},
+ 'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'symmetrical': 'False', 'through': "orm['askbot.Award']", 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'})
+ },
+ 'askbot.comment': {
+ 'Meta': {'ordering': "('-added_at',)", 'object_name': 'Comment', 'db_table': "u'comment'"},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'comment': ('django.db.models.fields.CharField', [], {'max_length': '2048'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'html': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '2048'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'offensive_flag_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'comments'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.emailfeedsetting': {
+ 'Meta': {'object_name': 'EmailFeedSetting'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'feed_type': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
+ 'frequency': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '8'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'reported_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+ 'subscriber': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notification_subscriptions'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.favoritequestion': {
+ 'Meta': {'object_name': 'FavoriteQuestion', 'db_table': "u'favorite_question'"},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'thread': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Thread']"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_favorite_questions'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.markedtag': {
+ 'Meta': {'object_name': 'MarkedTag'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
+ 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['askbot.Tag']"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.post': {
+ 'Meta': {'object_name': 'Post'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'posts'", 'to': "orm['auth.User']"}),
+ 'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'html': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'locked_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'locked_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locked_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'comment_posts'", 'null': 'True', 'to': "orm['askbot.Post']"}),
+ 'post_type': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'text': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'thread': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'posts'", 'to': "orm['askbot.Thread']"}),
+ 'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
+ },
+ 'askbot.postrevision': {
+ 'Meta': {'ordering': "('-revision',)", 'unique_together': "(('post', 'revision'),)", 'object_name': 'PostRevision'},
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'postrevisions'", 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'post': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'revisions'", 'null': 'True', 'to': "orm['askbot.Post']"}),
+ 'revised_at': ('django.db.models.fields.DateTimeField', [], {}),
+ 'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'revision_type': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '300', 'blank': 'True'}),
+ 'tagnames': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '125', 'blank': 'True'}),
+ 'text': ('django.db.models.fields.TextField', [], {}),
+ 'title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '300', 'blank': 'True'})
+ },
+ 'askbot.question': {
+ 'Meta': {'object_name': 'Question', 'db_table': "u'question'"},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'questions'", 'to': "orm['auth.User']"}),
+ 'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_questions'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'html': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_questions'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'locked_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'locked_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locked_questions'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'text': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'thread': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'questions'", 'unique': 'True', 'to': "orm['askbot.Thread']"}),
+ 'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
+ },
+ 'askbot.questionview': {
+ 'Meta': {'object_name': 'QuestionView'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'viewed'", 'to': "orm['askbot.Post']"}),
+ 'when': ('django.db.models.fields.DateTimeField', [], {}),
+ 'who': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'question_views'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.repute': {
+ 'Meta': {'object_name': 'Repute', 'db_table': "u'repute'"},
+ 'comment': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'negative': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'positive': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Post']", 'null': 'True', 'blank': 'True'}),
+ 'reputation': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+ 'reputation_type': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'reputed_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'askbot.tag': {
+ 'Meta': {'ordering': "('-used_count', 'name')", 'object_name': 'Tag', 'db_table': "u'tag'"},
+ 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['auth.User']"}),
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_tags'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+ 'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
+ },
+ 'askbot.thread': {
+ 'Meta': {'object_name': 'Thread'},
+ 'accepted_answer_post': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'to': "orm['askbot.Post']"}),
+ 'answer_accepted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'answer_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'close_reason': ('django.db.models.fields.SmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'closed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'closed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'closed_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
+ 'favorited_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'unused_favorite_threads'", 'symmetrical': 'False', 'through': "orm['askbot.FavoriteQuestion']", 'to': "orm['auth.User']"}),
+ 'favourite_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'followed_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'followed_threads'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'unused_last_active_in_threads'", 'to': "orm['auth.User']"}),
+ 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
+ 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'threads'", 'symmetrical': 'False', 'to': "orm['askbot.Tag']"}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
+ 'view_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
+ },
+ 'askbot.vote': {
+ 'Meta': {'unique_together': "(('user', 'voted_post'),)", 'object_name': 'Vote', 'db_table': "u'vote'"},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['auth.User']"}),
+ 'vote': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'voted_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'voted_post': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'post_votes'", 'to': "orm['askbot.Post']"})
+ },
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'avatar_type': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),
+ 'bronze': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'consecutive_days_visit_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'country': ('django_countries.fields.CountryField', [], {'max_length': '2', 'blank': 'True'}),
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ 'display_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'email_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
+ 'email_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '1'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'gold': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'gravatar': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ignored_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'interesting_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'new_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'questions_per_page': ('django.db.models.fields.SmallIntegerField', [], {'default': '10'}),
+ 'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
+ 'seen_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'show_country': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'silver': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'status': ('django.db.models.fields.CharField', [], {'default': "'w'", 'max_length': '2'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}),
+ 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ }
+ }
+
+ complete_apps = ['askbot']
diff --git a/askbot/migrations/0101_megadeath_of_q_a_c.py b/askbot/migrations/0101_megadeath_of_q_a_c.py
new file mode 100644
index 00000000..417463a0
--- /dev/null
+++ b/askbot/migrations/0101_megadeath_of_q_a_c.py
@@ -0,0 +1,352 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ db.rename_column('askbot_thread', 'accepted_answer_post_id', 'accepted_answer_id')
+
+ # Deleting model 'Comment'
+ db.delete_table(u'comment')
+
+ # Deleting model 'Answer'
+ db.delete_table(u'answer')
+
+ # Deleting model 'Question'
+ db.delete_table(u'question')
+
+
+
+ def backwards(self, orm):
+
+ # Adding model 'Comment'
+ db.create_table(u'comment', (
+ ('comment', self.gf('django.db.models.fields.CharField')(max_length=2048)),
+ ('offensive_flag_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
+ ('object_id', self.gf('django.db.models.fields.PositiveIntegerField')()),
+ ('content_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contenttypes.ContentType'])),
+ ('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='comments', to=orm['auth.User'])),
+ ('score', self.gf('django.db.models.fields.IntegerField')(default=0)),
+ ('html', self.gf('django.db.models.fields.CharField')(default='', max_length=2048)),
+ ('added_at', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ))
+ db.send_create_signal('askbot', ['Comment'])
+
+ # Adding model 'Answer'
+ db.create_table(u'answer', (
+ ('wiki', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ('vote_up_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
+ ('text', self.gf('django.db.models.fields.TextField')(null=True)),
+ ('offensive_flag_count', self.gf('django.db.models.fields.SmallIntegerField')(default=0)),
+ ('summary', self.gf('django.db.models.fields.CharField')(max_length=180)),
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('locked_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
+ ('author', self.gf('django.db.models.fields.related.ForeignKey')(related_name='answers', to=orm['auth.User'])),
+ ('question', self.gf('django.db.models.fields.related.ForeignKey')(related_name='answers', to=orm['askbot.Question'])),
+ ('comment_count', self.gf('django.db.models.fields.PositiveIntegerField')(default=0)),
+ ('score', self.gf('django.db.models.fields.IntegerField')(default=0)),
+ ('vote_down_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
+ ('last_edited_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='last_edited_answers', null=True, to=orm['auth.User'], blank=True)),
+ ('deleted', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ('deleted_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
+ ('locked', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ('is_anonymous', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ('locked_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='locked_answers', null=True, to=orm['auth.User'], blank=True)),
+ ('html', self.gf('django.db.models.fields.TextField')(null=True)),
+ ('added_at', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
+ ('deleted_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='deleted_answers', null=True, to=orm['auth.User'], blank=True)),
+ ('wikified_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
+ ('last_edited_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
+ ))
+ db.send_create_signal('askbot', ['Answer'])
+
+ # Adding model 'Question'
+ db.create_table(u'question', (
+ ('wiki', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ('vote_up_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
+ ('text', self.gf('django.db.models.fields.TextField')(null=True)),
+ ('offensive_flag_count', self.gf('django.db.models.fields.SmallIntegerField')(default=0)),
+ ('summary', self.gf('django.db.models.fields.CharField')(max_length=180)),
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('locked_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
+ ('author', self.gf('django.db.models.fields.related.ForeignKey')(related_name='questions', to=orm['auth.User'])),
+ ('comment_count', self.gf('django.db.models.fields.PositiveIntegerField')(default=0)),
+ ('score', self.gf('django.db.models.fields.IntegerField')(default=0)),
+ ('vote_down_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
+ ('last_edited_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='last_edited_questions', null=True, to=orm['auth.User'], blank=True)),
+ ('deleted', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ('deleted_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
+ ('locked', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ('thread', self.gf('django.db.models.fields.related.ForeignKey')(related_name='questions', unique=True, to=orm['askbot.Thread'])),
+ ('is_anonymous', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ('locked_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='locked_questions', null=True, to=orm['auth.User'], blank=True)),
+ ('html', self.gf('django.db.models.fields.TextField')(null=True)),
+ ('added_at', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
+ ('deleted_by', self.gf('django.db.models.fields.related.ForeignKey')(related_name='deleted_questions', null=True, to=orm['auth.User'], blank=True)),
+ ('wikified_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
+ ('last_edited_at', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
+ ))
+ db.send_create_signal('askbot', ['Question'])
+
+ # Adding field 'Thread.accepted_answer_post'
+ db.add_column('askbot_thread', 'accepted_answer_post', self.gf('django.db.models.fields.related.ForeignKey')(related_name='+', null=True, to=orm['askbot.Post'], blank=True), keep_default=False)
+
+ # Deleting field 'Thread.accepted_answer'
+ db.delete_column('askbot_thread', 'accepted_answer_id')
+
+
+ models = {
+ 'askbot.activity': {
+ 'Meta': {'object_name': 'Activity', 'db_table': "u'activity'"},
+ 'active_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'activity_type': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_auditted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Post']", 'null': 'True'}),
+ 'receiving_users': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'received_activity'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
+ 'recipients': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'incoming_activity'", 'symmetrical': 'False', 'through': "orm['askbot.ActivityAuditStatus']", 'to': "orm['auth.User']"}),
+ 'summary': ('django.db.models.fields.TextField', [], {'default': "''"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'askbot.activityauditstatus': {
+ 'Meta': {'unique_together': "(('user', 'activity'),)", 'object_name': 'ActivityAuditStatus'},
+ 'activity': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Activity']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'status': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'askbot.anonymousanswer': {
+ 'Meta': {'object_name': 'AnonymousAnswer'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ip_addr': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'anonymous_answers'", 'to': "orm['askbot.Post']"}),
+ 'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'text': ('django.db.models.fields.TextField', [], {}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+ },
+ 'askbot.anonymousquestion': {
+ 'Meta': {'object_name': 'AnonymousQuestion'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ip_addr': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
+ 'text': ('django.db.models.fields.TextField', [], {}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+ },
+ 'askbot.award': {
+ 'Meta': {'object_name': 'Award', 'db_table': "u'award'"},
+ 'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_badge'", 'to': "orm['askbot.BadgeData']"}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_user'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.badgedata': {
+ 'Meta': {'ordering': "('slug',)", 'object_name': 'BadgeData'},
+ 'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'symmetrical': 'False', 'through': "orm['askbot.Award']", 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'})
+ },
+ 'askbot.emailfeedsetting': {
+ 'Meta': {'object_name': 'EmailFeedSetting'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'feed_type': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
+ 'frequency': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '8'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'reported_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+ 'subscriber': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notification_subscriptions'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.favoritequestion': {
+ 'Meta': {'object_name': 'FavoriteQuestion', 'db_table': "u'favorite_question'"},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'thread': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Thread']"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_favorite_questions'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.markedtag': {
+ 'Meta': {'object_name': 'MarkedTag'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
+ 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['askbot.Tag']"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.post': {
+ 'Meta': {'object_name': 'Post'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'posts'", 'to': "orm['auth.User']"}),
+ 'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'html': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'locked_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'locked_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locked_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'comment_posts'", 'null': 'True', 'to': "orm['askbot.Post']"}),
+ 'post_type': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'text': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'thread': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'posts'", 'to': "orm['askbot.Thread']"}),
+ 'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
+ },
+ 'askbot.postrevision': {
+ 'Meta': {'ordering': "('-revision',)", 'unique_together': "(('post', 'revision'),)", 'object_name': 'PostRevision'},
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'postrevisions'", 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'post': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'revisions'", 'null': 'True', 'to': "orm['askbot.Post']"}),
+ 'revised_at': ('django.db.models.fields.DateTimeField', [], {}),
+ 'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'revision_type': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '300', 'blank': 'True'}),
+ 'tagnames': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '125', 'blank': 'True'}),
+ 'text': ('django.db.models.fields.TextField', [], {}),
+ 'title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '300', 'blank': 'True'})
+ },
+ 'askbot.questionview': {
+ 'Meta': {'object_name': 'QuestionView'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'viewed'", 'to': "orm['askbot.Post']"}),
+ 'when': ('django.db.models.fields.DateTimeField', [], {}),
+ 'who': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'question_views'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.repute': {
+ 'Meta': {'object_name': 'Repute', 'db_table': "u'repute'"},
+ 'comment': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'negative': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'positive': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Post']", 'null': 'True', 'blank': 'True'}),
+ 'reputation': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+ 'reputation_type': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'reputed_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'askbot.tag': {
+ 'Meta': {'ordering': "('-used_count', 'name')", 'object_name': 'Tag', 'db_table': "u'tag'"},
+ 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['auth.User']"}),
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_tags'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+ 'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
+ },
+ 'askbot.thread': {
+ 'Meta': {'object_name': 'Thread'},
+ 'accepted_answer': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'to': "orm['askbot.Post']"}),
+ 'answer_accepted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'answer_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'close_reason': ('django.db.models.fields.SmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'closed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'closed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'closed_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
+ 'favorited_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'unused_favorite_threads'", 'symmetrical': 'False', 'through': "orm['askbot.FavoriteQuestion']", 'to': "orm['auth.User']"}),
+ 'favourite_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'followed_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'followed_threads'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'unused_last_active_in_threads'", 'to': "orm['auth.User']"}),
+ 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
+ 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'threads'", 'symmetrical': 'False', 'to': "orm['askbot.Tag']"}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
+ 'view_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
+ },
+ 'askbot.vote': {
+ 'Meta': {'unique_together': "(('user', 'voted_post'),)", 'object_name': 'Vote', 'db_table': "u'vote'"},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['auth.User']"}),
+ 'vote': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'voted_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'voted_post': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'post_votes'", 'to': "orm['askbot.Post']"})
+ },
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'avatar_type': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),
+ 'bronze': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'consecutive_days_visit_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'country': ('django_countries.fields.CountryField', [], {'max_length': '2', 'blank': 'True'}),
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ 'display_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'email_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
+ 'email_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '1'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'gold': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'gravatar': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ignored_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'interesting_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'new_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'questions_per_page': ('django.db.models.fields.SmallIntegerField', [], {'default': '10'}),
+ 'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
+ 'seen_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'show_country': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'silver': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'status': ('django.db.models.fields.CharField', [], {'default': "'w'", 'max_length': '2'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}),
+ 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ }
+ }
+
+ complete_apps = ['askbot']
diff --git a/askbot/migrations/0102_rename_post_fields_back_1.py b/askbot/migrations/0102_rename_post_fields_back_1.py
new file mode 100644
index 00000000..332015b0
--- /dev/null
+++ b/askbot/migrations/0102_rename_post_fields_back_1.py
@@ -0,0 +1,267 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ db.rename_column('askbot_questionview', 'question_post_id', 'question_id')
+
+
+ def backwards(self, orm):
+ db.rename_column('askbot_questionview', 'question_id', 'question_post_id')
+
+
+ models = {
+ 'askbot.activity': {
+ 'Meta': {'object_name': 'Activity', 'db_table': "u'activity'"},
+ 'active_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'activity_type': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_auditted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Post']", 'null': 'True'}),
+ 'receiving_users': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'received_activity'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
+ 'recipients': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'incoming_activity'", 'symmetrical': 'False', 'through': "orm['askbot.ActivityAuditStatus']", 'to': "orm['auth.User']"}),
+ 'summary': ('django.db.models.fields.TextField', [], {'default': "''"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'askbot.activityauditstatus': {
+ 'Meta': {'unique_together': "(('user', 'activity'),)", 'object_name': 'ActivityAuditStatus'},
+ 'activity': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Activity']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'status': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'askbot.anonymousanswer': {
+ 'Meta': {'object_name': 'AnonymousAnswer'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ip_addr': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'anonymous_answers'", 'to': "orm['askbot.Post']"}),
+ 'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'text': ('django.db.models.fields.TextField', [], {}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+ },
+ 'askbot.anonymousquestion': {
+ 'Meta': {'object_name': 'AnonymousQuestion'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ip_addr': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
+ 'text': ('django.db.models.fields.TextField', [], {}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+ },
+ 'askbot.award': {
+ 'Meta': {'object_name': 'Award', 'db_table': "u'award'"},
+ 'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_badge'", 'to': "orm['askbot.BadgeData']"}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_user'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.badgedata': {
+ 'Meta': {'ordering': "('slug',)", 'object_name': 'BadgeData'},
+ 'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'symmetrical': 'False', 'through': "orm['askbot.Award']", 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'})
+ },
+ 'askbot.emailfeedsetting': {
+ 'Meta': {'object_name': 'EmailFeedSetting'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'feed_type': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
+ 'frequency': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '8'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'reported_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+ 'subscriber': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notification_subscriptions'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.favoritequestion': {
+ 'Meta': {'object_name': 'FavoriteQuestion', 'db_table': "u'favorite_question'"},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'thread': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Thread']"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_favorite_questions'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.markedtag': {
+ 'Meta': {'object_name': 'MarkedTag'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
+ 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['askbot.Tag']"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.post': {
+ 'Meta': {'object_name': 'Post'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'posts'", 'to': "orm['auth.User']"}),
+ 'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'html': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'locked_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'locked_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locked_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'comment_posts'", 'null': 'True', 'to': "orm['askbot.Post']"}),
+ 'post_type': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'text': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'thread': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'posts'", 'to': "orm['askbot.Thread']"}),
+ 'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
+ },
+ 'askbot.postrevision': {
+ 'Meta': {'ordering': "('-revision',)", 'unique_together': "(('post', 'revision'),)", 'object_name': 'PostRevision'},
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'postrevisions'", 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'post': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'revisions'", 'null': 'True', 'to': "orm['askbot.Post']"}),
+ 'revised_at': ('django.db.models.fields.DateTimeField', [], {}),
+ 'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'revision_type': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '300', 'blank': 'True'}),
+ 'tagnames': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '125', 'blank': 'True'}),
+ 'text': ('django.db.models.fields.TextField', [], {}),
+ 'title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '300', 'blank': 'True'})
+ },
+ 'askbot.questionview': {
+ 'Meta': {'object_name': 'QuestionView'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'question': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'viewed'", 'to': "orm['askbot.Post']"}),
+ 'when': ('django.db.models.fields.DateTimeField', [], {}),
+ 'who': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'question_views'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.repute': {
+ 'Meta': {'object_name': 'Repute', 'db_table': "u'repute'"},
+ 'comment': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'negative': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'positive': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Post']", 'null': 'True', 'blank': 'True'}),
+ 'reputation': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+ 'reputation_type': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'reputed_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'askbot.tag': {
+ 'Meta': {'ordering': "('-used_count', 'name')", 'object_name': 'Tag', 'db_table': "u'tag'"},
+ 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['auth.User']"}),
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_tags'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+ 'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
+ },
+ 'askbot.thread': {
+ 'Meta': {'object_name': 'Thread'},
+ 'accepted_answer': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'to': "orm['askbot.Post']"}),
+ 'answer_accepted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'answer_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'close_reason': ('django.db.models.fields.SmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'closed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'closed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'closed_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
+ 'favorited_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'unused_favorite_threads'", 'symmetrical': 'False', 'through': "orm['askbot.FavoriteQuestion']", 'to': "orm['auth.User']"}),
+ 'favourite_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'followed_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'followed_threads'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'unused_last_active_in_threads'", 'to': "orm['auth.User']"}),
+ 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
+ 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'threads'", 'symmetrical': 'False', 'to': "orm['askbot.Tag']"}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
+ 'view_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
+ },
+ 'askbot.vote': {
+ 'Meta': {'unique_together': "(('user', 'voted_post'),)", 'object_name': 'Vote', 'db_table': "u'vote'"},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['auth.User']"}),
+ 'vote': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'voted_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'voted_post': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'post_votes'", 'to': "orm['askbot.Post']"})
+ },
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'avatar_type': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),
+ 'bronze': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'consecutive_days_visit_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'country': ('django_countries.fields.CountryField', [], {'max_length': '2', 'blank': 'True'}),
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ 'display_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'email_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
+ 'email_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '1'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'gold': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'gravatar': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ignored_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'interesting_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'new_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'questions_per_page': ('django.db.models.fields.SmallIntegerField', [], {'default': '10'}),
+ 'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
+ 'seen_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'show_country': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'silver': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'status': ('django.db.models.fields.CharField', [], {'default': "'w'", 'max_length': '2'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}),
+ 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ }
+ }
+
+ complete_apps = ['askbot']
diff --git a/askbot/migrations/0103_rename_post_fields_back_2.py b/askbot/migrations/0103_rename_post_fields_back_2.py
new file mode 100644
index 00000000..87feb037
--- /dev/null
+++ b/askbot/migrations/0103_rename_post_fields_back_2.py
@@ -0,0 +1,267 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ db.rename_column(u'activity', 'question_post_id', 'question_id')
+
+
+ def backwards(self, orm):
+ db.rename_column(u'activity', 'question_id', 'question_post_id')
+
+
+ models = {
+ 'askbot.activity': {
+ 'Meta': {'object_name': 'Activity', 'db_table': "u'activity'"},
+ 'active_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'activity_type': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_auditted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Post']", 'null': 'True'}),
+ 'receiving_users': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'received_activity'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
+ 'recipients': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'incoming_activity'", 'symmetrical': 'False', 'through': "orm['askbot.ActivityAuditStatus']", 'to': "orm['auth.User']"}),
+ 'summary': ('django.db.models.fields.TextField', [], {'default': "''"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'askbot.activityauditstatus': {
+ 'Meta': {'unique_together': "(('user', 'activity'),)", 'object_name': 'ActivityAuditStatus'},
+ 'activity': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Activity']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'status': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'askbot.anonymousanswer': {
+ 'Meta': {'object_name': 'AnonymousAnswer'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ip_addr': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'anonymous_answers'", 'to': "orm['askbot.Post']"}),
+ 'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'text': ('django.db.models.fields.TextField', [], {}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+ },
+ 'askbot.anonymousquestion': {
+ 'Meta': {'object_name': 'AnonymousQuestion'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ip_addr': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
+ 'text': ('django.db.models.fields.TextField', [], {}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+ },
+ 'askbot.award': {
+ 'Meta': {'object_name': 'Award', 'db_table': "u'award'"},
+ 'awarded_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'badge': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_badge'", 'to': "orm['askbot.BadgeData']"}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'award_user'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.badgedata': {
+ 'Meta': {'ordering': "('slug',)", 'object_name': 'BadgeData'},
+ 'awarded_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'awarded_to': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'badges'", 'symmetrical': 'False', 'through': "orm['askbot.Award']", 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'})
+ },
+ 'askbot.emailfeedsetting': {
+ 'Meta': {'object_name': 'EmailFeedSetting'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'feed_type': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
+ 'frequency': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '8'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'reported_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+ 'subscriber': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notification_subscriptions'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.favoritequestion': {
+ 'Meta': {'object_name': 'FavoriteQuestion', 'db_table': "u'favorite_question'"},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'thread': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Thread']"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_favorite_questions'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.markedtag': {
+ 'Meta': {'object_name': 'MarkedTag'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'reason': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
+ 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'user_selections'", 'to': "orm['askbot.Tag']"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tag_selections'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.post': {
+ 'Meta': {'object_name': 'Post'},
+ 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'posts'", 'to': "orm['auth.User']"}),
+ 'comment_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'html': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_edited_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'last_edited_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_edited_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'locked_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'locked_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'locked_posts'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'offensive_flag_count': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'comment_posts'", 'null': 'True', 'to': "orm['askbot.Post']"}),
+ 'post_type': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '180'}),
+ 'text': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'thread': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'posts'", 'to': "orm['askbot.Thread']"}),
+ 'vote_down_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'vote_up_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'wiki': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'wikified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'})
+ },
+ 'askbot.postrevision': {
+ 'Meta': {'ordering': "('-revision',)", 'unique_together': "(('post', 'revision'),)", 'object_name': 'PostRevision'},
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'postrevisions'", 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'post': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'revisions'", 'null': 'True', 'to': "orm['askbot.Post']"}),
+ 'revised_at': ('django.db.models.fields.DateTimeField', [], {}),
+ 'revision': ('django.db.models.fields.PositiveIntegerField', [], {}),
+ 'revision_type': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'summary': ('django.db.models.fields.CharField', [], {'max_length': '300', 'blank': 'True'}),
+ 'tagnames': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '125', 'blank': 'True'}),
+ 'text': ('django.db.models.fields.TextField', [], {}),
+ 'title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '300', 'blank': 'True'})
+ },
+ 'askbot.questionview': {
+ 'Meta': {'object_name': 'QuestionView'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'question': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'viewed'", 'to': "orm['askbot.Post']"}),
+ 'when': ('django.db.models.fields.DateTimeField', [], {}),
+ 'who': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'question_views'", 'to': "orm['auth.User']"})
+ },
+ 'askbot.repute': {
+ 'Meta': {'object_name': 'Repute', 'db_table': "u'repute'"},
+ 'comment': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'negative': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'positive': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'question_post': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['askbot.Post']", 'null': 'True', 'blank': 'True'}),
+ 'reputation': ('django.db.models.fields.IntegerField', [], {'default': '1'}),
+ 'reputation_type': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'reputed_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'askbot.tag': {
+ 'Meta': {'ordering': "('-used_count', 'name')", 'object_name': 'Tag', 'db_table': "u'tag'"},
+ 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_tags'", 'to': "orm['auth.User']"}),
+ 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'deleted_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'deleted_tags'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+ 'used_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
+ },
+ 'askbot.thread': {
+ 'Meta': {'object_name': 'Thread'},
+ 'accepted_answer': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'to': "orm['askbot.Post']"}),
+ 'answer_accepted_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'answer_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'close_reason': ('django.db.models.fields.SmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'closed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'closed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'closed_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
+ 'favorited_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'unused_favorite_threads'", 'symmetrical': 'False', 'through': "orm['askbot.FavoriteQuestion']", 'to': "orm['auth.User']"}),
+ 'favourite_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'followed_by': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'followed_threads'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'last_activity_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_activity_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'unused_last_active_in_threads'", 'to': "orm['auth.User']"}),
+ 'tagnames': ('django.db.models.fields.CharField', [], {'max_length': '125'}),
+ 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'threads'", 'symmetrical': 'False', 'to': "orm['askbot.Tag']"}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
+ 'view_count': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'})
+ },
+ 'askbot.vote': {
+ 'Meta': {'unique_together': "(('user', 'voted_post'),)", 'object_name': 'Vote', 'db_table': "u'vote'"},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'votes'", 'to': "orm['auth.User']"}),
+ 'vote': ('django.db.models.fields.SmallIntegerField', [], {}),
+ 'voted_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'voted_post': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'post_votes'", 'to': "orm['askbot.Post']"})
+ },
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'about': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'avatar_type': ('django.db.models.fields.CharField', [], {'default': "'n'", 'max_length': '1'}),
+ 'bronze': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'consecutive_days_visit_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'country': ('django_countries.fields.CountryField', [], {'max_length': '2', 'blank': 'True'}),
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ 'display_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'email_isvalid': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'email_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
+ 'email_tag_filter_strategy': ('django.db.models.fields.SmallIntegerField', [], {'default': '1'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'gold': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'gravatar': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ignored_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'interesting_tags': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'location': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'new_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'questions_per_page': ('django.db.models.fields.SmallIntegerField', [], {'default': '10'}),
+ 'real_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'reputation': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
+ 'seen_response_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'show_country': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'silver': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+ 'status': ('django.db.models.fields.CharField', [], {'default': "'w'", 'max_length': '2'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}),
+ 'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ }
+ }
+
+ complete_apps = ['askbot']
diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py
index d83aeaad..a96a8251 100644
--- a/askbot/models/__init__.py
+++ b/askbot/models/__init__.py
@@ -20,12 +20,12 @@ from django_countries.fields import CountryField
from askbot import exceptions as askbot_exceptions
from askbot import const
from askbot.conf import settings as askbot_settings
-from askbot.models.question import Question, Thread
+from askbot.models.question import Thread
from askbot.models.question import QuestionView, AnonymousQuestion
from askbot.models.question import FavoriteQuestion
-from askbot.models.answer import Answer, AnonymousAnswer
+from askbot.models.answer import AnonymousAnswer
from askbot.models.tag import Tag, MarkedTag
-from askbot.models.meta import Vote, Comment
+from askbot.models.meta import Vote
from askbot.models.user import EmailFeedSetting, ActivityAuditStatus, Activity
from askbot.models.post import Post, PostRevision
from askbot.models import signals
@@ -608,12 +608,15 @@ def user_assert_can_edit_answer(self, answer = None):
def user_assert_can_delete_post(self, post = None):
- if isinstance(post, Question):
+ post_type = getattr(post, 'post_type', '')
+ if post_type == 'question':
self.assert_can_delete_question(question = post)
- elif isinstance(post, Answer):
+ elif post_type == 'answer':
self.assert_can_delete_answer(answer = post)
- elif isinstance(post, Comment):
+ elif post_type == 'comment':
self.assert_can_delete_comment(comment = post)
+ else:
+ raise ValueError('Invalid post_type!')
def user_assert_can_restore_post(self, post = None):
"""can_restore_rule is the same as can_delete
@@ -632,11 +635,8 @@ def user_assert_can_delete_question(self, question = None):
if self == question.get_owner():
#if there are answers by other people,
#then deny, unless user in admin or moderator
- answer_count = question.answers.exclude(
- author = self,
- ).exclude(
- score__lte = 0
- ).count()
+ answer_count = question.thread.all_answers()\
+ .exclude(author=self).exclude(score__lte=0).count()
if answer_count > 0:
if self.is_administrator() or self.is_moderator():
@@ -684,7 +684,7 @@ def user_assert_can_delete_answer(self, answer = None):
def user_assert_can_close_question(self, question = None):
- assert(isinstance(question, Question) == True)
+ assert(getattr(question, 'post_type', '') == 'question')
blocked_error_message = _(
'Sorry, since your account is blocked '
'you cannot close questions'
@@ -950,8 +950,6 @@ def user_post_comment(
comment = body_text,
added_at = timestamp,
)
- if hasattr(comment, 'self_comment'): # Handle Post-s
- comment = comment.self_comment
award_badges_signal.send(None,
event = 'post_comment',
actor = self,
@@ -1281,7 +1279,7 @@ def user_post_question(
wiki = wiki,
is_anonymous = is_anonymous,
)
- question = thread._question()
+ question = thread._question_post()
if question.author != self:
raise ValueError('question.author != self')
question.author = self # HACK: Some tests require that question.author IS exactly the same object as self-user (kind of identity map which Django doesn't provide),
@@ -1293,12 +1291,9 @@ def user_edit_comment(self, comment_post=None, body_text = None):
change the comments timestamp and no signals are sent
"""
self.assert_can_edit_comment(comment_post)
- comment_post.self_comment.comment = body_text
- comment_post.self_comment.parse_and_save(author = self)
+ comment_post.text = body_text
+ comment_post.parse_and_save(author = self)
- # HACK: We have to update this `comment_post` instance to reflect comment changes
- comment_post.text = comment_post.self_comment.comment
- comment_post.html = comment_post.self_comment.html
@auto_now_timestamp
def user_edit_question(
@@ -1431,7 +1426,7 @@ def user_post_answer(
award_badges_signal.send(None,
event = 'post_answer',
actor = self,
- context_object = answer_post.self_answer
+ context_object = answer_post
)
return answer_post
@@ -1443,21 +1438,14 @@ def user_visit_question(self, question = None, timestamp = None):
and remove pending on-screen notifications about anything in
the post - question, answer or comments
"""
- if not isinstance(question, Question):
- raise TypeError('question type expected, have %s' % type(question))
if timestamp is None:
timestamp = datetime.datetime.now()
try:
- question_view = QuestionView.objects.get(
- who = self,
- question = question
- )
+ question_view = QuestionView.objects.get(who=self, question=question)
except QuestionView.DoesNotExist:
- question_view = QuestionView(
- who = self,
- question = question
- )
+ question_view = QuestionView(who=self, question=question)
+
question_view.when = timestamp
question_view.save()
@@ -2574,7 +2562,7 @@ def record_update_tags(thread, tags, user, timestamp, **kwargs):
timestamp = timestamp
)
- question = thread._question()
+ question = thread._question_post()
activity = Activity(
user=user,
@@ -2595,10 +2583,10 @@ def record_favorite_question(instance, created, **kwargs):
active_at=datetime.datetime.now(),
content_object=instance,
activity_type=const.TYPE_ACTIVITY_FAVORITE,
- question=instance.thread._question()
+ question=instance.thread._question_post()
)
activity.save()
- recipients = instance.thread._question().get_author_list(
+ recipients = instance.thread._question_post().get_author_list(
exclude_list = [instance.user]
)
activity.add_recipients(recipients)
@@ -2664,7 +2652,7 @@ django_signals.pre_save.connect(calculate_gravatar_hash, sender=User)
django_signals.post_save.connect(add_missing_subscriptions, sender=User)
django_signals.post_save.connect(record_award_event, sender=Award)
django_signals.post_save.connect(notify_award_message, sender=Award)
-django_signals.post_save.connect(record_answer_accepted, sender=Answer)
+#django_signals.post_save.connect(record_answer_accepted, sender=Answer)
django_signals.post_save.connect(record_vote, sender=Vote)
django_signals.post_save.connect(
record_favorite_question,
@@ -2685,28 +2673,28 @@ if 'avatar' in django_settings.INSTALLED_APPS:
django_signals.post_delete.connect(record_cancel_vote, sender=Vote)
#change this to real m2m_changed with Django1.2
-signals.delete_question_or_answer.connect(record_delete_question, sender=Question)
-signals.delete_question_or_answer.connect(record_delete_question, sender=Answer)
-signals.flag_offensive.connect(record_flag_offensive, sender=Question)
-signals.flag_offensive.connect(record_flag_offensive, sender=Answer)
-signals.remove_flag_offensive.connect(remove_flag_offensive, sender=Question)
-signals.remove_flag_offensive.connect(remove_flag_offensive, sender=Answer)
+#signals.delete_question_or_answer.connect(record_delete_question, sender=Question)
+#signals.delete_question_or_answer.connect(record_delete_question, sender=Answer)
+#signals.flag_offensive.connect(record_flag_offensive, sender=Question)
+#signals.flag_offensive.connect(record_flag_offensive, sender=Answer)
+#signals.remove_flag_offensive.connect(remove_flag_offensive, sender=Question)
+#signals.remove_flag_offensive.connect(remove_flag_offensive, sender=Answer)
signals.tags_updated.connect(record_update_tags)
signals.user_updated.connect(record_user_full_updated, sender=User)
signals.user_logged_in.connect(complete_pending_tag_subscriptions)#todo: add this to fake onlogin middleware
signals.user_logged_in.connect(post_anonymous_askbot_content)
-signals.post_updated.connect(
- record_post_update_activity,
- sender=Comment
- )
-signals.post_updated.connect(
- record_post_update_activity,
- sender=Answer
- )
-signals.post_updated.connect(
- record_post_update_activity,
- sender=Question
- )
+#signals.post_updated.connect(
+# record_post_update_activity,
+# sender=Comment
+# )
+#signals.post_updated.connect(
+# record_post_update_activity,
+# sender=Answer
+# )
+#signals.post_updated.connect(
+# record_post_update_activity,
+# sender=Question
+# )
signals.site_visited.connect(record_user_visit)
#set up a possibility for the users to follow others
@@ -2720,19 +2708,17 @@ __all__ = [
'signals',
'Thread',
- 'Question',
+
'QuestionView',
'FavoriteQuestion',
'AnonymousQuestion',
- 'Answer',
'AnonymousAnswer',
'Post',
'PostRevision',
'Tag',
- 'Comment',
'Vote',
'MarkedTag',
@@ -2743,7 +2729,6 @@ __all__ = [
'Activity',
'ActivityAuditStatus',
'EmailFeedSetting',
- #'AuthKeyUserAssociation',
'User',
diff --git a/askbot/models/answer.py b/askbot/models/answer.py
index 69b9f526..429ffd88 100644
--- a/askbot/models/answer.py
+++ b/askbot/models/answer.py
@@ -5,12 +5,12 @@ from askbot.models import content
from askbot import const
-class Answer(content.Content):
- post_type = 'answer'
- question = models.ForeignKey('Question', related_name='answers')
-
- class Meta(content.Content.Meta):
- db_table = u'answer'
+#class Answer(content.Content):
+# post_type = 'answer'
+# question = models.ForeignKey('Question', related_name='answers')
+#
+# class Meta(content.Content.Meta):
+# db_table = u'answer'
class AnonymousAnswer(AnonymousContent):
diff --git a/askbot/models/badges.py b/askbot/models/badges.py
index 451eefc3..df96efdc 100644
--- a/askbot/models/badges.py
+++ b/askbot/models/badges.py
@@ -24,7 +24,6 @@ from django.utils.translation import ugettext as _
from django.dispatch import Signal
from askbot.models.repute import BadgeData, Award
from askbot.models.user import Activity
-from askbot.models.meta import Comment
from askbot.models.question import FavoriteQuestion as Fave#name collision
from askbot import const
from askbot.conf import settings as askbot_settings
diff --git a/askbot/models/content.py b/askbot/models/content.py
index 30abd50c..871e85cc 100644
--- a/askbot/models/content.py
+++ b/askbot/models/content.py
@@ -1,7 +1,7 @@
import datetime
+import operator
from django.conf import settings
from django.contrib.auth.models import User
-from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
from django.core import urlresolvers
from django.db import models
@@ -13,9 +13,8 @@ from django.core import exceptions as django_exceptions
from askbot.utils.slug import slugify
from askbot import const
-from askbot.models.meta import Comment, Vote
from askbot.models.user import EmailFeedSetting
-from askbot.models.tag import Tag, MarkedTag, tags_match_some_wildcard
+from askbot.models.tag import MarkedTag, tags_match_some_wildcard
from askbot.models.base import parse_post_text, parse_and_save_post
from askbot.conf import settings as askbot_settings
from askbot import exceptions
@@ -51,8 +50,6 @@ class Content(models.Model):
html = models.TextField(null=True)#html rendition of the latest revision
text = models.TextField(null=True)#denormalized copy of latest revision
- comments = generic.GenericRelation(Comment)
- votes = generic.GenericRelation(Vote)
# Denormalised data
summary = models.CharField(max_length=180)
@@ -129,20 +126,15 @@ class Content(models.Model):
if visitor.is_anonymous():
return self.comments.all().order_by('id')
else:
- comment_content_type = ContentType.objects.get_for_model(Comment)
- #a fancy query to annotate comments with the visitor votes
- comments = self.comments.extra(
- select = SortedDict([
- (
- 'upvoted_by_user',
- 'SELECT COUNT(*) from vote, comment '
- 'WHERE vote.user_id = %s AND '
- 'vote.content_type_id = %s AND '
- 'vote.object_id = comment.id',
- )
- ]),
- select_params = (visitor.id, comment_content_type.id)
- ).order_by('id')
+ upvoted_by_user = list(self.comments.filter(votes__user=visitor))
+ not_upvoted_by_user = list(self.comments.exclude(votes__user=visitor))
+
+ for c in upvoted_by_user:
+ c.upvoted_by_user = 1 # numeric value to maintain compatibility with previous version of this code
+
+ comments = upvoted_by_user + not_upvoted_by_user
+ comments.sort(key=operator.attrgetter('id'))
+
return comments
#todo: maybe remove this wnen post models are unified
diff --git a/askbot/models/meta.py b/askbot/models/meta.py
index d707ea72..e39fece8 100644
--- a/askbot/models/meta.py
+++ b/askbot/models/meta.py
@@ -38,7 +38,7 @@ class Vote(models.Model):
(VOTE_DOWN, u'Down'),
)
user = models.ForeignKey('auth.User', related_name='votes')
- voted_post = models.ForeignKey('Post', related_name='post_votes')
+ voted_post = models.ForeignKey('Post', related_name='votes')
vote = models.SmallIntegerField(choices=VOTE_CHOICES)
voted_at = models.DateTimeField(default=datetime.datetime.now)
@@ -89,246 +89,246 @@ class Vote(models.Model):
return score_after - score_before
-class Comment(models.Model):
- post_type = 'comment'
- comment = models.CharField(max_length = const.COMMENT_HARD_MAX_LENGTH)
- added_at = models.DateTimeField(default = datetime.datetime.now)
- html = models.CharField(max_length = const.COMMENT_HARD_MAX_LENGTH, default='')
- score = models.IntegerField(default = 0)
- offensive_flag_count = models.IntegerField(default = 0)
-
- user = models.ForeignKey('auth.User', related_name='comments')
-
- content_type = models.ForeignKey(ContentType)
- object_id = models.PositiveIntegerField()
- content_object = generic.GenericForeignKey('content_type', 'object_id')
-
- _urlize = True
- _use_markdown = True
- _escape_html = True
- is_anonymous = False #comments are never anonymous - may change
-
- class Meta:
- ordering = ('-added_at',)
- app_label = 'askbot'
- db_table = u'comment'
-
- #these two are methods
- parse = base.parse_post_text
- parse_and_save = base.parse_and_save_post
-
- def assert_is_visible_to(self, user):
- """raises QuestionHidden or AnswerHidden"""
- try:
- self.content_object.assert_is_visible_to(user)
- except exceptions.QuestionHidden:
- message = _(
- 'Sorry, the comment you are looking for is no '
- 'longer accessible, because the parent question '
- 'has been removed'
- )
- raise exceptions.QuestionHidden(message)
- except exceptions.AnswerHidden:
- message = _(
- 'Sorry, the comment you are looking for is no '
- 'longer accessible, because the parent answer '
- 'has been removed'
- )
- raise exceptions.AnswerHidden(message)
-
- def get_origin_post(self):
- return self.content_object.get_origin_post()
-
- def get_tag_names(self):
- """return tag names of the origin question"""
- return self.get_origin_post().get_tag_names()
-
- def get_page_number(self, answers = None):
- """return page number whithin the page
- where the comment is going to appear
- answers parameter will not be used if the comment belongs
- to a question, otherwise answers list or queryset
- will be used to determine the page number"""
- return self.content_object.get_page_number(answers = answers)
-
- def get_order_number(self):
- return self.content_object.comments.filter(
- added_at__lt = self.added_at
- ).count() + 1
-
- #todo: maybe remove this wnen post models are unified
- def get_text(self):
- return self.comment
-
- def set_text(self, text):
- self.comment = text
-
- def get_snippet(self):
- """returns an abbreviated snippet of the content
- todo: remove this if comment model unites with Q&A
- """
- return html_utils.strip_tags(self.html)[:120] + ' ...'
-
- def get_owner(self):
- return self.user
-
- def get_updated_activity_data(self, created = False):
- if self.content_object.post_type == 'question':
- return const.TYPE_ACTIVITY_COMMENT_QUESTION, self
- elif self.content_object.post_type == 'answer':
- return const.TYPE_ACTIVITY_COMMENT_ANSWER, self
-
- def get_response_receivers(self, exclude_list = None):
- """Response receivers are commenters of the
- same post and the authors of the post itself.
- """
- assert(exclude_list is not None)
- users = set()
- #get authors of parent object and all associated comments
- users.update(
- self.content_object.get_author_list(
- include_comments = True,
- )
- )
- users -= set(exclude_list)
- return list(users)
-
- def get_instant_notification_subscribers(
- self,
- potential_subscribers = None,
- mentioned_users = None,
- exclude_list = None
- ):
- """get list of users who want instant notifications about comments
-
- argument potential_subscribers is required as it saves on db hits
-
- Here is the list of people who will receive the notifications:
-
- * mentioned users
- * of response receivers
- (see :meth:`~askbot.models.meta.Comment.get_response_receivers`) -
- those who subscribe for the instant
- updates on comments and @mentions
- * all who follow the question explicitly
- * all global subscribers
- (tag filtered, and subject to personalized settings)
- """
- #print 'in meta function'
- #print 'potential subscribers: ', potential_subscribers
-
- subscriber_set = set()
-
- if potential_subscribers:
- potential_subscribers = set(potential_subscribers)
- else:
- potential_subscribers = set()
-
- if mentioned_users:
- potential_subscribers.update(mentioned_users)
-
- if potential_subscribers:
- comment_subscribers = EmailFeedSetting.objects.filter_subscribers(
- potential_subscribers = potential_subscribers,
- feed_type = 'm_and_c',
- frequency = 'i'
- )
- subscriber_set.update(comment_subscribers)
- #print 'comment subscribers: ', comment_subscribers
-
- origin_post = self.get_origin_post()
- # TODO: The line below works only if origin_post is Question !
- selective_subscribers = origin_post.thread.followed_by.all()
- if selective_subscribers:
- selective_subscribers = EmailFeedSetting.objects.filter_subscribers(
- potential_subscribers = selective_subscribers,
- feed_type = 'q_sel',
- frequency = 'i'
- )
- for subscriber in selective_subscribers:
- if origin_post.passes_tag_filter_for_user(subscriber):
- subscriber_set.add(subscriber)
-
- subscriber_set.update(selective_subscribers)
- #print 'selective subscribers: ', selective_subscribers
-
- global_subscribers = origin_post.get_global_instant_notification_subscribers()
- #print 'global subscribers: ', global_subscribers
-
- subscriber_set.update(global_subscribers)
-
- #print 'exclude list is: ', exclude_list
- if exclude_list:
- subscriber_set -= set(exclude_list)
-
- #print 'final list of subscribers:', subscriber_set
-
- return list(subscriber_set)
-
- def get_time_of_last_edit(self):
- return self.added_at
-
- def delete(self, **kwargs):
- """deletes comment and concomitant response activity
- records, as well as mention records, while preserving
- integrity or response counts for the users
- """
- comment_content_type = ContentType.objects.get_for_model(self)
- comment_id = self.id
-
- #todo: implement a custom delete method on these
- #all this should pack into Activity.responses.filter( somehow ).delete()
- activity_types = const.RESPONSE_ACTIVITY_TYPES_FOR_DISPLAY
- activity_types += (const.TYPE_ACTIVITY_MENTION,)
- #todo: not very good import in models of other models
- #todo: potentially a circular import
- from askbot.models.user import Activity
- activities = Activity.objects.filter(
- content_type = comment_content_type,
- object_id = comment_id,
- activity_type__in = activity_types
- )
-
- recipients = set()
- for activity in activities:
- for user in activity.recipients.all():
- recipients.add(user)
-
- #activities need to be deleted before the response
- #counts are updated
- activities.delete()
-
- for user in recipients:
- user.update_response_counts()
-
- super(Comment,self).delete(**kwargs)
-
- def get_absolute_url(self):
- origin_post = self.get_origin_post()
- return '%(url)s?comment=%(id)d#comment-%(id)d' % \
- {'url': origin_post.get_absolute_url(), 'id':self.id}
-
- def get_latest_revision_number(self):
- return 1
-
- def is_upvoted_by(self, user):
- content_type = ContentType.objects.get_for_model(self)
- what_to_count = {
- 'user': user,
- 'object_id': self.id,
- 'content_type': content_type
- }
- return Vote.objects.filter(**what_to_count).count() > 0
-
- def is_last(self):
- """True if there are no newer comments on
- the related parent object
- """
- return Comment.objects.filter(
- added_at__gt = self.added_at,
- object_id = self.object_id,
- content_type = self.content_type
- ).count() == 0
-
- def __unicode__(self):
- return self.comment
+#class Comment(models.Model):
+# post_type = 'comment'
+# comment = models.CharField(max_length = const.COMMENT_HARD_MAX_LENGTH)
+# added_at = models.DateTimeField(default = datetime.datetime.now)
+# html = models.CharField(max_length = const.COMMENT_HARD_MAX_LENGTH, default='')
+# score = models.IntegerField(default = 0)
+# offensive_flag_count = models.IntegerField(default = 0)
+#
+# user = models.ForeignKey('auth.User', related_name='comments')
+#
+# content_type = models.ForeignKey(ContentType)
+# object_id = models.PositiveIntegerField()
+# content_object = generic.GenericForeignKey('content_type', 'object_id')
+#
+# _urlize = True
+# _use_markdown = True
+# _escape_html = True
+# is_anonymous = False #comments are never anonymous - may change
+#
+# class Meta:
+# ordering = ('-added_at',)
+# app_label = 'askbot'
+# db_table = u'comment'
+#
+# #these two are methods
+# parse = base.parse_post_text
+# parse_and_save = base.parse_and_save_post
+#
+# def assert_is_visible_to(self, user):
+# """raises QuestionHidden or AnswerHidden"""
+# try:
+# self.content_object.assert_is_visible_to(user)
+# except exceptions.QuestionHidden:
+# message = _(
+# 'Sorry, the comment you are looking for is no '
+# 'longer accessible, because the parent question '
+# 'has been removed'
+# )
+# raise exceptions.QuestionHidden(message)
+# except exceptions.AnswerHidden:
+# message = _(
+# 'Sorry, the comment you are looking for is no '
+# 'longer accessible, because the parent answer '
+# 'has been removed'
+# )
+# raise exceptions.AnswerHidden(message)
+#
+# def get_origin_post(self):
+# return self.content_object.get_origin_post()
+#
+# def get_tag_names(self):
+# """return tag names of the origin question"""
+# return self.get_origin_post().get_tag_names()
+#
+# def get_page_number(self, answers = None):
+# """return page number whithin the page
+# where the comment is going to appear
+# answers parameter will not be used if the comment belongs
+# to a question, otherwise answers list or queryset
+# will be used to determine the page number"""
+# return self.content_object.get_page_number(answers = answers)
+#
+# def get_order_number(self):
+# return self.content_object.comments.filter(
+# added_at__lt = self.added_at
+# ).count() + 1
+#
+# #todo: maybe remove this wnen post models are unified
+# def get_text(self):
+# return self.comment
+#
+# def set_text(self, text):
+# self.comment = text
+#
+# def get_snippet(self):
+# """returns an abbreviated snippet of the content
+# todo: remove this if comment model unites with Q&A
+# """
+# return html_utils.strip_tags(self.html)[:120] + ' ...'
+#
+# def get_owner(self):
+# return self.user
+#
+# def get_updated_activity_data(self, created = False):
+# if self.content_object.post_type == 'question':
+# return const.TYPE_ACTIVITY_COMMENT_QUESTION, self
+# elif self.content_object.post_type == 'answer':
+# return const.TYPE_ACTIVITY_COMMENT_ANSWER, self
+#
+# def get_response_receivers(self, exclude_list = None):
+# """Response receivers are commenters of the
+# same post and the authors of the post itself.
+# """
+# assert(exclude_list is not None)
+# users = set()
+# #get authors of parent object and all associated comments
+# users.update(
+# self.content_object.get_author_list(
+# include_comments = True,
+# )
+# )
+# users -= set(exclude_list)
+# return list(users)
+#
+# def get_instant_notification_subscribers(
+# self,
+# potential_subscribers = None,
+# mentioned_users = None,
+# exclude_list = None
+# ):
+# """get list of users who want instant notifications about comments
+#
+# argument potential_subscribers is required as it saves on db hits
+#
+# Here is the list of people who will receive the notifications:
+#
+# * mentioned users
+# * of response receivers
+# (see :meth:`~askbot.models.meta.Comment.get_response_receivers`) -
+# those who subscribe for the instant
+# updates on comments and @mentions
+# * all who follow the question explicitly
+# * all global subscribers
+# (tag filtered, and subject to personalized settings)
+# """
+# #print 'in meta function'
+# #print 'potential subscribers: ', potential_subscribers
+#
+# subscriber_set = set()
+#
+# if potential_subscribers:
+# potential_subscribers = set(potential_subscribers)
+# else:
+# potential_subscribers = set()
+#
+# if mentioned_users:
+# potential_subscribers.update(mentioned_users)
+#
+# if potential_subscribers:
+# comment_subscribers = EmailFeedSetting.objects.filter_subscribers(
+# potential_subscribers = potential_subscribers,
+# feed_type = 'm_and_c',
+# frequency = 'i'
+# )
+# subscriber_set.update(comment_subscribers)
+# #print 'comment subscribers: ', comment_subscribers
+#
+# origin_post = self.get_origin_post()
+# # TODO: The line below works only if origin_post is Question !
+# selective_subscribers = origin_post.thread.followed_by.all()
+# if selective_subscribers:
+# selective_subscribers = EmailFeedSetting.objects.filter_subscribers(
+# potential_subscribers = selective_subscribers,
+# feed_type = 'q_sel',
+# frequency = 'i'
+# )
+# for subscriber in selective_subscribers:
+# if origin_post.passes_tag_filter_for_user(subscriber):
+# subscriber_set.add(subscriber)
+#
+# subscriber_set.update(selective_subscribers)
+# #print 'selective subscribers: ', selective_subscribers
+#
+# global_subscribers = origin_post.get_global_instant_notification_subscribers()
+# #print 'global subscribers: ', global_subscribers
+#
+# subscriber_set.update(global_subscribers)
+#
+# #print 'exclude list is: ', exclude_list
+# if exclude_list:
+# subscriber_set -= set(exclude_list)
+#
+# #print 'final list of subscribers:', subscriber_set
+#
+# return list(subscriber_set)
+#
+# def get_time_of_last_edit(self):
+# return self.added_at
+#
+# def delete(self, **kwargs):
+# """deletes comment and concomitant response activity
+# records, as well as mention records, while preserving
+# integrity or response counts for the users
+# """
+# comment_content_type = ContentType.objects.get_for_model(self)
+# comment_id = self.id
+#
+# #todo: implement a custom delete method on these
+# #all this should pack into Activity.responses.filter( somehow ).delete()
+# activity_types = const.RESPONSE_ACTIVITY_TYPES_FOR_DISPLAY
+# activity_types += (const.TYPE_ACTIVITY_MENTION,)
+# #todo: not very good import in models of other models
+# #todo: potentially a circular import
+# from askbot.models.user import Activity
+# activities = Activity.objects.filter(
+# content_type = comment_content_type,
+# object_id = comment_id,
+# activity_type__in = activity_types
+# )
+#
+# recipients = set()
+# for activity in activities:
+# for user in activity.recipients.all():
+# recipients.add(user)
+#
+# #activities need to be deleted before the response
+# #counts are updated
+# activities.delete()
+#
+# for user in recipients:
+# user.update_response_counts()
+#
+# super(Comment,self).delete(**kwargs)
+#
+# def get_absolute_url(self):
+# origin_post = self.get_origin_post()
+# return '%(url)s?comment=%(id)d#comment-%(id)d' % \
+# {'url': origin_post.get_absolute_url(), 'id':self.id}
+#
+# def get_latest_revision_number(self):
+# return 1
+#
+# def is_upvoted_by(self, user):
+# content_type = ContentType.objects.get_for_model(self)
+# what_to_count = {
+# 'user': user,
+# 'object_id': self.id,
+# 'content_type': content_type
+# }
+# return Vote.objects.filter(**what_to_count).count() > 0
+#
+# def is_last(self):
+# """True if there are no newer comments on
+# the related parent object
+# """
+# return Comment.objects.filter(
+# added_at__gt = self.added_at,
+# object_id = self.object_id,
+# content_type = self.content_type
+# ).count() == 0
+#
+# def __unicode__(self):
+# return self.comment
diff --git a/askbot/models/post.py b/askbot/models/post.py
index 9b6d9acb..26de39dc 100644
--- a/askbot/models/post.py
+++ b/askbot/models/post.py
@@ -53,19 +53,14 @@ class PostManager(models.Manager):
class Post(content.Content):
post_type = models.CharField(max_length=255)
- parent = models.ForeignKey('Post', blank=True, null=True, related_name='comment_posts') # Answer or Question for Comment
+ parent = models.ForeignKey('Post', blank=True, null=True, related_name='comments') # Answer or Question for Comment
+ thread = models.ForeignKey('Thread', related_name='posts')
- self_answer = models.ForeignKey('Answer', blank=True, null=True, related_name='+', on_delete=models.SET_NULL)
- self_question = models.ForeignKey('Question', blank=True, null=True, related_name='+', on_delete=models.SET_NULL)
- self_comment = models.ForeignKey('Comment', blank=True, null=True, related_name='+', on_delete=models.SET_NULL)
+ objects = PostManager()
question = property(fget=lambda self: self.thread._question_post()) # to simulate Answer model
question_id = property(fget=lambda self: self.thread._question_post().id) # to simulate Answer model
- thread = models.ForeignKey('Thread', related_name='posts')
-
- objects = PostManager()
-
class Meta:
app_label = 'askbot'
db_table = 'askbot_post'
@@ -78,12 +73,12 @@ class Post(content.Content):
if self.is_answer():
return u'%(base)s%(slug)s?answer=%(id)d#answer-container-%(id)d' % \
{
- 'base': urlresolvers.reverse('question', args=[self.self_answer.question_id]),
+ 'base': urlresolvers.reverse('question', args=[self.thread._question_post().id]),
'slug': django_urlquote(slugify(self.thread.title)),
- 'id': self.self_answer_id
+ 'id': self.id
}
elif self.is_question():
- url = urlresolvers.reverse('question', args=[self.self_question_id])
+ url = urlresolvers.reverse('question', args=[self.id])
if no_slug == True:
return url
else:
@@ -92,15 +87,19 @@ class Post(content.Content):
def delete(self, *args, **kwargs):
- # Redirect the deletion to the relevant Question or Answer instance
# WARNING: This is not called for batch deletions so watch out!
- real_post = self.self_answer or self.self_question
- real_post.delete(*args, **kwargs)
+ # TODO: Restore specialized Comment.delete() functionality!
+ self.delete(*args, **kwargs)
def is_answer_accepted(self):
if not self.is_answer():
raise NotImplementedError
- return self.thread.accepted_answer_id and (self.thread.accepted_answer_id == self.self_answer_id)
+ return self == self.thread.accepted_answer
+
+ def accepted(self):
+ if self.is_answer():
+ return self.question.thread.accepted_answer == self
+ raise NotImplementedError
def get_page_number(self, answer_posts):
"""When question has many answers, answers are
@@ -123,55 +122,16 @@ class Post(content.Content):
return int(order_number/const.ANSWERS_PAGE_SIZE) + 1
def revisions(self):
- if self.self_question:
- return self.self_question.revisions.all()
- elif self.self_answer:
- return self.self_answer.revisions.all()
- raise NotImplementedError
+ return self.revisions.all()
def get_latest_revision(self):
return self.revisions().order_by('-revised_at')[0]
def apply_edit(self, *kargs, **kwargs):
- post = (self.self_answer or self.self_question)
- if not post:
+ if self.post_type not in ('question', 'answer'):
raise NotImplementedError
return post.apply_edit(*kargs, **kwargs)
- def add_comment(self, *args, **kwargs):
- if self.self_question:
- comment = self.self_question.add_comment(*args, **kwargs)
- elif self.self_answer:
- comment = self.self_answer.add_comment(*args, **kwargs)
- else:
- raise NotImplementedError
- return self.__class__.objects.get(self_comment=comment)
-
- def get_comments(self, *args, **kwargs):
- if self.self_question:
- comments = self.self_question.get_comments(*args, **kwargs)
- elif self.self_answer:
- comments = self.self_answer.get_comments(*args, **kwargs)
- else:
- raise NotImplementedError
- # TODO: Convert `comments` to Post-s (there are lots of dependencies, though)
- return comments
-
- def accepted(self):
- if self.is_answer():
- return self.question.thread.accepted_answer == self
- raise NotImplementedError
-
-
-
-for field in Post._meta.fields:
- if isinstance(field, models.ForeignKey):
- # HACK: Patch all foreign keys to not cascade when deleted
- # This is required because foreign keys on Post create normal backreferences
- # in the destination models, so e.g. deleting User instance would trigger Post instance deletion,
- # which is not what should happen.
- field.rel.on_delete = models.DO_NOTHING
-
class PostRevisionManager(models.Manager):
def create(self, *kargs, **kwargs):
diff --git a/askbot/models/question.py b/askbot/models/question.py
index f14a3279..61626662 100644
--- a/askbot/models/question.py
+++ b/askbot/models/question.py
@@ -305,7 +305,7 @@ class Thread(models.Model):
blank=True
)
- accepted_answer_post = models.ForeignKey(Post, null=True, blank=True, related_name='+')
+ accepted_answer = models.ForeignKey(Post, null=True, blank=True, related_name='+')
answer_accepted_at = models.DateTimeField(null=True, blank=True)
objects = ThreadManager()
@@ -313,14 +313,11 @@ class Thread(models.Model):
class Meta:
app_label = 'askbot'
- def _question(self):
- return Question.objects.get(thread=self)
-
def _question_post(self):
- return Post.objects.get(thread=self)
+ return Post.objects.get(post_type='question', thread=self)
def get_absolute_url(self):
- return self._question().get_absolute_url()
+ return self._question_post().get_absolute_url()
def update_favorite_count(self):
self.favourite_count = FavoriteQuestion.objects.filter(thread=self).count()
@@ -361,7 +358,7 @@ class Thread(models.Model):
def get_title(self):
if self.closed:
attr = const.POST_STATUS['closed']
- elif self._question().deleted:
+ elif self._question_post().deleted:
attr = const.POST_STATUS['deleted']
else:
attr = None
@@ -373,6 +370,9 @@ class Thread(models.Model):
def tagname_meta_generator(self):
return u','.join([unicode(tag) for tag in self.get_tag_names()])
+ def all_answers(self):
+ return self.posts.get_answers()
+
def get_answers(self, user=None):
"""returns query set for answers to this question
that may be shown to the given user
@@ -433,8 +433,8 @@ class Thread(models.Model):
#note: see note for the is_anonymous field
#it is important that update method is called - not save,
#because we do not want the signals to fire here
- thread_question = self._question()
- Question.objects.filter(id=thread_question.id).update(is_anonymous=False)
+ thread_question = self._question_post()
+ Post.objects.filter(id=thread_question.id).update(is_anonymous=False)
thread_question.revisions.all().update(is_anonymous=False)
def update_tags(self, tagnames = None, user = None, timestamp = None):
@@ -451,7 +451,7 @@ class Thread(models.Model):
A signal tags updated is sent
- *IMPORTANT*: self._question() has to exist when update_tags() is called!
+ *IMPORTANT*: self._question_post() has to exist when update_tags() is called!
"""
previous_tags = list(self.tags.all())
@@ -525,7 +525,7 @@ class Thread(models.Model):
if None in (retagged_by, retagged_at, tagnames):
raise Exception('arguments retagged_at, retagged_by and tagnames are required')
- thread_question = self._question()
+ thread_question = self._question_post()
self.tagnames = tagnames
self.save()
@@ -886,30 +886,30 @@ class QuestionManager(BaseQuerySetManager):
return QuestionQuerySet(self.model)
-class Question(content.Content):
- post_type = 'question'
- thread = models.ForeignKey('Thread', unique=True, related_name='questions')
-
- objects = QuestionManager()
-
- class Meta(content.Content.Meta):
- db_table = u'question'
-
-
-if getattr(settings, 'USE_SPHINX_SEARCH', False):
- from djangosphinx.models import SphinxSearch
- Question.add_to_class(
- 'sphinx_search',
- SphinxSearch(
- index = settings.ASKBOT_SPHINX_SEARCH_INDEX,
- mode = 'SPH_MATCH_ALL'
- )
- )
+#class Question(content.Content):
+# post_type = 'question'
+# thread = models.ForeignKey('Thread', unique=True, related_name='questions')
+#
+# objects = QuestionManager()
+#
+# class Meta(content.Content.Meta):
+# db_table = u'question'
+#
+#
+#if getattr(settings, 'USE_SPHINX_SEARCH', False):
+# from djangosphinx.models import SphinxSearch
+# Question.add_to_class(
+# 'sphinx_search',
+# SphinxSearch(
+# index = settings.ASKBOT_SPHINX_SEARCH_INDEX,
+# mode = 'SPH_MATCH_ALL'
+# )
+# )
class QuestionView(models.Model):
- question_post = models.ForeignKey(Post, related_name='viewed')
+ question = models.ForeignKey(Post, related_name='viewed')
who = models.ForeignKey(User, related_name='question_views')
when = models.DateTimeField()
diff --git a/askbot/models/user.py b/askbot/models/user.py
index 8578bf06..6f27cbf3 100644
--- a/askbot/models/user.py
+++ b/askbot/models/user.py
@@ -165,7 +165,7 @@ class Activity(models.Model):
content_object = generic.GenericForeignKey('content_type', 'object_id')
#todo: remove this denorm question field when Post model is set up
- question_post = models.ForeignKey('Post', null=True)
+ question = models.ForeignKey('Post', null=True)
is_auditted = models.BooleanField(default=False)
#add summary field.
diff --git a/askbot/sitemap.py b/askbot/sitemap.py
index da58a846..af419af5 100644
--- a/askbot/sitemap.py
+++ b/askbot/sitemap.py
@@ -1,5 +1,5 @@
from django.contrib.sitemaps import Sitemap
-from askbot.models import Question
+#from askbot.models import Question
class QuestionsSitemap(Sitemap):
changefreq = 'daily'
diff --git a/askbot/skins/default/templates/answer_edit.html b/askbot/skins/default/templates/answer_edit.html
index 83c952c8..bbf3edef 100644
--- a/askbot/skins/default/templates/answer_edit.html
+++ b/askbot/skins/default/templates/answer_edit.html
@@ -10,7 +10,7 @@
{% trans %}Edit answer{% endtrans %} [<a href="{{ answer.question.get_absolute_url() }}#{{ answer.id }}">{% trans %}back{% endtrans %}</a>]
</h1>
<div id="main-body" class="ask-body">
- <form id="fmedit" action="{% url edit_answer answer.self_answer_id %}" method="post" >{% csrf_token %}
+ <form id="fmedit" action="{% url edit_answer answer.id %}" method="post" >{% csrf_token %}
<label for="id_revision" >{% trans %}revision{% endtrans %}:</label> <br/>
{% if revision_form.revision.errors %}{{ revision_form.revision.errors.as_ul() }}{% endif %}
<div style="vertical-align:middle">
diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html
index b5591b47..052bcc1d 100644
--- a/askbot/skins/default/templates/macros.html
+++ b/askbot/skins/default/templates/macros.html
@@ -298,7 +298,7 @@ for the purposes of the AJAX comment editor #}
</div>
<div class="comment-body">
{{comment.html}}
- <a class="author" href="{{comment.user.get_profile_url()}}">{{comment.user.username}}</a>
+ <a class="author" href="{{comment.author.get_profile_url()}}">{{comment.author.username}}</a>
<span class="age">&nbsp;({{comment.added_at|diff_date}})</span>
{% if user|can_edit_comment(comment) %}
&nbsp;<a class="edit">{% trans %}edit{% endtrans %}</a>
diff --git a/askbot/skins/default/templates/question.html b/askbot/skins/default/templates/question.html
index 518ebf29..2ec16927 100644
--- a/askbot/skins/default/templates/question.html
+++ b/askbot/skins/default/templates/question.html
@@ -15,7 +15,7 @@
{# ==== BEGIN: question/question_card.html ==== #}
<div class="vote-buttons">
{# ==== BEGIN: question/question_vote_buttons.html ==== #}
- {{ macros.post_vote_buttons(post = question.self_question, visitor_vote = user_question_vote) }}
+ {{ macros.post_vote_buttons(post = question, visitor_vote = user_question_vote) }}
{# ==== END: question/question_vote_buttons.html ==== #}
{# ==== BEGIN: question/share_buttons.html ==== #}
{% if settings.ENABLE_SHARING_TWITTER %}{{ macros.share(site = 'twitter', icon = True) }}{% endif %}
@@ -45,9 +45,9 @@
{{ macros.post_contributor_info(post, "original_author", post.wiki, min_rep_to_edit_wiki) }}
{{ macros.post_contributor_info(post, "last_updater", post.wiki, min_rep_to_edit_wiki) }}
{%- endmacro -%}
- {{ post_last_updater_and_creator_info(question.self_question, settings.MIN_REP_TO_EDIT_WIKI) }}
+ {{ post_last_updater_and_creator_info(question, settings.MIN_REP_TO_EDIT_WIKI) }}
{# ==== START: "question/question_author_info.html"
- {{ macros.post_last_updater_and_creator_info(question.self_question, settings.MIN_REP_TO_EDIT_WIKI) }}
+ {{ macros.post_last_updater_and_creator_info(question, settings.MIN_REP_TO_EDIT_WIKI) }}
==== END: "question/question_author_info.html" #}
</div>
{{ question.html }}
@@ -55,52 +55,52 @@
<div id="question-controls" class="post-controls">
{# ==== START: include "question/question_controls.html" #}
{% set pipe=joiner('<span class="sep">|</span>') %}
- {% if request.user|can_edit_post(question.self_question) %}{{ pipe() }}
- <a class="question-edit" href="{% url edit_question question.self_question_id %}">{% trans %}edit{% endtrans %}</a>
+ {% if request.user|can_edit_post(question) %}{{ pipe() }}
+ <a class="question-edit" href="{% url edit_question question.id %}">{% trans %}edit{% endtrans %}</a>
{% endif %}
- {% if request.user|can_retag_question(question.self_question) %}{{ pipe() }}
- <a id="retag" class="question-retag"href="{% url retag_question question.self_question_id %}">{% trans %}retag{% endtrans %}</a>
+ {% if request.user|can_retag_question(question) %}{{ pipe() }}
+ <a id="retag" class="question-retag"href="{% url retag_question question.id %}">{% trans %}retag{% endtrans %}</a>
<script type="text/javascript">
- var retagUrl = "{% url retag_question question.self_question_id %}";
+ var retagUrl = "{% url retag_question question.id %}";
</script>
{% endif %}
{% if thread.closed %}
- {% if request.user|can_reopen_question(question.self_question) %}{{ pipe() }}
- <a class="question-close" href="{% url reopen question.self_question_id %}">{% trans %}reopen{% endtrans %}</a>
+ {% if request.user|can_reopen_question(question) %}{{ pipe() }}
+ <a class="question-close" href="{% url reopen question.id %}">{% trans %}reopen{% endtrans %}</a>
{% endif %}
{% else %}
- {% if request.user|can_close_question(question.self_question) %}{{ pipe() }}
- <a class="question-close" href="{% url close question.self_question_id %}">{% trans %}close{% endtrans %}</a>
+ {% if request.user|can_close_question(question) %}{{ pipe() }}
+ <a class="question-close" href="{% url close question.id %}">{% trans %}close{% endtrans %}</a>
{% endif %}
{% endif %}
- {% if request.user|can_flag_offensive(question.self_question) %}{{ pipe() }}
- <span id="question-offensive-flag-{{ question.self_question_id }}" class="offensive-flag"
+ {% if request.user|can_flag_offensive(question) %}{{ pipe() }}
+ <span id="question-offensive-flag-{{ question.id }}" class="offensive-flag"
title="{% trans %}report as offensive (i.e containing spam, advertising, malicious text, etc.){% endtrans %}">
<a class="question-flag">{% trans %}flag offensive{% endtrans %}</a>
- {% if request.user|can_see_offensive_flags(question.self_question) %}
+ {% if request.user|can_see_offensive_flags(question) %}
<span class="darkred">{% if question.offensive_flag_count > 0 %}({{ question.offensive_flag_count }}){% endif %}</span>
{% endif %}
</span>
- {% elif request.user|can_remove_flag_offensive(question.self_question)%}{{ pipe() }}
- <span id="question-offensive-flag-remove-{{ question.self_question_id }}" class="offensive-flag"
+ {% elif request.user|can_remove_flag_offensive(question)%}{{ pipe() }}
+ <span id="question-offensive-flag-remove-{{ question.id }}" class="offensive-flag"
title="{% trans %}report as offensive (i.e containing spam, advertising, malicious text, etc.){% endtrans %}">
<a class="question-flag">{% trans %}remove flag{% endtrans %}</a>
- {% if request.user|can_see_offensive_flags(question.self_question) %}
+ {% if request.user|can_see_offensive_flags(question) %}
<span class="darkred">{% if question.offensive_flag_count > 0 %}({{ question.offensive_flag_count }}){% endif %}</span>
{% endif %}
</span>
{% endif %}
- {% if request.user|can_delete_post(question.self_question) %}{{ pipe() }}
- <a id="question-delete-link-{{question.self_question_id}}" class="question-delete">{% if question.deleted %}{% trans %}undelete{% endtrans %}{% else %}{% trans %}delete{% endtrans %}{% endif %}</a>
+ {% if request.user|can_delete_post(question) %}{{ pipe() }}
+ <a id="question-delete-link-{{question.id}}" class="question-delete">{% if question.deleted %}{% trans %}undelete{% endtrans %}{% else %}{% trans %}delete{% endtrans %}{% endif %}</a>
{% endif %}
{# ==== END: include "question/question_controls.html" #}
</div>
{# ==== START: question/question_comments.html ==== #}
{{
macros.post_comments_widget(
- post = question.self_question,
- show_post = show_post.self_answer,
- show_comment = show_comment.self_comment,
+ post = question,
+ show_post = show_post,
+ show_comment = show_comment,
show_comment_position = show_comment_position,
user = request.user,
max_comments = settings.MAX_COMMENTS_TO_SHOW
@@ -152,14 +152,14 @@
<div class="clean"></div>
{% for answer in answers %}
{# ==== START: question/answer_card.html ==== #}
- <a name="{{ answer.self_answer_id }}"></a>
+ <a name="{{ answer.id }}"></a>
<div
- id="answer-container-{{ answer.self_answer_id }}"
- class="{{ macros.answer_classes(answer.self_answer, question.self_question) }}">
+ id="answer-container-{{ answer.id }}"
+ class="{{ macros.answer_classes(answer, question) }}">
<div class="vote-buttons">
{# ==== START: question/answer_vote_buttons.html ==== #}
- {{ macros.post_vote_buttons(post = answer.self_answer, visitor_vote = user_answer_votes[answer.self_answer_id]) }}
- <img id="answer-img-accept-{{ answer.self_answer_id }}" class="answer-img-accept"
+ {{ macros.post_vote_buttons(post = answer, visitor_vote = user_answer_votes[answer.id]) }}
+ <img id="answer-img-accept-{{ answer.id }}" class="answer-img-accept"
{% if answer.is_answer_accepted() %}
src="{{'/images/vote-accepted-on.png'|media}}"
{% else %}
@@ -180,9 +180,9 @@
<div class="item-right">
<div class="answer-body">
<div class="post-update-info-container">
- {{ post_last_updater_and_creator_info(answer.self_answer, settings.MIN_REP_TO_EDIT_WIKI) }}
+ {{ post_last_updater_and_creator_info(answer, settings.MIN_REP_TO_EDIT_WIKI) }}
{# ==== START: question/answer_author_info.html ====
- {{ macros.post_last_updater_and_creator_info(answer.self_answer, settings.MIN_REP_TO_EDIT_WIKI) }}
+ {{ macros.post_last_updater_and_creator_info(answer, settings.MIN_REP_TO_EDIT_WIKI) }}
==== END: question/answer_author_info.html ==== #}
</div>
{{ answer.html }}
@@ -197,37 +197,37 @@
{% trans %}permanent link{% endtrans %}
</a>
</span>
- {% if request.user|can_edit_post(answer.self_answer) %}{{ pipe() }}
- <span class="action-link"><a class="question-edit" href="{% url edit_answer answer.self_answer_id %}">{% trans %}edit{% endtrans %}</a></span>
+ {% if request.user|can_edit_post(answer) %}{{ pipe() }}
+ <span class="action-link"><a class="question-edit" href="{% url edit_answer answer.id %}">{% trans %}edit{% endtrans %}</a></span>
{% endif %}
- {% if request.user|can_flag_offensive(answer.self_answer) %}{{ pipe() }}
- <span id="answer-offensive-flag-{{ answer.self_answer_id }}" class="offensive-flag"
+ {% if request.user|can_flag_offensive(answer) %}{{ pipe() }}
+ <span id="answer-offensive-flag-{{ answer.id }}" class="offensive-flag"
title="{% trans %}report as offensive (i.e containing spam, advertising, malicious text, etc.){% endtrans %}">
<a class="question-flag">{% trans %}flag offensive{% endtrans %}</a>
- {% if request.user|can_see_offensive_flags(answer.self_answer) %}
+ {% if request.user|can_see_offensive_flags(answer) %}
<span class="darkred">{% if answer.offensive_flag_count > 0 %}({{ answer.offensive_flag_count }}){% endif %}</span>
{% endif %}
</span>
- {% elif request.user|can_remove_flag_offensive(answer.self_answer)%}{{ pipe() }}
- <span id="answer-offensive-flag-remove-{{ answer.self_answer_id }}" class="offensive-flag"
+ {% elif request.user|can_remove_flag_offensive(answer)%}{{ pipe() }}
+ <span id="answer-offensive-flag-remove-{{ answer.id }}" class="offensive-flag"
title="{% trans %}report as offensive (i.e containing spam, advertising, malicious text, etc.){% endtrans %}">
<a class="question-flag">{% trans %}remove flag{% endtrans %}</a>
- {% if request.user|can_see_offensive_flags(answer.self_answer) %}
+ {% if request.user|can_see_offensive_flags(answer) %}
<span class="darkred">{% if answer.offensive_flag_count > 0 %}({{ answer.offensive_flag_count }}){% endif %}</span>
{% endif %}
</span>
{% endif %}
- {% if request.user|can_delete_post(answer.self_answer) %}{{ pipe() }}
+ {% if request.user|can_delete_post(answer) %}{{ pipe() }}
{% spaceless %}
<span class="action-link">
- <a class="question-delete" id="answer-delete-link-{{answer.self_answer_id}}">
+ <a class="question-delete" id="answer-delete-link-{{answer.id}}">
{% if answer.deleted %}{% trans %}undelete{% endtrans %}{% else %}{% trans %}delete{% endtrans %}{% endif %}</a>
</span>
{% endspaceless %}
{% endif %}
{% if settings.ALLOW_SWAPPING_QUESTION_WITH_ANSWER and request.user.is_authenticated() and request.user.is_administrator_or_moderator() %}{{ pipe() }}
<span class="action-link">
- <a id="swap-question-with-answer-{{answer.self_answer.id}}">{% trans %}swap with question{% endtrans %}</a>
+ <a id="swap-question-with-answer-{{answer.id}}">{% trans %}swap with question{% endtrans %}</a>
</span>
{% endif %}
{# ==== END: question/answer_controls.html ==== #}
@@ -235,9 +235,9 @@
{# ==== START: question/answer_comments.html ==== #}
{{
macros.post_comments_widget(
- post = answer.self_answer,
- show_post = show_post.self_answer,
- show_comment = show_comment.self_comment,
+ post = answer,
+ show_post = show_post,
+ show_comment = show_comment,
show_comment_position = show_comment_position,
user = request.user,
max_comments = settings.MAX_COMMENTS_TO_SHOW
@@ -272,7 +272,7 @@
<form
id="fmanswer"
{% if user == question.author %}style="display:none"{% endif %}
- action="{% url answer question.self_question_id %}"
+ action="{% url answer question.id %}"
method="post"
>{% csrf_token %}
{# ==== START: question/subscribe_by_email_prompt.html ==== #}
@@ -305,7 +305,7 @@
{% if not thread.closed %}
<a
class="submit"
- href="{{settings.LOGIN_URL}}?next={% url question question.self_question_id %}"
+ href="{{settings.LOGIN_URL}}?next={% url question question.id %}"
>{% trans %}Login/Signup to Answer{% endtrans %}</a>
{% endif %}
{% else %}
diff --git a/askbot/skins/default/templates/question/javascript.html b/askbot/skins/default/templates/question/javascript.html
index 0e9162d4..a613afb9 100644
--- a/askbot/skins/default/templates/question/javascript.html
+++ b/askbot/skins/default/templates/question/javascript.html
@@ -46,7 +46,7 @@
var answer_sort_tab = "{{ tab_id }}";
$("#" + answer_sort_tab).attr('className',"on");
- Vote.init({{ question.self_question_id }}, '{{ thread.title|slugify }}', '{{ question.author.id }}','{{ request.user.id }}');
+ Vote.init({{ question.id }}, '{{ thread.title|slugify }}', '{{ question.author.id }}','{{ request.user.id }}');
{% if not thread.closed and request.user.is_authenticated %}initEditor();{% endif %}
diff --git a/askbot/skins/default/templates/question/sidebar.html b/askbot/skins/default/templates/question/sidebar.html
index 827a2b0d..b10c58f2 100644
--- a/askbot/skins/default/templates/question/sidebar.html
+++ b/askbot/skins/default/templates/question/sidebar.html
@@ -31,13 +31,13 @@
{%endif%}
<p class="rss">
<a
- href="{{settings.APP_URL}}/feeds/question/{{ question.self_question_id }}"
+ href="{{settings.APP_URL}}/feeds/question/{{ question.id }}"
title="{% trans %}subscribe to this question rss feed{% endtrans %}"
>{% trans %}subscribe to rss feed{% endtrans %}</a>
</p>
</div>
</div>
-{% cache 0 "questions_tags" questions_tags question.self_question_id language_code %}
+{% cache 0 "questions_tags" questions_tags question.id language_code %}
{% if settings.SIDEBAR_QUESTION_SHOW_META %}
diff --git a/askbot/skins/default/templates/question_edit.html b/askbot/skins/default/templates/question_edit.html
index bc064467..47873e0e 100644
--- a/askbot/skins/default/templates/question_edit.html
+++ b/askbot/skins/default/templates/question_edit.html
@@ -7,7 +7,7 @@
{% endblock %}
{% block content %}
<div class="section-title">{% trans %}Edit question{% endtrans %} [<a href="{{ question.get_absolute_url() }}">{% trans %}back{% endtrans %}</a>]</div>
-<form id="fmedit" action="{% url edit_question question.self_question_id %}" method="post" >{% csrf_token %}
+<form id="fmedit" action="{% url edit_question question.id %}" method="post" >{% csrf_token %}
{% if revision_form.revision.errors %}{{ revision_form.revision.errors.as_ul() }}{% endif %}
<div style="vertical-align:middle">
diff --git a/askbot/skins/default/templates/question_retag.html b/askbot/skins/default/templates/question_retag.html
index ffcfdb20..c8981f72 100644
--- a/askbot/skins/default/templates/question_retag.html
+++ b/askbot/skins/default/templates/question_retag.html
@@ -3,7 +3,7 @@
{% block title %}{% spaceless %}{% trans %}Change tags{% endtrans %}{% endspaceless %}{% endblock %}
{% block content %}
<h1>{% trans %}Change tags{% endtrans %} [<a href="{{ question.get_absolute_url() }}">{% trans %}back{% endtrans %}</a>]</h1>
-<form id="fmretag" action="{% url retag_question question.self_question_id %}" method="post" >{% csrf_token %}
+<form id="fmretag" action="{% url retag_question question.id %}" method="post" >{% csrf_token %}
<h2>
{{ question.thread.get_title() }}
</h2>
diff --git a/askbot/skins/default/templates/revisions.html b/askbot/skins/default/templates/revisions.html
index fa11bcf6..a4e429a4 100644
--- a/askbot/skins/default/templates/revisions.html
+++ b/askbot/skins/default/templates/revisions.html
@@ -35,10 +35,10 @@
{% endif %}
{% if request.user|can_edit_post(post) %}
{% if post.post_type == 'answer' %}
- <a href="{% url edit_answer post.self_answer_id %}?revision={{ revision.revision }}">{% trans %}edit{% endtrans %}</a>
+ <a href="{% url edit_answer post.id %}?revision={{ revision.revision }}">{% trans %}edit{% endtrans %}</a>
{% endif %}
{% if post.post_type == 'question' %}
- <a href="{% url edit_question post.self_question_id %}?revision={{ revision.revision }}">{% trans %}edit{% endtrans %}</a>
+ <a href="{% url edit_question post.id %}?revision={{ revision.revision }}">{% trans %}edit{% endtrans %}</a>
{% endif %}
{% endif %}
</td>
diff --git a/askbot/skins/default/templates/user_profile/user_stats.html b/askbot/skins/default/templates/user_profile/user_stats.html
index 95619560..c16d63af 100644
--- a/askbot/skins/default/templates/user_profile/user_stats.html
+++ b/askbot/skins/default/templates/user_profile/user_stats.html
@@ -19,7 +19,7 @@
{% for top_answer in top_answers %}
<div class="answer-summary">
<a title="{{ top_answer.summary|collapse }}"
- href="{% url question top_answer.question_id %}{{ top_answer.thread.title|slugify }}#{{ top_answer.self_answer_id }}">
+ href="{% url question top_answer.question_id %}{{ top_answer.thread.title|slugify }}#{{ top_answer.id }}">
<span class="answer-votes {% if top_answer.is_answer_accepted() %}answered-accepted{% endif %}"
title="{% trans answer_score=top_answer.score %}the answer has been voted for {{ answer_score }} times{% endtrans %} {% if top_answer.is_answer_accepted() %}{% trans %}this answer has been selected as correct{% endtrans %}{%endif%}">
{{ top_answer.score }}
@@ -27,7 +27,7 @@
</a>
<div class="answer-link">
{% spaceless %}
- <a href="{% url question top_answer.question_id %}{{ top_answer.thread.title|slugify }}#{{top_answer.self_answer_id}}">{{ top_answer.thread.title }}</a>
+ <a href="{% url question top_answer.question_id %}{{ top_answer.thread.title|slugify }}#{{top_answer.id}}">{{ top_answer.thread.title }}</a>
{% endspaceless %}
{% if top_answer.comment_count > 0 %}
<span>
diff --git a/askbot/skins/default/templates/widgets/question_summary.html b/askbot/skins/default/templates/widgets/question_summary.html
index d6bd764d..e9bb08b6 100644
--- a/askbot/skins/default/templates/widgets/question_summary.html
+++ b/askbot/skins/default/templates/widgets/question_summary.html
@@ -1,5 +1,5 @@
{% from "macros.html" import user_country_flag, tag_list_widget %}
-<div class="short-summary{% if extra_class %} {{extra_class}}{% endif %}" id="question-{{question.self_question_id}}">
+<div class="short-summary{% if extra_class %} {{extra_class}}{% endif %}" id="question-{{question.id}}">
<div class="counts">
<div class="views
{% if thread.view_count == 0 -%}
diff --git a/askbot/utils/mysql.py b/askbot/utils/mysql.py
index cf073010..cc13e70f 100644
--- a/askbot/utils/mysql.py
+++ b/askbot/utils/mysql.py
@@ -6,12 +6,12 @@ SUPPORTS_FTS = None
def supports_full_text_search():
"""True if the database engine is MyISAM"""
- from askbot.models import Question
+ from askbot.models import Post
global SUPPORTS_FTS
if SUPPORTS_FTS is None:
cursor = connection.cursor()
- table_name = Question._meta.db_table
- cursor.execute("SHOW CREATE TABLE %s" % table_name);
+ table_name = Post._meta.db_table
+ cursor.execute("SHOW CREATE TABLE %s" % table_name)
data = cursor.fetchone()
if 'ENGINE=MyISAM' in data[1]:
SUPPORTS_FTS = True
diff --git a/askbot/views/readers.py b/askbot/views/readers.py
index c7fea431..6379a002 100644
--- a/askbot/views/readers.py
+++ b/askbot/views/readers.py
@@ -47,7 +47,7 @@ from askbot.skins.loaders import render_into_skin, get_template#jinja2 template
# used in index page
#todo: - take these out of const or settings
-from askbot.models import Answer, Vote
+from askbot.models import Post, Vote
INDEX_PAGE_SIZE = 30
INDEX_AWARD_SIZE = 15
@@ -389,11 +389,11 @@ def question(request, id):#refactor - long subroutine. display question body, an
#in addition - if url points to a comment and the comment
#is for the answer - we need the answer object
try:
- show_comment = models.Post.objects.get(self_comment=show_comment)
- if str(show_comment.thread._question_post().self_question_id) != id:
+ show_comment = models.Post.objects.get(id=show_comment.id)
+ if str(show_comment.thread._question_post().id) != id:
return HttpResponseRedirect(show_comment.thread.get_absolute_url())
show_post = show_comment.parent
- show_comment.self_comment.assert_is_visible_to(request.user)
+ show_comment.assert_is_visible_to(request.user)
except models.Comment.DoesNotExist:
error_message = _(
'Sorry, the comment you are looking for has been '
@@ -415,7 +415,7 @@ def question(request, id):#refactor - long subroutine. display question body, an
#whether answer is actually corresponding to the current question
#and that the visitor is allowed to see it
try:
- show_post = get_object_or_404(models.Post, self_answer=show_answer)
+ show_post = get_object_or_404(models.Post, id=show_answer)
if str(show_post.question_id) != id:
return HttpResponseRedirect(show_post.get_absolute_url())
show_post.assert_is_visible_to(request.user)
@@ -425,8 +425,8 @@ def question(request, id):#refactor - long subroutine. display question body, an
#load question and maybe refuse showing deleted question
try:
- question_post = get_object_or_404(models.Post, self_question=id)
- question_post.self_question.assert_is_visible_to(request.user)
+ question_post = get_object_or_404(models.Post, id=id)
+ question_post.assert_is_visible_to(request.user)
except exceptions.QuestionHidden, error:
request.user.message_set.create(message = unicode(error))
return HttpResponseRedirect(reverse('index'))
@@ -446,7 +446,7 @@ def question(request, id):#refactor - long subroutine. display question body, an
#load answers
answers = thread.get_answers(user = request.user)
- answers = answers.select_related('self_answer', 'thread', 'author', 'last_edited_by')
+ answers = answers.select_related('thread', 'author', 'last_edited_by')
answers = answers.order_by({"latest":"-added_at", "oldest":"added_at", "votes":"-score" }[answer_sort_method])
# TODO: Instead of fetching answer posts, fetch all posts that belong to this thread,
@@ -460,15 +460,14 @@ def question(request, id):#refactor - long subroutine. display question body, an
answers = list(answers)
if thread.accepted_answer: # Put the accepted answer to front
- accepted_post = models.Post.objects.get(self_answer=thread.accepted_answer)
- answers.remove(accepted_post)
- answers.insert(0, accepted_post)
+ answers.remove(thread.accepted_answer)
+ answers.insert(0, thread.accepted_answer)
user_answer_votes = {}
if request.user.is_authenticated():
- votes = Vote.objects.filter(user=request.user, content_type=ContentType.objects.get_for_model(Answer), object_id__in=[answer.self_answer_id for answer in answers])
+ votes = Vote.objects.filter(user=request.user, voted_post__in=answers)
for vote in votes:
- user_answer_votes[vote.object_id] = int(vote) # INFO: vote.object_id == Answer.id == Post.self_answer_id
+ user_answer_votes[vote.post.id] = int(vote)
filtered_answers = [answer for answer in answers if ((not answer.deleted) or (answer.deleted and answer.author_id == request.user.id))]
@@ -476,7 +475,7 @@ def question(request, id):#refactor - long subroutine. display question body, an
show_comment_position = None
if show_comment:
show_page = show_comment.get_page_number(answer_posts=filtered_answers)
- show_comment_position = show_comment.self_comment.get_order_number()
+ show_comment_position = show_comment.get_order_number()
elif show_answer:
show_page = show_post.get_page_number(answer_posts=filtered_answers)
@@ -494,7 +493,7 @@ def question(request, id):#refactor - long subroutine. display question body, an
if 'question_view_times' not in request.session:
request.session['question_view_times'] = {}
- last_seen = request.session['question_view_times'].get(question_post.self_question_id, None)
+ last_seen = request.session['question_view_times'].get(question_post.id, None)
updated_when, updated_who = thread.get_last_update_info()
if updated_who != request.user:
@@ -504,7 +503,7 @@ def question(request, id):#refactor - long subroutine. display question body, an
else:
update_view_count = True
- request.session['question_view_times'][question_post.self_question_id] = \
+ request.session['question_view_times'][question_post.id] = \
datetime.datetime.now()
if update_view_count:
@@ -513,14 +512,14 @@ def question(request, id):#refactor - long subroutine. display question body, an
#2) question view count per user and clear response displays
if request.user.is_authenticated():
#get response notifications
- request.user.visit_question(question_post.self_question)
+ request.user.visit_question(question_post)
#3) send award badges signal for any badges
#that are awarded for question views
award_badges_signal.send(None,
event = 'view_question',
actor = request.user,
- context_object = question_post.self_question,
+ context_object = question_post,
)
paginator_data = {
@@ -539,7 +538,7 @@ def question(request, id):#refactor - long subroutine. display question body, an
favorited = thread.has_favorite_by_user(request.user)
user_question_vote = 0
if request.user.is_authenticated():
- votes = question_post.self_question.votes.select_related().filter(user=request.user)
+ votes = question_post.votes.select_related().filter(user=request.user)
try:
user_question_vote = int(votes[0])
except IndexError:
@@ -551,8 +550,8 @@ def question(request, id):#refactor - long subroutine. display question body, an
'question' : question_post,
'thread': thread,
'user_question_vote' : user_question_vote,
- 'question_comment_count': question_post.self_question.comments.count(),
- 'answer' : AnswerForm(question_post.self_question, request.user),
+ 'question_comment_count': question_post.comments.count(),
+ 'answer' : AnswerForm(question_post, request.user),
'answers' : page_objects.object_list,
'user_answer_votes': user_answer_votes,
'tags' : thread.tags.all(),
@@ -570,11 +569,11 @@ def question(request, id):#refactor - long subroutine. display question body, an
def revisions(request, id, object_name=None):
if object_name == 'Question':
- post = get_object_or_404(models.Post, post_type='question', self_question=id)
- revisions = list(models.PostRevision.objects.filter(question=post.self_question))
+ post = get_object_or_404(models.Post, post_type='question', id=id)
+ revisions = list(models.PostRevision.objects.filter(question=post))
else:
- post = get_object_or_404(models.Post, post_type='answer', self_answer=id)
- revisions = list(models.PostRevision.objects.filter(answer=post.self_answer))
+ post = get_object_or_404(models.Post, post_type='answer', id=id)
+ revisions = list(models.PostRevision.objects.filter(answer=post))
revisions.reverse()
for i, revision in enumerate(revisions):
revision.html = revision.as_html()
@@ -601,7 +600,7 @@ def get_comment(request):
and request must be ajax
"""
id = int(request.GET['id'])
- comment = models.Post.objects.get(post_type='comment', self_comment=id)
+ comment = models.Post.objects.get(post_type='comment', id=id)
request.user.assert_can_edit_comment(comment)
return {'text': comment.text}
@@ -617,7 +616,7 @@ def get_question_body(request):
page = paginator.page(search_state.page)
questions_dict = {}
for question in page.object_list:
- questions_dict['question-%s' % question.self_question_id] = question.summary
+ questions_dict['question-%s' % question.id] = question.summary
return {'questions-titles': questions_dict}
diff --git a/askbot/views/users.py b/askbot/views/users.py
index 64a0d829..9850800c 100644
--- a/askbot/views/users.py
+++ b/askbot/views/users.py
@@ -287,10 +287,12 @@ def user_stats(request, user, context):
#
# Top answers
#
- top_answers = user.posts.get_answers().filter(
- deleted=False,
- self_answer__question__deleted=False,
- ).select_related('thread', 'self_answer').order_by('-score', '-id')[:100]
+# TODO: Rewrite this without using `self_answer`
+# top_answers = user.posts.get_answers().filter(
+# deleted=False,
+# self_answer__question__deleted=False,
+# ).select_related('thread', 'self_answer').order_by('-score', '-id')[:100]
+ top_answers = []
top_answer_count = len(top_answers)
@@ -330,15 +332,15 @@ def user_stats(request, user, context):
awarded_answer_ids.append(award.object_id)
awarded_posts = models.Post.objects.filter(
- Q(self_answer__in=awarded_answer_ids)|Q(self_question__in=awarded_question_ids)
- ).select_related('self_answer', 'thread') # select related to avoid additional queries in Post.get_absolute_url()
+ Q(post_type='answer', id__in=awarded_answer_ids)|Q(post_type='question', id__in=awarded_question_ids)
+ ).select_related('thread') # select related to avoid additional queries in Post.get_absolute_url()
awarded_questions_map = {}
awarded_answers_map = {}
for post in awarded_posts:
- if post.self_question_id:
- awarded_questions_map[post.self_question_id] = post
- elif post.self_answer_id:
- awarded_answers_map[post.self_answer_id] = post
+ if post.post_type == 'question':
+ awarded_questions_map[post.id] = post
+ elif post.post_type == 'answer':
+ awarded_answers_map[post.id] = post
badges_dict = collections.defaultdict(list)
diff --git a/askbot/views/writers.py b/askbot/views/writers.py
index dab32d2a..883f1a39 100644
--- a/askbot/views/writers.py
+++ b/askbot/views/writers.py
@@ -292,7 +292,7 @@ def ask(request):#view used to ask a new question
def retag_question(request, id):
"""retag question view
"""
- question = get_object_or_404(models.Post, self_question=id)
+ question = get_object_or_404(models.Post, id=id)
try:
request.user.assert_can_retag_question(question)
@@ -344,7 +344,7 @@ def retag_question(request, id):
def edit_question(request, id):
"""edit question view
"""
- question = get_object_or_404(models.Post, self_question=id)
+ question = get_object_or_404(models.Post, id=id)
latest_revision = question.get_latest_revision()
revision_form = None
try:
@@ -431,7 +431,7 @@ def edit_question(request, id):
@csrf.csrf_protect
@decorators.check_spam('text')
def edit_answer(request, id):
- answer = get_object_or_404(models.Post, self_answer=id)
+ answer = get_object_or_404(models.Post, id=id)
latest_revision = answer.get_latest_revision()
try:
request.user.assert_can_edit_answer(answer)
@@ -498,7 +498,7 @@ def answer(request, id):#process a new answer
authenticated users post directly
"""
- question = get_object_or_404(models.Post, post_type='question', self_question=id)
+ question = get_object_or_404(models.Post, post_type='question', id=id)
if request.method == "POST":
form = forms.AnswerForm(question, request.user, request.POST)
if form.is_valid():
@@ -586,9 +586,9 @@ def post_comments(request):#generic ajax handler to load comments to an object
id = request.REQUEST['post_id']
if post_type == 'question':
- obj = get_object_or_404(models.Post, self_question=id)
+ obj = get_object_or_404(models.Post, id=id)
else: #if post_type == 'answer':
- obj = get_object_or_404(models.Post, self_answer=id)
+ obj = get_object_or_404(models.Post, id=id)
if request.method == "GET":
response = __generate_comments_json(obj, user)
@@ -614,15 +614,16 @@ def edit_comment(request):
raise exceptions.PermissionDenied(_('Sorry, anonymous users cannot edit comments'))
comment_id = int(request.POST['comment_id'])
- comment_post = models.Post.objects.get(self_comment=comment_id)
+ comment_post = models.Post.objects.get(id=comment_id)
request.user.edit_comment(comment_post=comment_post, body_text = request.POST['comment'])
is_deletable = template_filters.can_delete_comment(comment_post.author, comment_post)
is_editable = template_filters.can_edit_comment(comment_post.author, comment_post)
- return {'id' : comment_post.self_comment.id,
- 'object_id': comment_post.self_comment.content_object.id,
+ return {
+ 'id' : comment_post.id,
+ 'object_id': comment_post.parent.id,
'comment_age': diff_date(comment_post.added_at),
'html': comment_post.html,
'user_display_name': comment_post.author.username,
@@ -631,7 +632,7 @@ def edit_comment(request):
'is_deletable': is_deletable,
'is_editable': is_editable,
'score': comment_post.score,
- 'voted': comment_post.self_comment.is_upvoted_by(request.user),
+ 'voted': comment_post.is_upvoted_by(request.user),
}
def delete_comment(request):