def post(self, id=None): object_dict = self._get_request_body() task_id = object_dict.get(self.TASK_ID) message = object_dict.get(self.MESSAGE) is_from_customer = object_dict.get(self.IS_FROM_CUSTOMER) if is_from_customer: email = unicode("{}-{}-{}@{}").format( "sendjack", task_id, "comment", settings.MAILGUN_DOMAIN) redflag.send_email_from_jack( email, "SUBJECT", message) else: task_instance = TaskInstance.read(task_id) customer = Customer.read(task_instance.customer_id) full_name = customer.full_name email = customer.email recipient = unicode("{} <{}>").format( full_name, email) redflag.send_comment_on_task( self.JACK_SERVICE, task_id, recipient, message)
def add_comment(self, task_id, message): """Create a comment in the service on a task.""" # Get the runner_email from Task Rabbit using the task_id task_path = unicode("{}/{}").format( TASK_RABBIT.TASKS_PATH, str(task_id)) raw_task = self._get( TASK_RABBIT.PROTOCOL, TASK_RABBIT.DOMAIN, task_path) runner_email = raw_task.get(TASK_RABBIT_FIELD.RUNNER, {}).get( TASK_RABBIT_FIELD.EMAIL) # If successful, send the runner an email. if runner_email: redflag.send_comment_on_task( TASK_RABBIT.VENDOR_IN_HTML, task_id, runner_email, message) return True
def post(self, id=None): object_dict = self._get_request_body() task_id = object_dict.get(self.TASK_ID) message = object_dict.get(self.MESSAGE) is_from_customer = object_dict.get(self.IS_FROM_CUSTOMER) if is_from_customer: email = unicode("{}-{}-{}@{}").format("sendjack", task_id, "comment", settings.MAILGUN_DOMAIN) redflag.send_email_from_jack(email, "SUBJECT", message) else: task_instance = TaskInstance.read(task_id) customer = Customer.read(task_instance.customer_id) full_name = customer.full_name email = customer.email recipient = unicode("{} <{}>").format(full_name, email) redflag.send_comment_on_task(self.JACK_SERVICE, task_id, recipient, message)