Skip to content

Instantly share code, notes, and snippets.

@jdm
Created June 28, 2013 17:39
Show Gist options
  • Save jdm/5886540 to your computer and use it in GitHub Desktop.
Save jdm/5886540 to your computer and use it in GitHub Desktop.
diff --git a/vendor/src/django-mobility b/vendor/src/django-mobility
[jdm@rosencrantz kitsune]$ git diff
diff --git a/kitsune/questions/models.py b/kitsune/questions/models.py
index c4a6d70..20f0150 100755
--- a/kitsune/questions/models.py
+++ b/kitsune/questions/models.py
@@ -49,6 +49,15 @@ log = logging.getLogger('k.questions')
CACHE_TIMEOUT = 10800 # 3 hours
+# Default RabbitMQ host settings are as defined in the accompanying
+# vagrant puppet files.
+DEFAULT_RABBIT_HOST = '192.168.33.10'
+DEFAULT_RABBIT_PORT = 5672
+DEFAULT_RABBIT_VHOST = 'pulse'
+DEFAULT_RABBIT_USER = 'pulse'
+DEFAULT_RABBIT_PASSWORD = 'pulse'
+
+
class Question(ModelBase, BigVocabTaggableMixin, SearchMixin):
"""A support question."""
title = models.CharField(max_length=255)
@@ -638,6 +647,28 @@ class Answer(ModelBase):
from kitsune.questions.events import QuestionReplyEvent
QuestionReplyEvent(self).fire(exclude=self.creator)
+ from mozillapulse.messages.sumo import SUMOAnswerMessage
+ from mozillapulse.publishers import SUMOPublisher
+ publisher = SUMOPublisher(host=DEFAULT_RABBIT_HOST,
+ port=DEFAULT_RABBIT_PORT,
+ vhost=DEFAULT_RABBIT_VHOST,
+ user=DEFAULT_RABBIT_USER,
+ password=DEFAULT_RABBIT_PASSWORD)
+
+ pulsemsg = SUMOAnswerMessage()
+ nowtuple = self.created.timetuple()
+ nowtimestamp = time.mktime(nowtuple)
+ from email import utils
+ pulsemsg.set_data('when', utils.formatdate(nowtimestamp))
+ pulsemsg.set_data('who', self.creator.email)
+ pulsemsg.set_data('question', self.question.id)
+ pulsemsg.set_data('id', self.id)
+ try:
+ publisher.publish(pulsemsg)
+ except:
+ #XXX handle stuff
+ pass
+
def delete(self, *args, **kwargs):
"""Override delete method to update parent question info."""
question = Question.uncached.get(pk=self.question.id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment