summaryrefslogtreecommitdiffstats
path: root/askbot/management
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-01-06 01:27:02 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-01-06 01:27:33 -0300
commit966720dcfefa3f8daced7ae9fef7ef5df00af0af (patch)
tree845449e225c399c15b24ad308ce2ade868f31fd1 /askbot/management
parentdf308aa37c4a91276d09007f6f55c706c8d9b1f6 (diff)
downloadaskbot-966720dcfefa3f8daced7ae9fef7ef5df00af0af.tar.gz
askbot-966720dcfefa3f8daced7ae9fef7ef5df00af0af.tar.bz2
askbot-966720dcfefa3f8daced7ae9fef7ef5df00af0af.zip
added basic support for multilingual content
Diffstat (limited to 'askbot/management')
-rw-r--r--askbot/management/commands/askbot_add_test_content.py10
-rw-r--r--askbot/management/commands/askbot_create_test_fixture.py76
-rw-r--r--askbot/management/commands/send_accept_answer_reminders.py4
-rw-r--r--askbot/management/commands/send_unanswered_question_reminders.py4
4 files changed, 11 insertions, 83 deletions
diff --git a/askbot/management/commands/askbot_add_test_content.py b/askbot/management/commands/askbot_add_test_content.py
index 7867fcec..0efd8c1f 100644
--- a/askbot/management/commands/askbot_add_test_content.py
+++ b/askbot/management/commands/askbot_add_test_content.py
@@ -1,8 +1,10 @@
-from django.core.management.base import NoArgsCommand
+from askbot.conf import settings as askbot_settings
from askbot.models import User
-from optparse import make_option
from askbot.utils.console import choice_dialog
-from askbot.conf import settings as askbot_settings
+from django.core.management.base import NoArgsCommand
+from django.conf import settings as django_settings
+from django.utils import translation
+from optparse import make_option
NUM_USERS = 40
@@ -236,6 +238,8 @@ class Command(NoArgsCommand):
if answer != "yes":
return
+ translation.activate(django_settings.LANGUAGE_CODE)
+
self.save_alert_settings()
self.stop_alerts()# saves time on running the command
diff --git a/askbot/management/commands/askbot_create_test_fixture.py b/askbot/management/commands/askbot_create_test_fixture.py
deleted file mode 100644
index e7045e8c..00000000
--- a/askbot/management/commands/askbot_create_test_fixture.py
+++ /dev/null
@@ -1,76 +0,0 @@
-from django.core.management.base import NoArgsCommand
-from django.core import management
-import os
-import askbot
-from optparse import make_option
-from askbot.utils.console import choice_dialog
-
-
-# FULL PATH HERE
-# DEFAULTS TO askbot_path/tests/test_data.json
-FIXTURE_NAME = os.path.join(os.path.dirname(askbot.__file__),
- "tests", "test_data.json")
-
-# The data from these apps gets auto-populated on signals, saves and updates
-# We have to exclude it otherwise we get Constraint errors
-EXCLUDE_APPS = ['contenttypes',
- 'sites',
- 'askbot.activity',
- 'askbot.activityauditstatus',
- 'askbot.badgedata',
- 'askbot.Post',
- 'askbot.EmailFeedSetting',
- 'auth.Message']
-
-
-class Command(NoArgsCommand):
- """
- Flushes the database, fills it with test data, dumps a fixture and then
- flushes the database again.
- """
-
- option_list = NoArgsCommand.option_list + (
- make_option('--noinput', action='store_false', dest='interactive', default=True,
- help='Do not prompt the user for input of any kind.'),
- )
-
- def print_if_verbose(self, text):
- "Only print if user chooses verbose output"
- if self.verbosity > 0:
- print text
-
-
- def handle_noargs(self, **options):
- self.verbosity = int(options.get("verbosity", 1))
- self.interactive = options.get("interactive")
-
- if self.interactive:
- answer = choice_dialog("This command will DELETE ALL DATA in the current database, fill the database with test data and flush the test data. Are you absolutely sure you want to proceed?",
- choices = ("yes", "no", ))
- if answer != "yes":
- return
-
- # First, flush the data
- self.print_if_verbose("FLUSHING THE DATABASE")
- management.call_command('flush', verbosity=0, interactive=False)
-
- # Then, fill the database with test content
- self.print_if_verbose("FILLING THE DB WITH TEST CONTENT")
- management.call_command('askbot_add_test_content', verbosity=0,
- interactive=False)
-
- # At last, dump the data into a fixture
- # Create a file object ready for writing
- self.print_if_verbose("DUMPING THE DATA IN FILE '%s'" % FIXTURE_NAME)
- fixture = open(FIXTURE_NAME, 'wb')
- management.call_command('dumpdata', stdout = fixture,
- exclude = EXCLUDE_APPS, indent = 4, natural = True)
- fixture.close()
-
- # FLUSH AGAIN
- self.print_if_verbose("FLUSHING THE DATABASE")
- management.call_command('flush', verbosity=0, interactive=False)
-
- self.print_if_verbose("You can load this data now by invoking ./manage.py %s" % FIXTURE_NAME)
-
-
diff --git a/askbot/management/commands/send_accept_answer_reminders.py b/askbot/management/commands/send_accept_answer_reminders.py
index 2b8b0851..eef74ca9 100644
--- a/askbot/management/commands/send_accept_answer_reminders.py
+++ b/askbot/management/commands/send_accept_answer_reminders.py
@@ -5,8 +5,8 @@ from django.template.loader import get_template
from askbot import models
from askbot import const
from askbot.conf import settings as askbot_settings
-from django.utils.translation import ugettext as _
-from django.utils.translation import ungettext
+from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import ungettext_lazy
from askbot import mail
from askbot.utils.classes import ReminderSchedule
from django.template import Context
diff --git a/askbot/management/commands/send_unanswered_question_reminders.py b/askbot/management/commands/send_unanswered_question_reminders.py
index 982dbafb..b91c043d 100644
--- a/askbot/management/commands/send_unanswered_question_reminders.py
+++ b/askbot/management/commands/send_unanswered_question_reminders.py
@@ -3,7 +3,7 @@ from django.template.loader import get_template
from askbot import models
from askbot import const
from askbot.conf import settings as askbot_settings
-from django.utils.translation import ungettext
+from django.utils.translation import ungettext_lazy
from askbot import mail
from askbot.utils.classes import ReminderSchedule
from askbot.models.question import Thread
@@ -62,7 +62,7 @@ class Command(NoArgsCommand):
threads = Thread.objects.filter(id__in=[qq.thread_id for qq in final_question_list])
tag_summary = Thread.objects.get_tag_summary_from_threads(threads)
- subject_line = ungettext(
+ subject_line = ungettext_lazy(
'%(question_count)d unanswered question about %(topics)s',
'%(question_count)d unanswered questions about %(topics)s',
question_count