summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-10-12 10:33:04 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-10-12 10:33:04 -0300
commit64cf5d12cd1c8bc14f29d96f1247b9993d5af7f6 (patch)
tree34ccfa8aebd016b64820315887f3215110cc630b
parent5508c894105d07f9e8e032818bd6dfb165482ce6 (diff)
parent03fa3dbdff9c72e2b5b537548b3ef9716447b7c6 (diff)
downloadaskbot-64cf5d12cd1c8bc14f29d96f1247b9993d5af7f6.tar.gz
askbot-64cf5d12cd1c8bc14f29d96f1247b9993d5af7f6.tar.bz2
askbot-64cf5d12cd1c8bc14f29d96f1247b9993d5af7f6.zip
Merge branch 'feature73'
-rw-r--r--askbot/conf/email.py87
-rw-r--r--askbot/doc/source/management-commands.rst7
-rw-r--r--askbot/forms.py5
-rw-r--r--askbot/management/commands/add_askbot_user.py13
-rw-r--r--askbot/models/__init__.py5
-rw-r--r--askbot/setup_templates/settings.py3
-rw-r--r--askbot/skins/loaders.py8
-rw-r--r--askbot/startup_procedures.py13
-rw-r--r--askbot/tests/email_alert_tests.py2
-rw-r--r--askbot/tests/management_command_tests.py1
10 files changed, 111 insertions, 33 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/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/forms.py b/askbot/forms.py
index afef2cc5..0769f180 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)
@@ -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)
diff --git a/askbot/management/commands/add_askbot_user.py b/askbot/management/commands/add_askbot_user.py
index 0b8fd02b..ed6e2b8b 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,21 +62,12 @@ 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
- )
+ email_feeds_form = forms.SimpleEmailSubscribeForm(subscription)
if email_feeds_form.is_valid():
email_feeds_form.save(user)
else:
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):
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