diff options
-rw-r--r-- | askbot/conf/email.py | 87 | ||||
-rw-r--r-- | askbot/forms.py | 2 | ||||
-rw-r--r-- | askbot/management/commands/add_askbot_user.py | 30 | ||||
-rw-r--r-- | askbot/models/__init__.py | 5 | ||||
-rw-r--r-- | askbot/setup_templates/settings.py | 3 | ||||
-rw-r--r-- | askbot/skins/loaders.py | 8 | ||||
-rw-r--r-- | askbot/startup_procedures.py | 13 | ||||
-rw-r--r-- | askbot/tests/email_alert_tests.py | 2 |
8 files changed, 121 insertions, 29 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/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..64d14072 100644 --- a/askbot/skins/loaders.py +++ b/askbot/skins/loaders.py @@ -22,9 +22,11 @@ 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 """ + if dirs is None: dirs = (ASKBOT_SKIN_COLLECTION_DIR, ) else: @@ -37,7 +39,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 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() 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): |