From 857bb4a7d27635184c9f69118547107b1860ebcf Mon Sep 17 00:00:00 2001 From: Tomasz Zielinski Date: Fri, 30 Dec 2011 00:38:13 +0100 Subject: BigMigration: Question, Answer, Comment models REMOVED; Initial adjustements of the codebase to make `questions()` and `question()` views roughly work --- askbot/admin.py | 16 +- askbot/auth.py | 2 +- askbot/feed.py | 2 +- ...question__del_field_post_self_answer__del_fi.py | 347 +++++++++++++++ askbot/migrations/0101_megadeath_of_q_a_c.py | 352 +++++++++++++++ .../migrations/0102_rename_post_fields_back_1.py | 267 +++++++++++ .../migrations/0103_rename_post_fields_back_2.py | 267 +++++++++++ askbot/models/__init__.py | 99 ++--- askbot/models/answer.py | 12 +- askbot/models/badges.py | 1 - askbot/models/content.py | 30 +- askbot/models/meta.py | 488 ++++++++++----------- askbot/models/post.py | 72 +-- askbot/models/question.py | 62 +-- askbot/models/user.py | 2 +- askbot/sitemap.py | 2 +- askbot/skins/default/templates/answer_edit.html | 2 +- askbot/skins/default/templates/macros.html | 2 +- askbot/skins/default/templates/question.html | 92 ++-- .../default/templates/question/javascript.html | 2 +- .../skins/default/templates/question/sidebar.html | 4 +- askbot/skins/default/templates/question_edit.html | 2 +- askbot/skins/default/templates/question_retag.html | 2 +- askbot/skins/default/templates/revisions.html | 4 +- .../default/templates/user_profile/user_stats.html | 4 +- .../templates/widgets/question_summary.html | 2 +- askbot/utils/mysql.py | 6 +- askbot/views/readers.py | 53 ++- askbot/views/users.py | 22 +- askbot/views/writers.py | 21 +- 30 files changed, 1698 insertions(+), 541 deletions(-) create mode 100644 askbot/migrations/0100_auto__del_field_post_self_question__del_field_post_self_answer__del_fi.py create mode 100644 askbot/migrations/0101_megadeath_of_q_a_c.py create mode 100644 askbot/migrations/0102_rename_post_fields_back_1.py create mode 100644 askbot/migrations/0103_rename_post_fields_back_2.py 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 %} [{% trans %}back{% endtrans %}]
-
{% csrf_token %} + {% csrf_token %}
{% if revision_form.revision.errors %}{{ revision_form.revision.errors.as_ul() }}{% endif %}
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 #}
{{comment.html}} - {{comment.user.username}} + {{comment.author.username}}  ({{comment.added_at|diff_date}}) {% if user|can_edit_comment(comment) %}  {% trans %}edit{% endtrans %} 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 ==== #}
{# ==== 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" #}
{{ question.html }} @@ -55,52 +55,52 @@
{# ==== START: include "question/question_controls.html" #} {% set pipe=joiner('|') %} - {% if request.user|can_edit_post(question.self_question) %}{{ pipe() }} - {% trans %}edit{% endtrans %} + {% if request.user|can_edit_post(question) %}{{ pipe() }} + {% trans %}edit{% endtrans %} {% endif %} - {% if request.user|can_retag_question(question.self_question) %}{{ pipe() }} - {% trans %}retag{% endtrans %} + {% if request.user|can_retag_question(question) %}{{ pipe() }} + {% trans %}retag{% endtrans %} {% endif %} {% if thread.closed %} - {% if request.user|can_reopen_question(question.self_question) %}{{ pipe() }} - {% trans %}reopen{% endtrans %} + {% if request.user|can_reopen_question(question) %}{{ pipe() }} + {% trans %}reopen{% endtrans %} {% endif %} {% else %} - {% if request.user|can_close_question(question.self_question) %}{{ pipe() }} - {% trans %}close{% endtrans %} + {% if request.user|can_close_question(question) %}{{ pipe() }} + {% trans %}close{% endtrans %} {% endif %} {% endif %} - {% if request.user|can_flag_offensive(question.self_question) %}{{ pipe() }} - {% trans %}flag offensive{% endtrans %} - {% if request.user|can_see_offensive_flags(question.self_question) %} + {% if request.user|can_see_offensive_flags(question) %} {% if question.offensive_flag_count > 0 %}({{ question.offensive_flag_count }}){% endif %} {% endif %} - {% elif request.user|can_remove_flag_offensive(question.self_question)%}{{ pipe() }} - {% trans %}remove flag{% endtrans %} - {% if request.user|can_see_offensive_flags(question.self_question) %} + {% if request.user|can_see_offensive_flags(question) %} {% if question.offensive_flag_count > 0 %}({{ question.offensive_flag_count }}){% endif %} {% endif %} {% endif %} - {% if request.user|can_delete_post(question.self_question) %}{{ pipe() }} - {% if question.deleted %}{% trans %}undelete{% endtrans %}{% else %}{% trans %}delete{% endtrans %}{% endif %} + {% if request.user|can_delete_post(question) %}{{ pipe() }} + {% if question.deleted %}{% trans %}undelete{% endtrans %}{% else %}{% trans %}delete{% endtrans %}{% endif %} {% endif %} {# ==== END: include "question/question_controls.html" #}
{# ==== 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 @@
{% for answer in answers %} {# ==== START: question/answer_card.html ==== #} - +
+ id="answer-container-{{ answer.id }}" + class="{{ macros.answer_classes(answer, question) }}">
{# ==== START: question/answer_vote_buttons.html ==== #} - {{ macros.post_vote_buttons(post = answer.self_answer, visitor_vote = user_answer_votes[answer.self_answer_id]) }} -
- {{ 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 ==== #}
{{ answer.html }} @@ -197,37 +197,37 @@ {% trans %}permanent link{% endtrans %} - {% if request.user|can_edit_post(answer.self_answer) %}{{ pipe() }} - {% trans %}edit{% endtrans %} + {% if request.user|can_edit_post(answer) %}{{ pipe() }} + {% trans %}edit{% endtrans %} {% endif %} - {% if request.user|can_flag_offensive(answer.self_answer) %}{{ pipe() }} - {% trans %}flag offensive{% endtrans %} - {% if request.user|can_see_offensive_flags(answer.self_answer) %} + {% if request.user|can_see_offensive_flags(answer) %} {% if answer.offensive_flag_count > 0 %}({{ answer.offensive_flag_count }}){% endif %} {% endif %} - {% elif request.user|can_remove_flag_offensive(answer.self_answer)%}{{ pipe() }} - {% trans %}remove flag{% endtrans %} - {% if request.user|can_see_offensive_flags(answer.self_answer) %} + {% if request.user|can_see_offensive_flags(answer) %} {% if answer.offensive_flag_count > 0 %}({{ answer.offensive_flag_count }}){% endif %} {% endif %} {% endif %} - {% if request.user|can_delete_post(answer.self_answer) %}{{ pipe() }} + {% if request.user|can_delete_post(answer) %}{{ pipe() }} {% spaceless %} - + {% if answer.deleted %}{% trans %}undelete{% endtrans %}{% else %}{% trans %}delete{% endtrans %}{% endif %} {% endspaceless %} {% endif %} {% if settings.ALLOW_SWAPPING_QUESTION_WITH_ANSWER and request.user.is_authenticated() and request.user.is_administrator_or_moderator() %}{{ pipe() }} - {% trans %}swap with question{% endtrans %} + {% trans %}swap with question{% endtrans %} {% 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 @@ {% csrf_token %} {# ==== START: question/subscribe_by_email_prompt.html ==== #} @@ -305,7 +305,7 @@ {% if not thread.closed %} {% trans %}Login/Signup to Answer{% endtrans %} {% 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%}

{% trans %}subscribe to rss feed{% endtrans %}

-{% 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 %}
{% trans %}Edit question{% endtrans %} [{% trans %}back{% endtrans %}]
-{% csrf_token %} +{% csrf_token %} {% if revision_form.revision.errors %}{{ revision_form.revision.errors.as_ul() }}{% endif %}
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 %}

{% trans %}Change tags{% endtrans %} [{% trans %}back{% endtrans %}]

-{% csrf_token %} +{% csrf_token %}

{{ question.thread.get_title() }}

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' %} - {% trans %}edit{% endtrans %} + {% trans %}edit{% endtrans %} {% endif %} {% if post.post_type == 'question' %} - {% trans %}edit{% endtrans %} + {% trans %}edit{% endtrans %} {% endif %} {% endif %} 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 %}
+ href="{% url question top_answer.question_id %}{{ top_answer.thread.title|slugify }}#{{ top_answer.id }}"> {{ top_answer.score }} @@ -27,7 +27,7 @@