]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/subscriptions.py
OSQA-240: adjusted wmd-preview to not be 100%, this seemed to cause it to run afoul...
[osqa.git] / forum / subscriptions.py
index e943d2d34de098f583a63465b76e4a0060c54100..45f430fb78e217ebf1692ab0ebb8d3604de8b273 100644 (file)
@@ -5,7 +5,7 @@ from forum.models import User, Question, Comment, QuestionSubscription, Subscrip
 from forum.utils.mail import send_email\r
 from django.utils.translation import ugettext as _\r
 from forum.actions import AskAction, AnswerAction, CommentAction, AcceptAnswerAction, UserJoinsAction, QuestionViewAction\r
-from django.conf import settings\r
+from forum import settings\r
 from django.db.models import Q, F\r
 \r
 def create_subscription_if_not_exists(question, user):\r
@@ -124,7 +124,7 @@ def answer_accepted(action, new):
             subscription_settings__enable_notifications=True,\r
             subscription_settings__notify_accepted=True,\r
             subscription_settings__subscribed_questions='i'\r
-    ).exclude(id=instance.accepted_by.id).distinct()\r
+    ).exclude(id=action.node.accepted.by.id).distinct()\r
     recipients = create_recipients_dict(subscribers)\r
 \r
     send_email(settings.EMAIL_SUBJECT_PREFIX + _("An answer to '%(question_title)s' was accepted") % dict(question_title=question.title),\r
@@ -144,7 +144,7 @@ def member_joined(action, new):
 \r
     recipients = create_recipients_dict(subscribers)\r
 \r
-    send_email(settings.EMAIL_SUBJECT_PREFIX + _("%(username)s is a new member on %(app_name)s") % dict(username=instance.username, app_name=settings.APP_SHORT_NAME),\r
+    send_email(settings.EMAIL_SUBJECT_PREFIX + _("%(username)s is a new member on %(app_name)s") % dict(username=action.user.username, app_name=settings.APP_SHORT_NAME),\r
                recipients, "notifications/newmember.html", {\r
         'newmember': action.user,\r
     }, threaded=False)\r
@@ -156,12 +156,12 @@ def question_viewed(action, new):
         return\r
 \r
     try:\r
-        subscription = QuestionSubscription.objects.get(question=action.question, user=action.viewuser)\r
+        subscription = QuestionSubscription.objects.get(question=action.node, user=action.viewuser)\r
         subscription.last_view = datetime.datetime.now()\r
         subscription.save()\r
     except:\r
         if action.viewuser.subscription_settings.questions_viewed:\r
-            subscription = QuestionSubscription(question=action.question, user=action.viewuser)\r
+            subscription = QuestionSubscription(question=action.node, user=action.viewuser)\r
             subscription.save()\r
 \r
 QuestionViewAction.hook(question_viewed)\r