required=False,
))
+DONT_NOTIFY_UNVALIDATED = Setting('DONT_NOTIFY_UNVALIDATED', True, USERS_SET, dict(
+label = _("Don't notify to invalid emails"),
+help_text = _("Do not notify users with unvalidated emails."),
+required=False))
+
HOLD_PENDING_POSTS_MINUTES = Setting('HOLD_PENDING_POSTS_MINUTES', 120, USERS_SET, dict(
label=_("Hold pending posts for X minutes"),
help_text=_("How much time in minutes a post should be kept in session until the user logs in or validates the email.")
subscription = QuestionSubscription(question=question, user=user)\r
subscription.save()\r
\r
+def filter_subscribers(subscribers):\r
+ subscribers = subscribers.exclude(is_active=False)\r
+\r
+ if settings.DONT_NOTIFY_UNVALIDATED:\r
+ return subscribers.exclude(email_isvalid=False)\r
+ else:\r
+ return subscribers\r
+\r
def question_posted(action, new):\r
question = action.node\r
\r
Q(tag_selections__reason='good'))\r
).exclude(id=question.author.id).distinct()\r
\r
+ subscribers = filter_subscribers(subscribers)\r
+\r
send_template_email(subscribers, "notifications/newquestion.html", {'question': question})\r
\r
if question.author.subscription_settings.questions_asked:\r
subscription_settings__subscribed_questions='i'\r
).exclude(id=answer.author.id).distinct()\r
\r
+ subscribers = filter_subscribers(subscribers)\r
+\r
send_template_email(subscribers, "notifications/newanswer.html", {'answer': answer})\r
\r
if answer.author.subscription_settings.questions_answered:\r
q_filter, subscription_settings__subscribed_questions='i', subscription_settings__enable_notifications=True\r
).exclude(id=comment.user.id).distinct()\r
\r
+ subscribers = filter_subscribers(subscribers)\r
+\r
\r
send_template_email(subscribers, "notifications/newcomment.html", {'comment': comment})\r
\r
subscription_settings__subscribed_questions='i'\r
).exclude(id=action.node.nstate.accepted.by.id).distinct()\r
\r
+ subscribers = filter_subscribers(subscribers)\r
+\r
send_template_email(subscribers, "notifications/answeraccepted.html", {'answer': action.node})\r
\r
AcceptAnswerAction.hook(answer_accepted)\r
subscription_settings__member_joins='i'\r
).exclude(id=action.user.id).distinct()\r
\r
+ subscribers = filter_subscribers(subscribers)\r
+\r
send_template_email(subscribers, "notifications/newmember.html", {'newmember': action.user})\r
\r
UserJoinsAction.hook(member_joined)\r