diff options
-rw-r--r-- | askbot/management/commands/fix_answer_counts.py | 31 | ||||
-rw-r--r-- | askbot/setup_templates/settings.py | 6 |
2 files changed, 34 insertions, 3 deletions
diff --git a/askbot/management/commands/fix_answer_counts.py b/askbot/management/commands/fix_answer_counts.py new file mode 100644 index 00000000..3bb7f7d4 --- /dev/null +++ b/askbot/management/commands/fix_answer_counts.py @@ -0,0 +1,31 @@ +"""fix_answer_counts management command +to run type (on the command line:) + +python manage.py fix_answer_counts +""" +from django.core.management.base import NoArgsCommand +from django.db.models import signals +from askbot import models + +class Command(NoArgsCommand): + """Command class for "fix_answer_counts" + """ + + def remove_save_signals(self): + """removes signals on model pre-save and + post-save, so that there are no side-effects + besides actually updating the answer counts + """ + signals.pre_save.receivers = [] + signals.post_save.receivers = [] + + def handle(self, *arguments, **options): + """function that handles the command job + """ + self.remove_save_signals() + questions = models.Question.objects.all() + for question in questions: + #todo: must be simply + #question.update_answer_count() + models.Question.objects.update_answer_count(question) + question.save() diff --git a/askbot/setup_templates/settings.py b/askbot/setup_templates/settings.py index 3bee538f..4117880e 100644 --- a/askbot/setup_templates/settings.py +++ b/askbot/setup_templates/settings.py @@ -29,9 +29,9 @@ SERVER_EMAIL = '' DEFAULT_FROM_EMAIL = '' EMAIL_HOST_USER = '' EMAIL_HOST_PASSWORD = '' -EMAIL_SUBJECT_PREFIX = '[ASKBOT] ' -EMAIL_HOST='askbot.org' -EMAIL_PORT='25' +EMAIL_SUBJECT_PREFIX = '' +EMAIL_HOST='' +EMAIL_PORT='' EMAIL_USE_TLS=False # Local time zone for this installation. Choices can be found here: |