import datetime\r
from forum.models import User, Question, Comment, QuestionSubscription, SubscriptionSettings, Answer\r
from forum.models.user import activity_record\r
+from forum.models.node import node_create\r
from forum.utils.mail import send_email\r
from forum.views.readers import question_view\r
from django.utils.translation import ugettext as _\r
def create_recipients_dict(usr_list):\r
return [(s['username'], s['email'], {'username': s['username']}) for s in usr_list]\r
\r
-def question_posted(instance, created, **kwargs):\r
- if not created: return\r
-\r
+def question_posted(instance, **kwargs):\r
question = instance\r
\r
subscribers = User.objects.values('email', 'username').filter(\r
for user in new_subscribers:\r
create_subscription_if_not_exists(question, user)\r
\r
-#post_save.connect(question_posted, sender=Question)\r
-\r
+node_create.connect(question_posted, sender=Question)\r
\r
-def answer_posted(instance, created, **kwargs):\r
- if not created: return\r
\r
+def answer_posted(instance, **kwargs):\r
answer = instance\r
question = answer.question\r
\r
if answer.author.subscription_settings.questions_answered:\r
create_subscription_if_not_exists(question, answer.author)\r
\r
-post_save.connect(answer_posted, sender=Answer)\r
+node_create.connect(answer_posted, sender=Answer)\r
\r
\r
-def comment_posted(sender, instance, **kwargs):\r
- comment = instance.content_object\r
+def comment_posted(instance, **kwargs):\r
+ comment = instance\r
post = comment.content_object\r
\r
if post.__class__ == Question:\r
)\r
\r
subscribers = subscribers.filter(\r
- q_filter, subscription_settings__subscribed_questions='i', subscription_settings__enable_notifications=True \r
+ q_filter, subscription_settings__subscribed_questions='i', subscription_settings__enable_notifications=True\r
).exclude(id=comment.user.id).distinct()\r
\r
recipients = create_recipients_dict(subscribers)\r
if comment.user.subscription_settings.questions_commented:\r
create_subscription_if_not_exists(question, comment.user)\r
\r
-activity_record.connect(comment_posted, sender=const.TYPE_ACTIVITY_COMMENT_QUESTION, weak=False)\r
-activity_record.connect(comment_posted, sender=const.TYPE_ACTIVITY_COMMENT_ANSWER, weak=False)\r
+node_create.connect(comment_posted, sender=Comment)\r
\r
\r
def answer_accepted(instance, created, **kwargs):\r