diff options
author | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-03-05 08:42:33 -0600 |
---|---|---|
committer | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-03-05 08:42:33 -0600 |
commit | fafc737789dd33265dfbe7ff7d1a0c4261269133 (patch) | |
tree | 207125553b5a0837546fc4f411314fc6751f7ed7 | |
parent | 4aa28d9ff14dbe1da47d7eedc94d99a675ba4bbf (diff) | |
parent | 176553fb823b0748ad513a88a444376fd58d7cb6 (diff) | |
download | askbot-fafc737789dd33265dfbe7ff7d1a0c4261269133.tar.gz askbot-fafc737789dd33265dfbe7ff7d1a0c4261269133.tar.bz2 askbot-fafc737789dd33265dfbe7ff7d1a0c4261269133.zip |
Merge branch 'master' of github.com:ASKBOT/askbot-devel
35 files changed, 1707 insertions, 308 deletions
diff --git a/askbot/conf/email.py b/askbot/conf/email.py index 3db80e7a..1f60c442 100644 --- a/askbot/conf/email.py +++ b/askbot/conf/email.py @@ -31,6 +31,15 @@ settings.register( ) settings.register( + livesettings.BooleanValue( + EMAIL, + 'ENABLE_EMAIL_ALERTS', + default = True, + description = _('Enable email alerts'), + ) +) + +settings.register( livesettings.IntegerValue( EMAIL, 'MAX_ALERTS_PER_EMAIL', diff --git a/askbot/const/__init__.py b/askbot/const/__init__.py index 6fef38d7..66e20dae 100644 --- a/askbot/const/__init__.py +++ b/askbot/const/__init__.py @@ -18,6 +18,8 @@ CLOSE_REASONS = ( (9, _('too localized')), ) +LONG_TIME = 60*60*24*30 #30 days is a lot of time + TYPE_REPUTATION = ( (1, 'gain_by_upvoted'), (2, 'gain_by_answer_accepted'), @@ -48,6 +50,10 @@ POST_SORT_METHODS = ( ('votes-asc', _('least voted')), ('relevance-desc', _('relevance')), ) + +ANSWER_SORT_METHODS = (#no translations needed here + 'latest', 'oldest', 'votes' +) #todo: add assertion here that all sort methods are unique #because they are keys to the hash used in implementations #of Q.run_advanced_search diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index 54baa18f..b6880d37 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -18,6 +18,7 @@ Development version (not released yet) * Added a management delete_contextless_badge_award_activities (Evgeny) * Fixed a file upload issue in FF and IE found by jerry_gzy (Evgeny) * Added test on maximum length of title working for utf-8 text (Evgeny) +* Added caching and invalidation to the question page (Evgeny) 0.7.39 (Jan 11, 2012) --------------------- diff --git a/askbot/doc/source/index.rst b/askbot/doc/source/index.rst index 27f106be..81f21fcc 100644 --- a/askbot/doc/source/index.rst +++ b/askbot/doc/source/index.rst @@ -20,6 +20,7 @@ at the forum_ or by email at admin@askbot.org Initialize the database tables <initialize-database-tables> Deploy on a webserver <deployment> Import data (StackExchange & ZenDesk) <import-data> + Moderation <moderation> Appendix A: Maintenance procedures <management-commands> Appendix B: Sending email to askbot <sending-email-to-askbot> Appendix C: Optional modules <optional-modules> diff --git a/askbot/doc/source/moderation.rst b/askbot/doc/source/moderation.rst new file mode 100644 index 00000000..9ccaa5b0 --- /dev/null +++ b/askbot/doc/source/moderation.rst @@ -0,0 +1,30 @@ +==================== +Moderation in Askbot +==================== + +Regular users and forum Moderators can participate +in the content moderation. Any user with sufficient reputation +(this reputation threshold can be changed in the settings panel) +can flag offensive posts. + +When a post receives a certain number of flags (adjustable), +the post is automatically hidden. + +In addition users can delete posts, given a minimum reputation +threshold (also adjustable) is met. +Moderators can delete any post at any time. + +.. note:: + All the minimum reputation thresholds can be adjusted + at the "settings" panel. Only site administrators have + access to the settings editor. + +Forum moderators can suspend and block users, by going to +the "moderation" section in the user profile page. +From the same page moderators can send an email to the user. + +Suspended users can only edit own posts, but cannot make new posts. +Blocked users can only sign in and send feedback to +the side administrators. + +Only site administrators can assign moderator status to any user. diff --git a/askbot/forms.py b/askbot/forms.py index 2aa37e75..4b72180c 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -685,17 +685,10 @@ class AnswerForm(forms.Form): openid = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 40, 'class':'openid-input'})) user = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) email = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) - email_notify = EmailNotifyField() - def __init__(self, question, user, *args, **kwargs): + email_notify = EmailNotifyField(initial = False) + def __init__(self, *args, **kwargs): super(AnswerForm, self).__init__(*args, **kwargs) self.fields['email_notify'].widget.attrs['id'] = 'question-subscribe-updates' - if question.wiki and askbot_settings.WIKI_ON: - self.fields['wiki'].initial = True - if user.is_authenticated(): - if user in question.thread.followed_by.all(): - self.fields['email_notify'].initial = True - return - self.fields['email_notify'].initial = False class VoteForm(forms.Form): """form used in ajax vote view (only comment_upvote so far) diff --git a/askbot/management/commands/send_accept_answer_reminders.py b/askbot/management/commands/send_accept_answer_reminders.py index 54fdbed4..47358a99 100644 --- a/askbot/management/commands/send_accept_answer_reminders.py +++ b/askbot/management/commands/send_accept_answer_reminders.py @@ -13,6 +13,8 @@ DEBUG_THIS_COMMAND = False class Command(NoArgsCommand): def handle_noargs(self, **options): + if askbot_settings.ENABLE_EMAIL_ALERTS == False: + return if askbot_settings.ENABLE_ACCEPT_ANSWER_REMINDERS == False: return #get questions without answers, excluding closed and deleted diff --git a/askbot/management/commands/send_email_alerts.py b/askbot/management/commands/send_email_alerts.py index c1959885..8cb71859 100644 --- a/askbot/management/commands/send_email_alerts.py +++ b/askbot/management/commands/send_email_alerts.py @@ -75,13 +75,14 @@ def format_action_count(string, number, output): class Command(NoArgsCommand): def handle_noargs(self, **options): - try: + if askbot_settings.ENABLE_EMAIL_ALERTS: try: - self.send_email_alerts() - except Exception, e: - print e - finally: - connection.close() + try: + self.send_email_alerts() + except Exception, e: + print e + finally: + connection.close() def get_updated_questions_for_user(self,user): """ diff --git a/askbot/management/commands/send_unanswered_question_reminders.py b/askbot/management/commands/send_unanswered_question_reminders.py index ba21f7de..424e45cc 100644 --- a/askbot/management/commands/send_unanswered_question_reminders.py +++ b/askbot/management/commands/send_unanswered_question_reminders.py @@ -14,6 +14,8 @@ class Command(NoArgsCommand): about unanswered questions to all users """ def handle_noargs(self, **options): + if askbot_settings.ENABLE_EMAIL_ALERTS == False: + return if askbot_settings.ENABLE_UNANSWERED_REMINDERS == False: return #get questions without answers, excluding closed and deleted diff --git a/askbot/migrations/0108_auto__add_field_thread_score.py b/askbot/migrations/0108_auto__add_field_thread_score.py new file mode 100644 index 00000000..ce5a4ff1 --- /dev/null +++ b/askbot/migrations/0108_auto__add_field_thread_score.py @@ -0,0 +1,274 @@ +# -*- coding: 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): + # Adding field 'Thread.score' + db.add_column('askbot_thread', 'score', + self.gf('django.db.models.fields.IntegerField')(default=0), + keep_default=False) + + def backwards(self, orm): + # Deleting field 'Thread.score' + db.delete_column('askbot_thread', 'score') + + 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': ('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'}) + }, + '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', 'db_index': 'True'}), + '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'}), + 'old_answer_id': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'old_comment_id': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'old_question_id': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'comments'", 'null': 'True', 'to': "orm['askbot.Post']"}), + 'post_type': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + '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': ('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']"}), + 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + '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': "'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']
\ No newline at end of file diff --git a/askbot/migrations/0109_denormalize_question_vote_to_thread.py b/askbot/migrations/0109_denormalize_question_vote_to_thread.py new file mode 100644 index 00000000..7feb6b54 --- /dev/null +++ b/askbot/migrations/0109_denormalize_question_vote_to_thread.py @@ -0,0 +1,279 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models +from askbot.utils.console import ProgressBar + +class Migration(DataMigration): + + def forwards(self, orm): + "copy question score to threads" + message = 'Copying question votes to Thread objects' + questions = orm.Post.objects.filter(post_type = 'question') + count = questions.count() + for question in ProgressBar(questions.iterator(), count, message): + question.thread.score = question.score + question.thread.save() + + + def backwards(self, orm): + "nothing to do here" + + + 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': ('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'}) + }, + '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', 'db_index': 'True'}), + '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'}), + 'old_answer_id': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'old_comment_id': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'old_question_id': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'comments'", 'null': 'True', 'to': "orm['askbot.Post']"}), + 'post_type': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + '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': ('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']"}), + 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + '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': "'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'] + symmetrical = True diff --git a/askbot/migrations/0110_auto__add_field_thread_added_at.py b/askbot/migrations/0110_auto__add_field_thread_added_at.py new file mode 100644 index 00000000..fbb95e3a --- /dev/null +++ b/askbot/migrations/0110_auto__add_field_thread_added_at.py @@ -0,0 +1,275 @@ +# -*- coding: 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): + # Adding field 'Thread.added_at' + db.add_column('askbot_thread', 'added_at', + self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now), + keep_default=False) + + def backwards(self, orm): + # Deleting field 'Thread.added_at' + db.delete_column('askbot_thread', 'added_at') + + 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': ('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'}) + }, + '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', 'db_index': 'True'}), + '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'}), + 'old_answer_id': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'old_comment_id': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'old_question_id': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'comments'", 'null': 'True', 'to': "orm['askbot.Post']"}), + 'post_type': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + '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': ('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']"}), + 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + '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']"}), + 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + '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': "'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']
\ No newline at end of file diff --git a/askbot/migrations/0111_populate__thread__added_at.py b/askbot/migrations/0111_populate__thread__added_at.py new file mode 100644 index 00000000..f733baf5 --- /dev/null +++ b/askbot/migrations/0111_populate__thread__added_at.py @@ -0,0 +1,279 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models +from askbot.utils.console import ProgressBar + +class Migration(DataMigration): + + def forwards(self, orm): + "copy added_at field to Thread from the question posts" + message = 'Setting added_at on Threads based on the questions' + questions = orm.Post.objects.filter(post_type = 'question') + count = questions.count() + for question in ProgressBar(questions.iterator(), count, message): + question.thread.added_at = question.added_at + question.thread.save() + + def backwards(self, orm): + "nothing to do here" + + + 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': ('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'}) + }, + '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', 'db_index': 'True'}), + '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'}), + 'old_answer_id': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'old_comment_id': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'old_question_id': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'comments'", 'null': 'True', 'to': "orm['askbot.Post']"}), + 'post_type': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + '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': ('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']"}), + 'added_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + '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']"}), + 'score': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + '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': "'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'] + symmetrical = True diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index a3644844..d7f2770f 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -15,6 +15,7 @@ from django.utils.safestring import mark_safe from django.db import models from django.conf import settings as django_settings from django.contrib.contenttypes.models import ContentType +from django.core import cache from django.core import exceptions as django_exceptions from django_countries.fields import CountryField from askbot import exceptions as askbot_exceptions @@ -499,7 +500,7 @@ def user_can_post_comment(self, parent_post = None): """ if self.reputation >= askbot_settings.MIN_REP_TO_LEAVE_COMMENTS: return True - if self == parent_post.author: + if parent_post and self == parent_post.author: return True if self.is_administrator_or_moderator(): return True @@ -990,6 +991,7 @@ def user_post_comment( comment = body_text, added_at = timestamp, ) + parent_post.thread.invalidate_cached_data() award_badges_signal.send(None, event = 'post_comment', actor = self, @@ -1159,6 +1161,7 @@ def user_delete_comment( ): self.assert_can_delete_comment(comment = comment) comment.delete() + comment.thread.invalidate_cached_data() @auto_now_timestamp def user_delete_answer( @@ -1259,6 +1262,7 @@ def user_delete_post( self.delete_question(question = post, timestamp = timestamp) else: raise TypeError('either Comment, Question or Answer expected') + post.thread.invalidate_cached_data() def user_restore_post( self, @@ -1272,6 +1276,7 @@ def user_restore_post( post.deleted_by = None post.deleted_at = None post.save() + post.thread.invalidate_cached_data() if post.post_type == 'answer': post.thread.update_answer_count() else: @@ -1330,10 +1335,13 @@ def user_post_question( def user_edit_comment(self, comment_post=None, body_text = None): """apply edit to a comment, the method does not change the comments timestamp and no signals are sent + todo: see how this can be merged with edit_post + todo: add timestamp """ self.assert_can_edit_comment(comment_post) comment_post.text = body_text comment_post.parse_and_save(author = self) + comment_post.thread.invalidate_cached_data() @auto_now_timestamp @@ -1362,6 +1370,7 @@ def user_edit_question( wiki = wiki, edit_anonymously = edit_anonymously, ) + question.thread.invalidate_cached_data() award_badges_signal.send(None, event = 'edit_question', actor = self, @@ -1388,6 +1397,7 @@ def user_edit_answer( comment = revision_comment, wiki = wiki, ) + answer.thread.invalidate_cached_data() award_badges_signal.send(None, event = 'edit_answer', actor = self, @@ -1484,12 +1494,17 @@ def user_visit_question(self, question = None, timestamp = None): timestamp = datetime.datetime.now() try: - question_view = QuestionView.objects.get(who=self, question=question) + QuestionView.objects.filter( + who=self, question=question + ).update( + when = timestamp + ) except QuestionView.DoesNotExist: - question_view = QuestionView(who=self, question=question) - - question_view.when = timestamp - question_view.save() + QuestionView( + who=self, + question=question, + when = timestamp + ).save() #filter memo objects on response activities directed to the qurrent user #that refer to the children of the currently @@ -1951,15 +1966,24 @@ def _process_vote(user, post, timestamp=None, cancel=False, vote_type=None): if vote_type == Vote.VOTE_UP: if cancel: auth.onUpVotedCanceled(vote, post, user, timestamp) - return None else: auth.onUpVoted(vote, post, user, timestamp) elif vote_type == Vote.VOTE_DOWN: if cancel: auth.onDownVotedCanceled(vote, post, user, timestamp) - return None else: auth.onDownVoted(vote, post, user, timestamp) + + if post.post_type == 'question': + #denormalize the question post score on the thread + post.thread.score = post.score + post.thread.save() + post.thread.update_summary_html() + + post.thread.invalidate_cached_data() + + if cancel: + return None event = VOTES_TO_EVENTS.get((vote_type, post.post_type), None) if event: @@ -2510,7 +2534,8 @@ def record_user_visit(user, timestamp, **kwargs): context_object = user, timestamp = timestamp ) - user.save() + #somehow it saves on the query as compared to user.save() + User.objects.filter(id = user.id).update(last_seen = timestamp) def record_vote(instance, created, **kwargs): @@ -2695,9 +2720,21 @@ def update_user_avatar_type_flag(instance, **kwargs): def make_admin_if_first_user(instance, **kwargs): + """first user automatically becomes an administrator + the function is run only once in the interpreter session + """ + import sys + #have to check sys.argv to satisfy the test runner + #which fails with the cache-based skipping + #for real the setUp() code in the base test case must + #clear the cache!!! + if 'test' not in sys.argv and cache.cache.get('admin-created'): + #no need to hit the database every time! + return user_count = User.objects.all().count() if user_count == 0: instance.set_admin_status() + cache.cache.set('admin-created', True) #signal for User model save changes django_signals.pre_save.connect(make_admin_if_first_user, sender=User) diff --git a/askbot/models/post.py b/askbot/models/post.py index dead32bc..d9cd9a5e 100644 --- a/askbot/models/post.py +++ b/askbot/models/post.py @@ -210,7 +210,7 @@ class PostManager(BaseQuerySetManager): for cm in comments: post_map[cm.parent_id].append(cm) for post in for_posts: - post._cached_comments = post_map[post.id] + post.set_cached_comments(post_map[post.id]) # Old Post.get_comment(self, visitor=None) method: # if visitor.is_anonymous(): @@ -540,6 +540,19 @@ class Post(models.Model): """ return html_utils.strip_tags(self.html)[:120] + ' ...' + def set_cached_comments(self, comments): + """caches comments in the lifetime of the object + does not talk to the actual cache system + """ + self._cached_comments = comments + + def get_cached_comments(self): + try: + return self._cached_comments + except AttributeError: + self._cached_comments = list() + return self._cached_comments + def add_comment(self, comment=None, user=None, added_at=None): if added_at is None: added_at = datetime.datetime.now() diff --git a/askbot/models/question.py b/askbot/models/question.py index 2bb4d6a0..f0e6e03e 100644 --- a/askbot/models/question.py +++ b/askbot/models/question.py @@ -5,9 +5,10 @@ import re from django.conf import settings from django.db import models from django.contrib.auth.models import User -from django.utils.translation import ugettext as _ from django.core import cache # import cache, not from cache import cache, to be able to monkey-patch cache.cache in test cases from django.core.urlresolvers import reverse +from django.utils.hashcompat import md5_constructor +from django.utils.translation import ugettext as _ import askbot import askbot.conf @@ -225,14 +226,14 @@ class ThreadManager(models.Manager): meta_data['ignored_tag_names'].extend(request_user.ignored_tags.split()) QUESTION_ORDER_BY_MAP = { - 'age-desc': '-askbot_post.added_at', - 'age-asc': 'askbot_post.added_at', + 'age-desc': '-added_at', + 'age-asc': 'added_at', 'activity-desc': '-last_activity_at', 'activity-asc': 'last_activity_at', 'answers-desc': '-answer_count', 'answers-asc': 'answer_count', - 'votes-desc': '-askbot_post.score', - 'votes-asc': 'askbot_post.score', + 'votes-desc': '-score', + 'votes-asc': 'score', 'relevance-desc': '-relevance', # special Postgresql-specific ordering, 'relevance' quaso-column is added by get_for_query() } @@ -296,6 +297,7 @@ class ThreadManager(models.Manager): class Thread(models.Model): SUMMARY_CACHE_KEY_TPL = 'thread-question-summary-%d' + ANSWER_LIST_KEY_TPL = 'thread-answer-list-%d' title = models.CharField(max_length=300) @@ -323,6 +325,9 @@ class Thread(models.Model): accepted_answer = models.ForeignKey(Post, null=True, blank=True, related_name='+') answer_accepted_at = models.DateTimeField(null=True, blank=True) + added_at = models.DateTimeField(default = datetime.datetime.now) + + score = models.IntegerField(default = 0) objects = ThreadManager() @@ -420,6 +425,105 @@ class Thread(models.Model): | models.Q(deleted_by = user) ) + def invalidate_cached_thread_content_fragment(self): + """we do not precache the fragment here, as re-generating + the the fragment takes a lot of data, so we just + invalidate the cached item + + Note: the cache key generation code is copy-pasted + from coffin/template/defaulttags.py no way around + that unfortunately + """ + args_md5 = md5_constructor(str(self.id)) + key = 'template.cache.%s.%s' % ('thread-content-html', args_md5.hexdigest()) + cache.cache.delete(key) + + def get_post_data_cache_key(self, sort_method = None): + return 'thread-data-%s-%s' % (self.id, sort_method) + + def invalidate_cached_post_data(self): + """needs to be called when anything notable + changes in the post data - on votes, adding, + deleting, editing content""" + #we can call delete_many() here if using Django > 1.2 + for sort_method in const.ANSWER_SORT_METHODS: + cache.cache.delete(self.get_post_data_cache_key(sort_method)) + + def invalidate_cached_data(self): + self.invalidate_cached_post_data() + self.invalidate_cached_thread_content_fragment() + + def get_cached_post_data(self, sort_method = None): + """returns cached post data, as calculated by + the method get_post_data()""" + key = self.get_post_data_cache_key(sort_method) + post_data = cache.cache.get(key) + if not post_data: + post_data = self.get_post_data(sort_method) + cache.cache.set(key, post_data, const.LONG_TIME) + return post_data + + def get_post_data(self, sort_method = None): + """returns question, answers as list and a list of post ids + for the given thread + the returned posts are pre-stuffed with the comments + all (both posts and the comments sorted in the correct + order) + """ + thread_posts = self.posts.all().order_by( + { + "latest":"-added_at", + "oldest":"added_at", + "votes":"-score" + }[sort_method] + ) + #1) collect question, answer and comment posts and list of post id's + answers = list() + post_map = dict() + comment_map = dict() + post_to_author = dict() + question_post = None + for post in thread_posts: + #pass through only deleted question posts + if post.deleted and post.post_type != 'question': + continue + + post_to_author[post.id] = post.author_id + + if post.post_type == 'answer': + answers.append(post) + post_map[post.id] = post + elif post.post_type == 'comment': + if post.parent_id not in comment_map: + comment_map[post.parent_id] = list() + comment_map[post.parent_id].append(post) + elif post.post_type == 'question': + assert(question_post == None) + post_map[post.id] = post + question_post = post + + #2) sort comments in the temporal order + for comment_list in comment_map.values(): + comment_list.sort(key=operator.attrgetter('added_at')) + + #3) attach comments to question and the answers + for post_id, comment_list in comment_map.items(): + try: + post_map[post_id].set_cached_comments(comment_list) + except KeyError: + pass#comment to deleted answer - don't want it + + if self.has_accepted_answer() and self.accepted_answer.deleted == False: + #Put the accepted answer to front + #the second check is for the case when accepted answer is deleted + accepted_answer = post_map[self.accepted_answer_id] + answers.remove(accepted_answer) + answers.insert(0, accepted_answer) + + return (question_post, answers, post_to_author) + + def has_accepted_answer(self): + return self.accepted_answer_id != None def get_similarity(self, other_thread = None): """return number of tags in the other question @@ -442,9 +546,15 @@ class Thread(models.Model): """ def get_data(): - tags_list = self.tags.all() - similar_threads = Thread.objects.filter(tags__in=tags_list).\ - exclude(id = self.id).exclude(posts__post_type='question', posts__deleted = True).distinct()[:100] + tags_list = self.get_tag_names() + similar_threads = Thread.objects.filter( + tags__name__in=tags_list + ).exclude( + id = self.id + ).exclude( + posts__post_type='question', + posts__deleted = True + ).distinct()[:100] similar_threads = list(similar_threads) for thread in similar_threads: @@ -455,7 +565,8 @@ class Thread(models.Model): # Denormalize questions to speed up template rendering thread_map = dict([(thread.id, thread) for thread in similar_threads]) - questions = Post.objects.get_questions().select_related('thread').filter(thread__in=similar_threads) + questions = Post.objects.get_questions() + questions = questions.select_related('thread').filter(thread__in=similar_threads) for q in questions: thread_map[q.thread_id].question_denorm = q @@ -466,10 +577,20 @@ class Thread(models.Model): 'title': thread.get_title(thread.question_denorm) } for thread in similar_threads ] - return similar_threads - return LazyList(get_data) + def get_cached_data(): + """similar thread data will expire + with the default expiration delay + """ + key = 'similar-threads-%s' % self.id + data = cache.cache.get(key) + if data is None: + data = get_data() + cache.cache.set(key, data) + return data + + return LazyList(get_cached_data) def remove_author_anonymity(self): """removes anonymous flag from the question @@ -484,6 +605,12 @@ class Thread(models.Model): Post.objects.filter(id=thread_question.id).update(is_anonymous=False) thread_question.revisions.all().update(is_anonymous=False) + def is_followed_by(self, user = None): + """True if thread is followed by user""" + if user and user.is_authenticated(): + return self.followed_by.filter(id = user.id).count() > 0 + return False + def update_tags(self, tagnames = None, user = None, timestamp = None): """ Updates Tag associations for a thread to match the given @@ -659,36 +786,16 @@ class Thread(models.Model): # * We probably don't need to pollute the cache with threads older than 30 days # * Additionally, Memcached treats timeouts > 30day as dates (https://code.djangoproject.com/browser/django/tags/releases/1.3/django/core/cache/backends/memcached.py#L36), # which probably doesn't break anything but if we can stick to 30 days then let's stick to it - cache.cache.set(self.SUMMARY_CACHE_KEY_TPL % self.id, html, timeout=60*60*24*30) + cache.cache.set( + self.SUMMARY_CACHE_KEY_TPL % self.id, + html, + timeout=const.LONG_TIME + ) return html def summary_html_cached(self): return cache.cache.has_key(self.SUMMARY_CACHE_KEY_TPL % self.id) - -#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' -# -# TODO: Add sphinx_search() to Post model -# -#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 = models.ForeignKey(Post, related_name='viewed') who = models.ForeignKey(User, related_name='question_views') diff --git a/askbot/skins/common/media/js/post.js b/askbot/skins/common/media/js/post.js index dc3fbfd7..0ad59c69 100644 --- a/askbot/skins/common/media/js/post.js +++ b/askbot/skins/common/media/js/post.js @@ -311,7 +311,6 @@ var Vote = function(){ var removeAllOffensiveIdPrefixAnswerFlag = 'answer-offensive-remove-all-flag-'; var offensiveClassFlag = 'offensive-flag'; var questionControlsId = 'question-controls'; - var removeQuestionLinkIdPrefix = 'question-delete-link-'; var removeAnswerLinkIdPrefix = 'answer-delete-link-'; var questionSubscribeUpdates = 'question-subscribe-updates'; var questionSubscribeSidebar= 'question-subscribe-sidebar'; @@ -419,11 +418,6 @@ var Vote = function(){ return $(removeAllOffensiveAnswerFlag); }; - var getremoveQuestionLink = function(){ - var removeQuestionLink = 'div#question-controls a[id^='+ removeQuestionLinkIdPrefix +']'; - return $(removeQuestionLink); - }; - var getquestionSubscribeUpdatesCheckbox = function(){ return $('#' + questionSubscribeUpdates); }; @@ -464,7 +458,7 @@ var Vote = function(){ var bindEvents = function(){ // accept answers - var acceptedButtons = 'div.'+ voteContainerId +' img[id^='+ imgIdPrefixAccept +']'; + var acceptedButtons = 'div.'+ voteContainerId +' div[id^='+ imgIdPrefixAccept +']'; $(acceptedButtons).unbind('click').click(function(event){ Vote.accept($(event.target)); }); @@ -520,10 +514,6 @@ var Vote = function(){ Vote.remove_all_offensive(this, VoteType.removeAllOffensiveAnswer); }); - //getremoveQuestionLink().unbind('click').click(function(event){ - // Vote.remove(this, VoteType.removeQuestion); - //}); - getquestionSubscribeUpdatesCheckbox().unbind('click').click(function(event){ //despeluchar esto if (this.checked){ @@ -578,19 +568,15 @@ var Vote = function(){ showMessage(object, acceptOwnAnswerMessage); } else if(data.status == "1"){ - object.attr("src", mediaUrl("media/images/vote-accepted.png")); $("#"+answerContainerIdPrefix+postId).removeClass("accepted-answer"); $("#"+commentLinkIdPrefix+postId).removeClass("comment-link-accepted"); } else if(data.success == "1"){ - var acceptedButtons = 'div.'+ voteContainerId +' img[id^='+ imgIdPrefixAccept +']'; - $(acceptedButtons).attr("src", mediaUrl("media/images/vote-accepted.png")); var answers = ("div[id^="+answerContainerIdPrefix +"]"); $(answers).removeClass("accepted-answer"); var commentLinks = ("div[id^="+answerContainerIdPrefix +"] div[id^="+ commentLinkIdPrefix +"]"); $(commentLinks).removeClass("comment-link-accepted"); - object.attr("src", mediaUrl("media/images/vote-accepted-on.png")); $("#"+answerContainerIdPrefix+postId).addClass("accepted-answer"); $("#"+commentLinkIdPrefix+postId).addClass("comment-link-accepted"); } diff --git a/askbot/skins/common/templates/authopenid/complete.html b/askbot/skins/common/templates/authopenid/complete.html index fbb6ba01..6408c8b4 100644 --- a/askbot/skins/common/templates/authopenid/complete.html +++ b/askbot/skins/common/templates/authopenid/complete.html @@ -20,50 +20,7 @@ parameters: {% block head %}{% endblock %} {% block title %}{% spaceless %}{% trans %}Registration{% endtrans %}{% endspaceless %}{% endblock %} {% block content %} - <h1>{% trans %}Registration{% endtrans %}</h1> - <div id="completetxt" > - <div class="message"> - {% if login_type=='openid' %} - {% trans %}<p><span class=\"big strong\">You are here for the first time with your -%(provider)s login.</span> Please create your <strong>screen name</strong> -and save your <strong>email</strong> address. Saved email address will let -you <strong>subscribe for the updates</strong> on the most interesting -questions and will be used to create and retrieve your unique avatar image - -<a href='%(gravatar_faq_url)s'><strong>gravatar</strong></a>.</p>{% endtrans %} - register new {{provider}} account info, see {{gravatar_faq_url}}{% endtrans %} - {% elif login_type=='legacy' %} - {% if external_login_name_is_taken %} - {% trans %}<p><span class='strong big'>Oops... looks like screen name %(username)s is -already used in another account.</span></p><p>Please choose another screen -name to use with your %(provider)s login. Also, a valid email address is -required on the <span class='orange'>Q&A</span> forum. Your email is -used to create a unique <a href='%(gravatar_faq_url)s'><strong>gravatar -</strong></a> image for your account. If you like, you can <strong>receive -updates</strong> on the interesting questions or entire forum by email. -Email addresses are never shown or otherwise shared with anybody else.</p> - {% endtrans %} - {% else %} - {% trans %} -<p><span class=\"big strong\">You are here for the first time with your -%(provider)s login.</span></p><p>You can either keep your <strong>screen -name</strong> the same as your %(provider)s login name or choose some other -nickname.</p><p>Also, please save a valid <strong>email</strong> address. -With the email you can <strong>subscribe for the updates</strong> on the -most interesting questions. Email address is also used to create and -retrieve your unique avatar image - <a -href='%(gravatar_faq_url)s'><strong>gravatar</strong></a>.</p>{% endtrans %} - {% endif %} - {% else %} - {% trans %}<p><span class=\"big strong\">You are here for the first time with your -Facebook login.</span> Please create your <strong>screen name</strong> and -save your <strong>email</strong> address. Saved email address will let you -<strong>subscribe for the updates</strong> on the most interesting questions -and will be used to create and retrieve your unique avatar image - -<a href='%(gravatar_faq_url)s'><strong>gravatar</strong></a>.</p>{% endtrans %} - {% endif %} - </div> - <p style="display:none">{% trans %}This account already exists, please use another.{% endtrans %}</p> - </div> + <h1>{% trans %}User registration{% endtrans %}</h1> {% if openid_register_form.errors %} <ul class="errorlist"> {% for error in openid_register_form.non_field_errors() %} @@ -81,7 +38,9 @@ and will be used to create and retrieve your unique avatar image - {% endif %} {{ openid_register_form.next }} <div class="form-row-vertical"> - {%- trans %}<strong>Screen Name</strong> (<i>will be shown to others</i>){% endtrans %} + <label for="id_username"> + {%- trans %}<strong>Screen Name</strong> (<i>will be shown to others</i>){% endtrans %} + </label> {% if openid_register_form.username.errors %} <p class="error">{{ openid_register_form.username.errors|join(", ") }}</p> {% endif %} @@ -105,7 +64,6 @@ anyone, must be valid</i>) <p class="error">{% trans %}please select one of the options above{% endtrans %}</p> {% endif %} </div> - <p class='space-above'>{% trans %}Tag filter tool will be your right panel, once you log in.{% endtrans %}</p> <div class="submit-row"><input type="submit" class="submit" name="bnewaccount" value="{% trans %}Signup{% endtrans %}"/></div> </form> </div> diff --git a/askbot/skins/common/templates/question/answer_controls.html b/askbot/skins/common/templates/question/answer_controls.html index fd12c856..091572af 100644 --- a/askbot/skins/common/templates/question/answer_controls.html +++ b/askbot/skins/common/templates/question/answer_controls.html @@ -8,26 +8,18 @@ {% trans %}link{% endtrans %} </a> </span> -{% if request.user.is_authenticated() and - ( - request.user == answer.author or - request.user.is_administrator_or_moderator() - ) -%} -<span class="action-link delete-post"> +<span id='delete-answer-{{answer.id}}' class="action-link delete-post"> <a class="question-delete" >{% if answer.deleted %}{% trans %}undelete{% endtrans %}{% else %}{% trans %}delete{% endtrans %}{% endif %}</a> </span> +{% if answer.offensive_flag_count > 0 %} <span - id="answer-offensive-flag-{{ answer.id }}" + id="answer-offensive-remove-flag-{{ answer.id }}" class="action-link offensive-flag" - title="{% trans %}report as offensive (i.e containing spam, advertising, malicious text, etc.){% endtrans %}" + title="{% trans %}remove offensive flag{% endtrans %}" > - <a class="question-flag">{% trans %}flag offensive{% endtrans %} - <span class="darkred">{% if answer.offensive_flag_count > 0 %}({{ answer.offensive_flag_count }}){% endif %}</span> - </a> + <a class="question-flag">{% trans %}remove flag{% endtrans %}</a> </span> -{% if answer.offensive_flag_count > 0 %} <span id="answer-offensive-flag-{{ answer.id }}" class="action-link offensive-flag" @@ -36,13 +28,6 @@ <a class="question-flag">{% trans %}flag offensive{% endtrans %} ({{ answer.offensive_flag_count }})</a> </a> </span> -<span - id="answer-offensive-flag-remove-{{ answer.id }}" - class="action-link offensive-flag" - title="{% trans %}remove offensive flag{% endtrans %}" -> - <a class="question-flag">{% trans %}remove flag{% endtrans %} ({{ answer.offensive_flag_count }})</a> -</span> {% else %} <span id="answer-offensive-flag-{{ answer.id }}" @@ -52,7 +37,20 @@ <a class="question-flag">{% trans %}flag offensive{% endtrans %}</a> </span> {% endif %} -<span class="action-link"> +<span id='edit-answer-{{answer.id}}' class="action-link"> <a class="question-edit" href="{% url edit_answer answer.id %}">{% trans %}edit{% endtrans %}</a> </span> -{% endif %} +<script type="text/javascript"> + (function(){ + var del_link = document.getElementById( + 'delete-answer-' + '{{answer.id}}' + ); + var edit_link = document.getElementById( + 'edit-answer-' + '{{answer.id}}' + ); + if (askbot['data']['userIsAuthenticated'] === false){ + del_link.parentNode.removeChild(del_link); + edit_link.parentNode.removeChild(edit_link); + } + })(); +</script> diff --git a/askbot/skins/common/templates/question/answer_vote_buttons.html b/askbot/skins/common/templates/question/answer_vote_buttons.html index 9097fec2..242bf2be 100644 --- a/askbot/skins/common/templates/question/answer_vote_buttons.html +++ b/askbot/skins/common/templates/question/answer_vote_buttons.html @@ -1,20 +1,10 @@ -{{ macros.post_vote_buttons(post = answer, visitor_vote = user_answer_votes[answer.id]) }} -<img id="answer-img-accept-{{ answer.id }}" class="answer-img-accept" +{{ macros.post_vote_buttons(post = answer) }} +<div + id="answer-img-accept-{{ answer.id }}" + class="answer-img-accept" {% if answer.accepted() %} - src="{{'/images/vote-accepted-on.png'|media}}" + title="{% trans %}this answer has been selected as correct{% endtrans %}" {% else %} - src="{{'/images/vote-accepted.png'|media}}" + title="{% trans %}mark this answer as correct (click again to undo){% endtrans %}" {% endif %} - {% if request.user.is_authenticated() and - ( - request.user == question.author or - request.user.is_administrator_or_moderator() - ) - %} - alt="{% trans %}mark this answer as correct (click again to undo){% endtrans %}" - title="{% trans %}mark this answer as correct (click again to undo){% endtrans %}" - {% else %} - alt="{% trans question_author=question.author.username %}{{question_author}} has selected this answer as correct{% endtrans %}" - title="{% trans question_author=question.author.username%}{{question_author}} has selected this answer as correct{% endtrans %}" - {% endif %} - /> +></div> diff --git a/askbot/skins/common/templates/question/question_controls.html b/askbot/skins/common/templates/question/question_controls.html index 4710559d..5eee380a 100644 --- a/askbot/skins/common/templates/question/question_controls.html +++ b/askbot/skins/common/templates/question/question_controls.html @@ -15,17 +15,17 @@ {% endif %} {% if question.offensive_flag_count > 0 %} <span - id="question-offensive-flag-{{ question.id }}" class="offensive-flag" + id="question-offensive-remove-flag-{{ question.id }}" + class="offensive-flag" title="{% trans %}report as offensive (i.e containing spam, advertising, malicious text, etc.){% endtrans %}" > - <a class="question-flag">{% trans %}flag offensive{% endtrans %} {{ question.offensive_flag_count }})</a> + <a class="question-flag">{% trans %}remove flag{% endtrans %}</a> </span> <span - id="question-offensive-flag-remove-{{ question.id }}" - class="offensive-flag" + id="question-offensive-flag-{{ question.id }}" class="offensive-flag" title="{% trans %}report as offensive (i.e containing spam, advertising, malicious text, etc.){% endtrans %}" > - <a class="question-flag">{% trans %}remove flag{% endtrans %} ({{ question.offensive_flag_count }})</a> + <a class="question-flag">{% trans %}flag offensive{% endtrans %} ({{ question.offensive_flag_count }})</a> </span> {% else %} <span diff --git a/askbot/skins/common/templates/question/question_vote_buttons.html b/askbot/skins/common/templates/question/question_vote_buttons.html index 8466beb9..6b8774cc 100644 --- a/askbot/skins/common/templates/question/question_vote_buttons.html +++ b/askbot/skins/common/templates/question/question_vote_buttons.html @@ -1 +1 @@ -{{ macros.post_vote_buttons(post = question, visitor_vote = user_question_vote) }} +{{ macros.post_vote_buttons(post = question) }} diff --git a/askbot/skins/default/media/style/style.less b/askbot/skins/default/media/style/style.less index e8e5a5d8..4f096bd0 100644 --- a/askbot/skins/default/media/style/style.less +++ b/askbot/skins/default/media/style/style.less @@ -2034,9 +2034,17 @@ ul#related-tags li { } } + .answer-img-accept { + background: url(../images/vote-accepted.png); + width: 23px; + height: 23px; + } + + .accepted-answer .answer-img-accept, .answer-img-accept:hover { background: url(../images/vote-accepted-on.png) } + .answer-body a { color:@link; } diff --git a/askbot/skins/default/templates/base.html b/askbot/skins/default/templates/base.html index bd19f707..bc0a8d6c 100644 --- a/askbot/skins/default/templates/base.html +++ b/askbot/skins/default/templates/base.html @@ -9,6 +9,7 @@ {% include "meta/html_head_stylesheets.html" %} {% block forestyle %}{% endblock %} {% include "meta/html_head_javascript.html" %} + {% block forejs %}{% endblock %} {% if settings.USE_CUSTOM_HTML_HEAD %} {{ settings.CUSTOM_HTML_HEAD }} {% endif %} diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html index 93eae41b..e0de6bb6 100644 --- a/askbot/skins/default/templates/macros.html +++ b/askbot/skins/default/templates/macros.html @@ -23,16 +23,10 @@ </div> {%- endmacro -%} -{%- macro post_vote_buttons(post = None, visitor_vote = None) -%} -<div - id="{{post.post_type}}-img-upvote-{{ post.id }}" - class="{{post.post_type}}-img-upvote post-vote{% if visitor_vote == 1 %} on{% endif %}" - {% if post.post_type == 'question' %} - title="{% trans %}i like this question (click again to cancel){% endtrans %}" - {% else %} - title="{% trans %}i like this answer (click again to cancel){% endtrans %}" - {% endif %} -/></div> +{%- macro post_vote_buttons(post = None) -%} +<div id="{{post.post_type}}-img-upvote-{{ post.id }}" + class="{{post.post_type}}-img-upvote post-vote"> +</div> <div id="{{post.post_type}}-vote-number-{{ post.id }}" class="vote-number" @@ -40,13 +34,11 @@ >{{ post.score }}</div> <div id="{{post.post_type}}-img-downvote-{{ post.id }}" - class="{{post.post_type}}-img-downvote post-vote{% if visitor_vote == -1 %} on{% endif %}" - {% if post.post_type == 'question' %} - title="{% trans %}i dont like this question (click again to cancel){% endtrans %}" - {% else %} - title="{% trans %}i dont like this answer (click again to cancel){% endtrans %}" - {% endif %} -/></div> + class="{{post.post_type}}-img-downvote post-vote"> +</div> +<script type="text/javascript"> + askbot['functions']['renderPostVoteButtons']('{{post.post_type}}', '{{post.id}}'); +</script> {%- endmacro -%} {%- macro post_contributor_avatar_and_credentials(post, user) -%} @@ -244,27 +236,22 @@ poor design of the data or methods on data objects #} {# Warning! Any changes to the comment markup here must be duplicated in post.js for the purposes of the AJAX comment editor #} -{%- macro add_or_show_comments_button(post = None, can_post = None, max_comments = None, widget_id = None) -%} +{%- macro add_or_show_comments_button(post = None, max_comments = None, widget_id = None) -%} + {% if post.comment_count > max_comments %} + {% set remaining_comment_count = post.comment_count - max_comments %} + {% else %} + {% set remaining_comment_count = 0 %} + {% endif %} + <a id="add-comment-to-post-{{post.id}}" class="button"></a> <script type="text/javascript"> askbot['data']['{{widget_id}}'] = { - can_post: {% if can_post %}true{% else %}false{% endif %}, truncated: {% if post.comment_count > max_comments %}true{% else %}false{% endif %} }; + askbot['functions']['renderAddCommentButton']( + '{{post.id}}', + {{remaining_comment_count}} + ); </script> - {% if post.comment_count > max_comments %} - {% set remaining_comments = post.comment_count - max_comments %} - <a class="button"> - {% if can_post %} - {% trans %}post a comment{% endtrans %} / - {% trans counter=remaining_comments %}see <strong>{{counter}}</strong> more{% pluralize %}see <strong>{{counter}}</strong> more{% endtrans %} - {% else %} - {% trans counter=remaining_comments %}see <strong>{{counter}}</strong> more comment{% pluralize %}see <strong>{{counter}}</strong> more comments - {% endtrans %} - {% endif %} - </a> - {% elif can_post %} - <a class="button">{% trans %}post a comment{% endtrans %}</a> - {% endif %} {%- endmacro -%} {%- macro post_comments_widget( @@ -285,9 +272,9 @@ for the purposes of the AJAX comment editor #} <div class="comments" id="{{widget_id}}"> <div class="content"> {% if show_post == post and show_comment and show_comment_position > max_comments %} - {% set comments = post._cached_comments[:show_comment_position] %} + {% set comments = post.get_cached_comments()[:show_comment_position] %} {% else %} - {% set comments = post._cached_comments[:max_comments] %} + {% set comments = post.get_cached_comments()[:max_comments] %} {% endif %} {% for comment in comments %} {# Warning! Any changes to the comment markup IN THIS `FOR` LOOP must be duplicated in post.js @@ -295,35 +282,42 @@ for the purposes of the AJAX comment editor #} <div class="comment" id="comment-{{comment.id}}"> <div class="comment-votes"> {% if comment.score > 0 %} - <div class="upvote{% if comment.upvoted_by_user %} upvoted{% endif %}">{{comment.score}}</div> + <div + id="comment-img-upvote-{{comment.id}}" + class="upvote" + >{{comment.score}}</div> + <script type="text/javascript"> + askbot['functions']['renderPostVoteButtons']('comment', '{{comment.id}}'); + </script> {% else %} <div class="upvote"></div> {% endif %} </div> - <div class="comment-delete"> - {% if user|can_delete_comment(comment) %} - <span class="delete-icon" title="{% trans %}delete this comment{% endtrans %}"></span> - {% endif %} + <div + id="post-{{comment.id}}-delete" + class="comment-delete" + > + <span class="delete-icon" title="{% trans %}delete this comment{% endtrans %}"></span> </div> <div class="comment-body"> {{comment.html}} <a class="author" href="{{comment.author.get_profile_url()}}">{{comment.author.username}}</a> <span class="age"> ({{comment.added_at|diff_date}})</span> - {% if user|can_edit_comment(comment) %} - <a class="edit">{% trans %}edit{% endtrans %}</a> - {% endif %} + <a id="post-{{comment.id}}-edit" + class="edit">{% trans %}edit{% endtrans %}</a> </div> </div> + <script type="text/javascript"> + askbot['functions']['renderPostControls']('{{comment.id}}'); + </script> {% endfor %} </div> <div class="controls"> - {% set can_post = user.is_authenticated() and user.can_post_comment(post) %} {% if show_post == post and show_comment %} {% if show_comment_position > max_comments %} {{ add_or_show_comments_button( post = post, - can_post = can_post, max_comments = show_comment_position, widget_id = widget_id ) @@ -332,7 +326,6 @@ for the purposes of the AJAX comment editor #} {{ add_or_show_comments_button( post = post, - can_post = can_post, max_comments = max_comments, widget_id = widget_id ) @@ -342,7 +335,6 @@ for the purposes of the AJAX comment editor #} {{ add_or_show_comments_button( post = post, - can_post = can_post, max_comments = max_comments, widget_id = widget_id ) diff --git a/askbot/skins/default/templates/meta/bottom_scripts.html b/askbot/skins/default/templates/meta/bottom_scripts.html index dd5cb202..244cec21 100644 --- a/askbot/skins/default/templates/meta/bottom_scripts.html +++ b/askbot/skins/default/templates/meta/bottom_scripts.html @@ -12,16 +12,6 @@ var scriptUrl = '/{{settings.ASKBOT_URL}}' var askbotSkin = '{{settings.ASKBOT_DEFAULT_SKIN}}'; var enableMathJax = {% if settings.ENABLE_MATHJAX %}true{% else %}false{% endif %}; - {% if request.user.is_authenticated() %} - askbot['data']['userIsAuthenticated'] = true; - askbot['data']['userId'] = {{request.user.id}}; - askbot['data']['userIsAdminOrMod'] = {% if - request.user.is_administrator() - or request.user.is_moderator() - %}true{% else %}false{% endif %}; - {% else %} - askbot['data']['userIsAuthenticated'] = false; - {% endif %} askbot['urls']['mark_read_message'] = '{% url "read_message" %}'; askbot['urls']['get_tags_by_wildcard'] = '{% url "get_tags_by_wildcard" %}'; askbot['urls']['get_tag_list'] = '{% url "get_tag_list" %}'; diff --git a/askbot/skins/default/templates/meta/html_head_javascript.html b/askbot/skins/default/templates/meta/html_head_javascript.html index 2d453215..65d0bdce 100644 --- a/askbot/skins/default/templates/meta/html_head_javascript.html +++ b/askbot/skins/default/templates/meta/html_head_javascript.html @@ -2,10 +2,20 @@ <script type="text/javascript"> var askbot = {}; askbot['data'] = {}; + {% if request.user.is_authenticated() %} + askbot['data']['userIsAuthenticated'] = true; + askbot['data']['userId'] = {{request.user.id}}; + askbot['data']['userIsAdminOrMod'] = {% if + request.user.is_administrator() + or request.user.is_moderator() + %}true{% else %}false{% endif %}; + askbot['data']['userReputation'] = {{request.user.reputation}}; + {% else %} + askbot['data']['userIsAuthenticated'] = false; + askbot['data']['userReputation'] = 0; + {% endif %} askbot['urls'] = {}; askbot['settings'] = {}; askbot['messages'] = {}; </script> -{% block forejs %} -{% endblock %} {# avoid adding javascript here so that pages load faster #} diff --git a/askbot/skins/default/templates/question.html b/askbot/skins/default/templates/question.html index b2462faf..bc0dbdeb 100644 --- a/askbot/skins/default/templates/question.html +++ b/askbot/skins/default/templates/question.html @@ -9,15 +9,148 @@ <link rel="canonical" href="{{settings.APP_URL|strip_path}}{{question.get_absolute_url()}}" /> <link rel="stylesheet" type="text/css" href="{{'/js/wmd/wmd.css'|media}}" /> {% endblock %} +{% block forejs %} + <script type="text/javascript"> + //below is pure cross-browser javascript, no jQuery + (function(){ + var data = askbot['data']; + if (data['userIsAuthenticated']){ + var votes = {}; + {% for post_id in user_votes %} + votes['{{post_id}}'] = {{user_votes[post_id]}}; + {% endfor %} + data['user_votes'] = votes; + var posts = {}; + {% for post_id in user_post_id_list %} + posts['{{post_id}}'] = 1; + {% endfor %} + data['user_posts'] = posts; + } + + function render_vote_buttons(post_type, post_id){ + var upvote_btn = document.getElementById( + post_type + '-img-upvote-' + post_id + ); + var downvote_btn = document.getElementById( + post_type + '-img-downvote-' + post_id + ); + if (data['userIsAuthenticated']){ + if (post_id in data['user_votes']){ + var vote = data['user_votes'][post_id]; + if (vote == -1){ + var btn = downvote_btn; + } else if (vote == 1){ + var btn = upvote_btn; + } else { + return; + } + if (post_type == 'comment'){ + btn.className = btn.className + ' upvoted'; + } else { + btn.className = btn.className + ' on'; + } + } + } + } + function render_post_controls(post_id){ + if (data['userIsAdminOrMod']){ + return;//all functions on + } + var edit_btn = document.getElementById( + 'post-' + post_id + '-edit' + ) + if (post_id in data['user_posts']){ + //todo: remove edit button from older comments + return;//same here + } + if ( + data['userReputation'] < + {{settings.MIN_REP_TO_DELETE_OTHERS_COMMENTS}} + ) { + var delete_btn = document.getElementById( + 'post-' + post_id + '-delete' + ); + delete_btn.parentNode.removeChild(delete_btn); + } + edit_btn.parentNode.removeChild(edit_btn); + } + function render_add_comment_button(post_id, extra_comment_count){ + var can_add = false; + {% if user_can_post_comment %} + can_add = true; + {% else %} + if (post_id in data['user_posts']){ + can_add = true; + } + {% endif %} + var add_comment_btn = document.getElementById( + 'add-comment-to-post-' + post_id + ); + if (can_add === false){ + add_comment_btn.parentNode.removeChild(add_comment_btn); + return; + } + + var text = ''; + if (extra_comment_count > 0){ + if (can_add){ + text = + "{% trans %}post a comment / <strong>some</strong> more{% endtrans %}"; + } else { + text = + "{% trans %}see <strong>some</strong> more{% endtrans%}"; + } + } else { + if (can_add){ + text = "{% trans %}post a comment{% endtrans %}"; + } + } + add_comment_btn.innerHTML = text; + //add the count + for (node in add_comment_btn.childNodes){ + if (node.nodeName === 'strong'){ + node.innerHTML = extra_comment_count; + break; + } + } + } + askbot['functions'] = askbot['functions'] || {}; + askbot['functions']['renderPostVoteButtons'] = render_vote_buttons; + askbot['functions']['renderPostControls'] = render_post_controls; + askbot['functions']['renderAddCommentButton'] = render_add_comment_button; + })(); + </script> +{% endblock %} {% block content %} - {# ==== BEGIN: question/content.html ==== #} - {% include "question/content.html" %} - {# ==== END: question/content.html ==== #} + {% if is_cacheable %} + {% cache long_time "thread-content-html" thread.id %} + {% include "question/content.html" %} + {% endcache %} + {% else %} + {% include "question/content.html" %} + {% endif %} {% endblock %} {% block sidebar %} - {%include "question/sidebar.html" %} + {% include "question/sidebar.html" %} {% endblock %} {% block endjs %} - {%include "question/javascript.html" %} + {% include "question/javascript.html" %} + {# + <script type="text/javascript"> + var messages = askbot['messages']; + messages['upvote_question'] = gettext( + 'I like this question (click again to cancel)' + ); + messages['upvote_answer'] = gettext( + 'I like this answer (click again to cancel)' + ); + messages['downvote_question'] = gettext( + "I don't like this question (click again to cancel)" + ); + messages['downvote_answer'] = gettext( + "I don't like this answer (click again to cancel)" + ); + </script> + #} {% endblock %} diff --git a/askbot/skins/default/templates/question/answer_card.html b/askbot/skins/default/templates/question/answer_card.html index d71131a8..7161c186 100644 --- a/askbot/skins/default/templates/question/answer_card.html +++ b/askbot/skins/default/templates/question/answer_card.html @@ -7,29 +7,21 @@ id="post-id-{{ answer.id }}" class="{{ macros.answer_classes(answer, question) }}"> <div class="vote-buttons"> - {# ==== START: question/answer_vote_buttons.html ==== #} {% include "question/answer_vote_buttons.html" %} - {# ==== END: question/answer_vote_buttons.html ==== #} </div> <div class="answer-table"> <div class="item-right"> <div class="answer-body"> <div class="post-update-info-container"> - {# ==== START: question/answer_author_info.html ==== #} {% include "question/answer_author_info.html" %} - {# ==== END: question/answer_author_info.html ==== #} </div> {{ answer.html }} </div> <div class="answer-controls post-controls"> - {# ==== START: question/answer_controls.html ==== #} {% include "question/answer_controls.html" %} - {# ==== END: question/answer_controls.html ==== #} </div> - {# ==== START: question/answer_comments.html ==== #} {% include "question/answer_comments.html" %} - {# ==== END: question/answer_comments.html ==== #} </div> </div> <div class="clean"></div> diff --git a/askbot/skins/default/templates/question/javascript.html b/askbot/skins/default/templates/question/javascript.html index 8ad3f09c..3a29579d 100644 --- a/askbot/skins/default/templates/question/javascript.html +++ b/askbot/skins/default/templates/question/javascript.html @@ -42,7 +42,7 @@ var answer_sort_tab = "{{ tab_id }}"; $("#" + answer_sort_tab).attr('className',"on"); - Vote.init({{ 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 %} @@ -53,7 +53,7 @@ } {% if settings.ENABLE_SHARING_GOOGLE %}$.getScript("http://apis.google.com/js/plusone.js"){% endif %} - {% if request.user == question.author %} + {% if request.user.id == question.author_id %} $("#fmanswer_button").click(function() { $("#fmanswer").show(); $("#fmanswer_button").hide(); diff --git a/askbot/skins/default/templates/question/question_card.html b/askbot/skins/default/templates/question/question_card.html index 7077a8d1..08f7ccee 100644 --- a/askbot/skins/default/templates/question/question_card.html +++ b/askbot/skins/default/templates/question/question_card.html @@ -1,34 +1,31 @@ <div class="vote-buttons"> - {# ==== BEGIN: question/question_vote_buttons.html ==== #} {% include "question/question_vote_buttons.html" %} - {# ==== END: question/question_vote_buttons.html ==== #} - {# ==== BEGIN: question/share_buttons.html ==== #} {% include "question/share_buttons.html" %} - {# ==== END: question/share_buttons.html ==== #} </div> <div id="post-id-{{question.id}}" class="question-content{% if question.deleted %} deleted{% endif %}"> <h1><a href="{{ question.get_absolute_url() }}">{{ thread.get_title(question)|escape }}</a></h1> {% include "question/question_tags.html" %} - {# ==== END: question/question_tags.html" #} <div id="question-table"> <div class="question-body"> <div class="post-update-info-container"> - {# ==== START: "question/question_author_info.html" #} {% include "question/question_author_info.html" %} - {# ==== END: "question/question_author_info.html" #} </div> {{ question.html }} </div> <div id="question-controls" class="post-controls"> - {# ==== START: include "question/question_controls.html" #} {% include "question/question_controls.html" %} - {# ==== END: include "question/question_controls.html" #} </div> - {# ==== START: question/question_comments.html ==== #} + <script type="text/javascript"> + (function(){ + if (askbot['data']['userIsAuthenticated'] === false){ + var ctrl = document.getElementById('question-controls') + ctrl.parentNode.removeChild(ctrl); + } + })(); + </script> {% include "question/question_comments.html" %} - {# ==== END: question/question_comments.html ==== #} </div> </div> diff --git a/askbot/tasks.py b/askbot/tasks.py index 634befb9..d94e0a68 100644 --- a/askbot/tasks.py +++ b/askbot/tasks.py @@ -22,6 +22,7 @@ import traceback from django.contrib.contenttypes.models import ContentType from celery.decorators import task +from askbot.conf import settings as askbot_settings from askbot.models import Activity, Post, Thread, User from askbot.models import send_instant_notifications_about_activity_in_post from askbot.models.badges import award_badges_signal @@ -133,6 +134,10 @@ def record_post_update( for user in (set(recipients) | set(newly_mentioned_users)): user.update_response_counts() + #shortcircuit if the email alerts are disabled + if askbot_settings.ENABLE_EMAIL_ALERTS == False: + return + #todo: weird thing is that only comments need the recipients #todo: debug these calls and then uncomment in the repo #argument to this call @@ -155,8 +160,8 @@ def record_post_update( @task(ignore_result = True) def record_question_visit( - question_post_id = None, - user_id = None, + question_post = None, + user = None, update_view_count = False): """celery task which records question visit by a person updates view counter, if necessary, @@ -164,12 +169,17 @@ def record_question_visit( question visit """ #1) maybe update the view count - question_post = Post.objects.get(id = question_post_id) + #question_post = Post.objects.filter( + # id = question_post_id + #).select_related('thread')[0] if update_view_count: question_post.thread.increase_view_count() + if user.is_anonymous(): + return + #2) question view count per user and clear response displays - user = User.objects.get(id = user_id) + #user = User.objects.get(id = user_id) if user.is_authenticated(): #get response notifications user.visit_question(question_post) diff --git a/askbot/views/commands.py b/askbot/views/commands.py index a6de376b..5d86d1a1 100644 --- a/askbot/views/commands.py +++ b/askbot/views/commands.py @@ -288,10 +288,10 @@ def vote(request, id): elif vote_type in ['7.6', '8.6']: #flag question or answer if vote_type == '7.6': - post = get_object_or_404(models.Question, id=id) + post = get_object_or_404(models.Post, id=id) if vote_type == '8.6': id = request.POST.get('postId') - post = get_object_or_404(models.Answer, id=id) + post = get_object_or_404(models.Post, id=id) request.user.flag_post(post, cancel_all = True) @@ -360,6 +360,13 @@ def vote(request, id): response_data['success'] = 0 response_data['message'] = u'Request mode is not supported. Please try again.' + if vote_type not in (1, 2, 4, 5, 6, 11, 12): + #favorite or subscribe/unsubscribe + #upvote or downvote question or answer - those + #are handled within user.upvote and user.downvote + post = models.Post.objects.get(id = id) + post.thread.invalidate_cached_data() + data = simplejson.dumps(response_data) except Exception, e: diff --git a/askbot/views/readers.py b/askbot/views/readers.py index c14d8008..6ad69aa3 100644 --- a/askbot/views/readers.py +++ b/askbot/views/readers.py @@ -307,6 +307,7 @@ def question(request, id):#refactor - long subroutine. display question body, an """ #process url parameters #todo: fix inheritance of sort method from questions + before = datetime.datetime.now() default_sort_method = request.session.get('questions_sort_method', 'votes') form = ShowQuestionForm(request.GET, default_sort_method) form.full_clean()#always valid @@ -353,6 +354,16 @@ def question(request, id):#refactor - long subroutine. display question body, an request.user.message_set.create(message = unicode(error)) return HttpResponseRedirect(reverse('index')) + #redirect if slug in the url is wrong + if request.path.split('/')[-1] != question_post.slug: + logging.debug('no slug match!') + question_url = '?'.join(( + question_post.get_absolute_url(), + urllib.urlencode(request.GET) + )) + return HttpResponseRedirect(question_url) + + #resolve comment and answer permalinks #they go first because in theory both can be moved to another question #this block "returns" show_post and assigns actual comment and answer @@ -410,51 +421,42 @@ def question(request, id):#refactor - long subroutine. display question body, an thread = question_post.thread - #redirect if slug in the url is wrong - if request.path.split('/')[-1] != question_post.slug: - logging.debug('no slug match!') - question_url = '?'.join(( - question_post.get_absolute_url(), - urllib.urlencode(request.GET) - )) - return HttpResponseRedirect(question_url) - logging.debug('answer_sort_method=' + unicode(answer_sort_method)) - #load answers - answers = thread.get_answers(user = request.user) - answers = answers.select_related('thread', 'author', 'last_edited_by') - answers = answers.order_by({"latest":"-added_at", "oldest":"added_at", "votes":"-score" }[answer_sort_method]) - answers = list(answers) - - # TODO: Add unit test to catch the bug where precache_comments() is called above (before) reordering the accepted answer to the top - #Post.objects.precache_comments(for_posts=[question_post] + answers, visitor=request.user) + #load answers and post id's->athor_id mapping + #posts are pre-stuffed with the correctly ordered comments + updated_question_post, answers, post_to_author = thread.get_cached_post_data( + sort_method = answer_sort_method, + ) + question_post.set_cached_comments(updated_question_post.get_cached_comments()) - if thread.accepted_answer and thread.accepted_answer.deleted == False: - #Put the accepted answer to front - #the second check is for the case when accepted answer is deleted - answers.remove(thread.accepted_answer) - answers.insert(0, thread.accepted_answer) - Post.objects.precache_comments(for_posts=[question_post] + answers, visitor=request.user) + #Post.objects.precache_comments(for_posts=[question_post] + answers, visitor=request.user) - user_answer_votes = {} + user_votes = {} + user_post_id_list = list() + #todo: cache this query set, but again takes only 3ms! if request.user.is_authenticated(): - votes = Vote.objects.filter(user=request.user, voted_post__in=answers) - for vote in votes: - user_answer_votes[vote.voted_post.id] = int(vote) - - filtered_answers = [answer for answer in answers if ((not answer.deleted) or (answer.deleted and answer.author_id == request.user.id))] - + user_votes = Vote.objects.filter( + user=request.user, + voted_post__id__in = post_to_author.keys() + ).values_list('voted_post_id', 'vote') + user_votes = dict(user_votes) + #we can avoid making this query by iterating through + #already loaded posts + user_post_id_list = [ + id for id in post_to_author if post_to_author[id] == request.user.id + ] + #resolve page number and comment number for permalinks show_comment_position = None if show_comment: - show_page = show_comment.get_page_number(answer_posts=filtered_answers) + show_page = show_comment.get_page_number(answer_posts=answers) show_comment_position = show_comment.get_order_number() elif show_answer: - show_page = show_post.get_page_number(answer_posts=filtered_answers) + show_page = show_post.get_page_number(answer_posts=answers) - objects_list = Paginator(filtered_answers, const.ANSWERS_PAGE_SIZE) + objects_list = Paginator(answers, const.ANSWERS_PAGE_SIZE) if show_page > objects_list.num_pages: return HttpResponseRedirect(question_post.get_absolute_url()) page_objects = objects_list.page(show_page) @@ -471,7 +473,7 @@ def question(request, id):#refactor - long subroutine. display question body, an last_seen = request.session['question_view_times'].get(question_post.id, None) - if thread.last_activity_by != request.user: + if thread.last_activity_by_id != request.user.id: if last_seen: if last_seen < thread.last_activity_at: update_view_count = True @@ -484,8 +486,8 @@ def question(request, id):#refactor - long subroutine. display question body, an #2) run the slower jobs in a celery task from askbot import tasks tasks.record_question_visit.delay( - question_post_id = question_post.id, - user_id = request.user.id, + question_post = question_post, + user = request.user, update_view_count = update_view_count ) @@ -501,26 +503,39 @@ def question(request, id):#refactor - long subroutine. display question body, an } paginator_context = functions.setup_paginator(paginator_data) + #todo: maybe consolidate all activity in the thread + #for the user into just one query? favorited = thread.has_favorite_by_user(request.user) - user_question_vote = 0 - if request.user.is_authenticated(): - votes = question_post.votes.select_related().filter(user=request.user) - try: - user_question_vote = int(votes[0]) - except IndexError: - user_question_vote = 0 + + is_cacheable = True + if show_page != 1: + is_cacheable = False + elif show_comment_position > askbot_settings.MAX_COMMENTS_TO_SHOW: + is_cacheable = False + + answer_form = AnswerForm( + initial = { + 'wiki': question_post.wiki and askbot_settings.WIKI_ON, + 'email_notify': thread.is_followed_by(request.user) + } + ) + + user_can_post_comment = ( + request.user.is_authenticated() and request.user.can_post_comment() + ) data = { + 'is_cacheable': is_cacheable, + 'long_time': const.LONG_TIME,#"forever" caching 'page_class': 'question-page', 'active_tab': 'questions', 'question' : question_post, 'thread': thread, - 'user_question_vote' : user_question_vote, - 'question_comment_count': question_post.comments.count(), - 'answer' : AnswerForm(question_post, request.user), + 'answer' : answer_form, 'answers' : page_objects.object_list, - 'user_answer_votes': user_answer_votes, - 'tags' : thread.tags.all(), + 'user_votes': user_votes, + 'user_post_id_list': user_post_id_list, + 'user_can_post_comment': user_can_post_comment,#in general 'tab_id' : answer_sort_method, 'favorited' : favorited, 'similar_threads' : thread.get_similar_threads(), @@ -531,7 +546,9 @@ def question(request, id):#refactor - long subroutine. display question body, an 'show_comment_position': show_comment_position, } - return render_into_skin('question.html', data, request) + result = render_into_skin('question.html', data, request) + #print datetime.datetime.now() - before + return result def revisions(request, id, object_name=None): if object_name == 'Question': diff --git a/askbot/views/writers.py b/askbot/views/writers.py index 4c435eea..ab7f581e 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -484,7 +484,7 @@ def answer(request, id):#process a new answer """ question = get_object_or_404(models.Post, post_type='question', id=id) if request.method == "POST": - form = forms.AnswerForm(question, request.user, request.POST) + form = forms.AnswerForm(request.POST) if form.is_valid(): wiki = form.cleaned_data['wiki'] text = form.cleaned_data['text'] @@ -641,6 +641,7 @@ def delete_comment(request): #attn: recalc denormalized field parent.comment_count = parent.comment_count - 1 parent.save() + parent.thread.invalidate_cached_data() return __generate_comments_json(parent, request.user) |