summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdolfo Fitoria <adolfo.fitoria@gmail.com>2011-10-07 10:35:23 -0300
committerAdolfo Fitoria <adolfo.fitoria@gmail.com>2011-10-07 10:35:23 -0300
commit894650d8ade55731bfa995d4a08a7f5790d53ded (patch)
tree0c27e9bd5b29e33aa09d8b3caa616ff3a416a72c
parent68829269827ec4558fb04d1edf24c309f4a07ba1 (diff)
parenta063a2f13ef8bbf340af5d722d63c7a64743cac4 (diff)
downloadaskbot-894650d8ade55731bfa995d4a08a7f5790d53ded.tar.gz
askbot-894650d8ade55731bfa995d4a08a7f5790d53ded.tar.bz2
askbot-894650d8ade55731bfa995d4a08a7f5790d53ded.zip
Merge branch 'feature73'
-rw-r--r--askbot/conf/email.py87
-rw-r--r--askbot/forms.py2
-rw-r--r--askbot/management/commands/add_askbot_user.py30
-rw-r--r--askbot/models/__init__.py5
-rw-r--r--askbot/tests/email_alert_tests.py2
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):