X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/61486d20fd5bf0a187868e3997ca7cdabe8acde7..22236fb67da2f27ceb35ad138f4d534a4fd08251:/forum/subscriptions.py?ds=inline diff --git a/forum/subscriptions.py b/forum/subscriptions.py index 7a5bf06..e897e4e 100644 --- a/forum/subscriptions.py +++ b/forum/subscriptions.py @@ -1,6 +1,7 @@ import os import re import datetime +import logging from forum.models import User, Question, Comment, QuestionSubscription, SubscriptionSettings, Answer from forum.utils.mail import send_template_email from django.utils.translation import ugettext as _ @@ -37,9 +38,8 @@ def question_posted(action, new): send_template_email(subscribers, "notifications/newquestion.html", {'question': question}) - if question.author.subscription_settings.questions_asked: - subscription = QuestionSubscription(question=question, user=question.author) - subscription.save() + subscription = QuestionSubscription(question=question, user=question.author) + subscription.save() new_subscribers = User.objects.filter( Q(subscription_settings__all_questions=True) | @@ -67,8 +67,7 @@ def answer_posted(action, new): send_template_email(subscribers, "notifications/newanswer.html", {'answer': answer}) - if answer.author.subscription_settings.questions_answered: - create_subscription_if_not_exists(question, answer.author) + create_subscription_if_not_exists(question, answer.author) AnswerAction.hook(answer_posted) @@ -99,8 +98,7 @@ def comment_posted(action, new): send_template_email(subscribers, "notifications/newcomment.html", {'comment': comment}) - if comment.user.subscription_settings.questions_commented: - create_subscription_if_not_exists(question, comment.user) + create_subscription_if_not_exists(question, comment.user) CommentAction.hook(comment_posted) @@ -110,10 +108,9 @@ def answer_accepted(action, new): subscribers = question.subscribers.filter( subscription_settings__enable_notifications=True, - subscription_settings__notify_accepted=True, subscription_settings__subscribed_questions='i' ).exclude(id=action.node.nstate.accepted.by.id).distinct() - + subscribers = filter_subscribers(subscribers) send_template_email(subscribers, "notifications/answeraccepted.html", {'answer': action.node}) @@ -176,4 +173,4 @@ QuestionViewAction.hook(question_viewed) # # q_author.message_set.create(message=msg) # -#post_save.connect(record_answer_event, sender=Answer) \ No newline at end of file +#post_save.connect(record_answer_event, sender=Answer)