From 1f2e789675ec471ecbaad32617eed1bb816e237b Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Fri, 30 Sep 2011 17:16:37 -0300 Subject: Fixed bug 97: UserWarning: Cannot translate loader --- askbot/setup_templates/settings.py | 3 ++- askbot/skins/loaders.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/askbot/setup_templates/settings.py b/askbot/setup_templates/settings.py index feb7a2a2..a97402aa 100644 --- a/askbot/setup_templates/settings.py +++ b/askbot/setup_templates/settings.py @@ -85,7 +85,8 @@ TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', #below is askbot stuff for this tuple - 'askbot.skins.loaders.load_template_source', + #'askbot.skins.loaders.load_template_source', #changed due to bug 97 + 'askbot.skins.loaders.filesystem_load_template_source', #'django.template.loaders.eggs.load_template_source', ) diff --git a/askbot/skins/loaders.py b/askbot/skins/loaders.py index bed1e9da..36fb5af2 100644 --- a/askbot/skins/loaders.py +++ b/askbot/skins/loaders.py @@ -22,9 +22,13 @@ template.add_to_builtins('askbot.templatetags.extra_filters_jinja') #here it is ignored because it is assumed that we won't use unicode paths ASKBOT_SKIN_COLLECTION_DIR = os.path.dirname(__file__) -def load_template_source(name, dirs=None): +#changed the name from load_template_source +def filesystem_load_template_source(name, dirs=None): """Django template loader """ + + import pdb + pdb.set_trace() if dirs is None: dirs = (ASKBOT_SKIN_COLLECTION_DIR, ) else: @@ -37,7 +41,9 @@ def load_template_source(name, dirs=None): except: tname = os.path.join('default','templates',name) return filesystem.load_template_source(tname,dirs) -load_template_source.is_usable = True +filesystem_load_template_source.is_usable = True +#added this for backward compatbility +load_template_source = filesystem_load_template_source class SkinEnvironment(CoffinEnvironment): """Jinja template environment -- cgit v1.2.3-1-g7c22 From f9c1b77001f7303ee5f20be82955bb8ea0429fdf Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Mon, 3 Oct 2011 14:55:20 -0300 Subject: added startup test --- askbot/startup_procedures.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py index cc7f86c0..e8dec45f 100644 --- a/askbot/startup_procedures.py +++ b/askbot/startup_procedures.py @@ -172,12 +172,25 @@ def test_encoding(): 'to the terminal or log files' ) +def test_template_loader(): + """Sends a warning if you have an old style template + loader that used to send a warning""" + old_template_loader = 'askbot.skins.loaders.load_template_source' + if old_template_loader in django_settings.TEMPLATE_LOADERS: + askbot_warning( + 'In TEMPLATE_LOADERS settings you have an old style ' + 'template loader that throws a Warning on logs ' + 'please change: askbot.skins.loaders.load_template_source ' + 'for: askbot.skins.loaders.filesystem_load_template_source' + ) + def run_startup_tests(): """function that runs all startup tests, mainly checking settings config so far """ #todo: refactor this when another test arrives + test_template_loader() test_encoding() test_modules() test_askbot_url() -- cgit v1.2.3-1-g7c22 From 5617b30162857b9179bad090a39e8c1ef239508b Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Mon, 3 Oct 2011 16:42:10 -0300 Subject: deleted pdb statements --- askbot/skins/loaders.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/askbot/skins/loaders.py b/askbot/skins/loaders.py index 36fb5af2..64d14072 100644 --- a/askbot/skins/loaders.py +++ b/askbot/skins/loaders.py @@ -27,8 +27,6 @@ def filesystem_load_template_source(name, dirs=None): """Django template loader """ - import pdb - pdb.set_trace() if dirs is None: dirs = (ASKBOT_SKIN_COLLECTION_DIR, ) else: -- cgit v1.2.3-1-g7c22 From bfdaa85311e23a579470068e1c19e94e04a503b0 Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Wed, 5 Oct 2011 11:49:34 -0300 Subject: Fixes issue 73: Added entries into livesettings, modified tests to make it work. --- askbot/conf/email.py | 87 ++++++++++++++++++++++++--- askbot/forms.py | 2 +- askbot/management/commands/add_askbot_user.py | 30 ++++----- askbot/models/__init__.py | 5 +- askbot/tests/email_alert_tests.py | 2 +- 5 files changed, 100 insertions(+), 26 deletions(-) diff --git a/askbot/conf/email.py b/askbot/conf/email.py index 5ef6b866..5402cad0 100644 --- a/askbot/conf/email.py +++ b/askbot/conf/email.py @@ -37,19 +37,92 @@ settings.register( ) ) +#settings.register( +# livesettings.StringValue( +# EMAIL, +# 'DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE', +# default='w', +# choices=const.NOTIFICATION_DELIVERY_SCHEDULE_CHOICES, +# description=_('Default news notification frequency'), +# help_text=_( +# 'This option currently defines default frequency ' +# 'of emailed updates in the following five categories: ' +# 'questions asked by user, answered by user, individually ' +# 'selected, entire forum (per person tag filter applies) ' +# 'and posts mentioning the user and comment responses' +# ) +# ) +#) + + +settings.register( + livesettings.StringValue( + EMAIL, + 'DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE_Q_ALL', + default='w', + choices=const.NOTIFICATION_DELIVERY_SCHEDULE_CHOICES, + description=_('Default notification frequency all questions'), + help_text=_( + 'Option to define frequency of emailed updates for: ' + 'all questions.' + ) + ) +) + +settings.register( + livesettings.StringValue( + EMAIL, + 'DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE_Q_ASK', + default='w', + choices=const.NOTIFICATION_DELIVERY_SCHEDULE_CHOICES, + description=_('Default notification frequency questions asked by the user'), + help_text=_( + 'Option to define frequency of emailed updates for: ' + 'Question asked by the user.' + ) + ) +) + +settings.register( + livesettings.StringValue( + EMAIL, + 'DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE_Q_ANS', + default='w', + choices=const.NOTIFICATION_DELIVERY_SCHEDULE_CHOICES, + description=_('Default notification frequency questions answered by the user'), + help_text=_( + 'Option to define frequency of emailed updates for: ' + 'Question answered by the user.' + ) + ) +) + +settings.register( + livesettings.StringValue( + EMAIL, + 'DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE_Q_SEL', + default='w', + choices=const.NOTIFICATION_DELIVERY_SCHEDULE_CHOICES, + description=_('Default notification frequency questions individually \ + selected by the user'), + help_text=_( + 'Option to define frequency of emailed updates for: ' + 'Question individually selected by the user.' + ) + ) +) + settings.register( livesettings.StringValue( EMAIL, - 'DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE', + 'DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE_M_AND_C', default='w', choices=const.NOTIFICATION_DELIVERY_SCHEDULE_CHOICES, - description=_('Default news notification frequency'), + description=_('Default notification frequency for mentions \ + and comments'), help_text=_( - 'This option currently defines default frequency ' - 'of emailed updates in the following five categories: ' - 'questions asked by user, answered by user, individually ' - 'selected, entire forum (per person tag filter applies) ' - 'and posts mentioning the user and comment responses' + 'Option to define frequency of emailed updates for: ' + 'Mentions and comments.' ) ) ) diff --git a/askbot/forms.py b/askbot/forms.py index afef2cc5..b0517cce 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -962,7 +962,7 @@ class TagFilterSelectionForm(forms.ModelForm): class EmailFeedSettingField(forms.ChoiceField): def __init__(self, *arg, **kwarg): kwarg['choices'] = const.NOTIFICATION_DELIVERY_SCHEDULE_CHOICES - kwarg['initial'] = askbot_settings.DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE + #kwarg['initial'] = askbot_settings.DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE kwarg['widget'] = forms.RadioSelect super(EmailFeedSettingField, self).__init__(*arg, **kwarg) diff --git a/askbot/management/commands/add_askbot_user.py b/askbot/management/commands/add_askbot_user.py index 0b8fd02b..bac18a58 100644 --- a/askbot/management/commands/add_askbot_user.py +++ b/askbot/management/commands/add_askbot_user.py @@ -40,7 +40,7 @@ class Command(BaseCommand): action = 'store', type = 'str', dest = 'frequency', - default = 'w', + default = None, help = 'email subscription frequency (n - never, i - ' 'instant, d - daily, w - weekly, default - w)' ), @@ -62,22 +62,22 @@ class Command(BaseCommand): username = options['username'] frequency = options['frequency'] - if frequency not in ('i', 'd', 'w', 'n'): - raise CommandError( - 'value of --frequency must be one of: ' - 'i, d, w, n' - ) - user = models.User.objects.create_user(username, email) if password: user.set_password(password) user.save() subscription = {'subscribe': 'y'} - email_feeds_form = forms.SimpleEmailSubscribeForm( - subscription, - frequency = frequency - ) - if email_feeds_form.is_valid(): - email_feeds_form.save(user) - else: - raise CommandError('\n'.join(email_feeds_form.errors)) + if frequency in ('i', 'd', 'w', 'n'): + email_feeds_form = forms.SimpleEmailSubscribeForm( + subscription, + frequency = frequency + ) + if email_feeds_form.is_valid(): + email_feeds_form.save(user) + else: + raise CommandError('\n'.join(email_feeds_form.errors)) + elif frequency is not None: + raise CommandError( + 'value of --frequency must be one of: ' + 'i, d, w, n' + ) diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index 17723ce5..e1677d9f 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -1452,12 +1452,13 @@ def user_add_missing_askbot_subscriptions(self): 'feed_type', flat = True ) missing_feed_types = set(need_feed_types) - set(have_feed_types) - frequency = askbot_settings.DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE for missing_feed_type in missing_feed_types: + attr_key = 'DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE_%s' % missing_feed_type.upper() + freq = getattr(askbot_settings, attr_key) feed_setting = EmailFeedSetting( subscriber = self, feed_type = missing_feed_type, - frequency = frequency + frequency = freq ) feed_setting.save() diff --git a/askbot/tests/email_alert_tests.py b/askbot/tests/email_alert_tests.py index 1fbe3bf5..dcea2e54 100644 --- a/askbot/tests/email_alert_tests.py +++ b/askbot/tests/email_alert_tests.py @@ -893,7 +893,7 @@ class EmailFeedSettingTests(utils.AskbotTestCase): self.assertEquals( feed.frequency, - askbot_settings.DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE + askbot_settings.DEFAULT_NOTIFICATION_DELIVERY_SCHEDULE_Q_ALL ) def test_missing_subscriptions_added_automatically(self): -- cgit v1.2.3-1-g7c22 From 1000a45fc2da936523bfcc4744076c6832d754aa Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Fri, 7 Oct 2011 14:48:56 -0300 Subject: fixed bug produced by form --- askbot/forms.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/askbot/forms.py b/askbot/forms.py index b0517cce..0769f180 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -1092,7 +1092,6 @@ class SimpleEmailSubscribeForm(forms.Form): ) def __init__(self, *args, **kwargs): - self.frequency = kwargs.pop('frequency', 'w') super(SimpleEmailSubscribeForm, self).__init__(*args, **kwargs) def save(self, user=None): @@ -1101,7 +1100,7 @@ class SimpleEmailSubscribeForm(forms.Form): #with the frequency variable - needs to be fixed if self.is_bound and self.cleaned_data['subscribe'] == 'y': email_settings_form = EFF() - email_settings_form.set_frequency(self.frequency) + email_settings_form.set_initial_values(user) logging.debug('%s wants to subscribe' % user.username) else: email_settings_form = EFF(initial=EFF.NO_EMAIL_INITIAL) -- cgit v1.2.3-1-g7c22 From a76a247052c99d074ed45d277a9a3a120f71e9b0 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Fri, 7 Oct 2011 18:05:15 -0300 Subject: fixed exception, but still have failure of test case askbot.tests.ManagementCommandTests --- askbot/doc/source/management-commands.rst | 7 ++----- askbot/management/commands/add_askbot_user.py | 19 +++++-------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/askbot/doc/source/management-commands.rst b/askbot/doc/source/management-commands.rst index bc32dbc2..1da3fdee 100644 --- a/askbot/doc/source/management-commands.rst +++ b/askbot/doc/source/management-commands.rst @@ -29,11 +29,8 @@ The bulk of the management commands fall into this group and will probably be th | | the `add_admin` command | +---------------------------------+-------------------------------------------------------------+ | `add_askbot_user --user-name | Create a user account. If password is not given, an | -| --email [--password] | unusable password will be set. Possible values for the | -| [--email-frequency]` | --email-frequency are: **i**, **d**, **w**, **n** | -| | that stand for | -| | instant, daily, weekly and never - respectively. The default| -| | value is w. The command does not create associations with | +| --email [--password] | unusable password will be set. | +| | The command does not create associations with | | | any of the external login providers. | +---------------------------------+-------------------------------------------------------------+ | `dump_forum [--dump-name | Save forum contents into a file. `--dump-name` parameter is | diff --git a/askbot/management/commands/add_askbot_user.py b/askbot/management/commands/add_askbot_user.py index bac18a58..ed6e2b8b 100644 --- a/askbot/management/commands/add_askbot_user.py +++ b/askbot/management/commands/add_askbot_user.py @@ -67,17 +67,8 @@ class Command(BaseCommand): user.set_password(password) user.save() subscription = {'subscribe': 'y'} - if frequency in ('i', 'd', 'w', 'n'): - email_feeds_form = forms.SimpleEmailSubscribeForm( - subscription, - frequency = frequency - ) - if email_feeds_form.is_valid(): - email_feeds_form.save(user) - else: - raise CommandError('\n'.join(email_feeds_form.errors)) - elif frequency is not None: - raise CommandError( - 'value of --frequency must be one of: ' - 'i, d, w, n' - ) + email_feeds_form = forms.SimpleEmailSubscribeForm(subscription) + if email_feeds_form.is_valid(): + email_feeds_form.save(user) + else: + raise CommandError('\n'.join(email_feeds_form.errors)) -- cgit v1.2.3-1-g7c22 From 03fa3dbdff9c72e2b5b537548b3ef9716447b7c6 Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Tue, 11 Oct 2011 11:38:08 -0300 Subject: fixed management_command_test according to changes in feature73 --- askbot/tests/management_command_tests.py | 1 - 1 file changed, 1 deletion(-) diff --git a/askbot/tests/management_command_tests.py b/askbot/tests/management_command_tests.py index 41a42a91..9eb41cdf 100644 --- a/askbot/tests/management_command_tests.py +++ b/askbot/tests/management_command_tests.py @@ -21,7 +21,6 @@ class ManagementCommandTests(AskbotTestCase): #check thath subscrptions are correct subs = models.EmailFeedSetting.objects.filter( subscriber = user, - frequency = 'd' ) self.assertEquals(subs.count(), 5) #try to log in -- cgit v1.2.3-1-g7c22