def post(self, exploration_id): """Handles POST requests. Args: exploration_id: str. The ID of the exploration. """ moderator_services.enqueue_flag_exploration_email_task( exploration_id, self.payload.get('report_text'), self.user_id) self.render_json(self.values)
def test_that_flag_exploration_emails_are_correct(self): expected_email_html_body = ( 'Hello Moderator,<br>' 'newuser has flagged exploration "Title" on the following ' 'grounds: <br>' 'AD .<br>' 'You can modify the exploration by clicking ' '<a href="https://www.oppia.org/create/A">' 'here</a>.<br>' '<br>' 'Thanks!<br>' '- The Oppia Team<br>' '<br>' 'You can change your email preferences via the ' '<a href="http://localhost:8181/preferences">Preferences</a> page.') expected_email_text_body = ( 'Hello Moderator,\n' 'newuser has flagged exploration "Title" on the following ' 'grounds: \n' 'AD .\n' 'You can modify the exploration by clicking here.\n' '\n' 'Thanks!\n' '- The Oppia Team\n' '\n' 'You can change your email preferences via the Preferences page.') with self.can_send_emails_ctx: moderator_services.enqueue_flag_exploration_email_task( self.exploration.id, self.report_text, self.new_user_id) self.process_and_flush_pending_tasks() # Make sure correct email is sent. messages = self._get_sent_email_messages( self.MODERATOR_EMAIL) self.assertEqual(len(messages), 1) self.assertEqual( messages[0].html.decode(), expected_email_html_body) self.assertEqual( messages[0].body.decode(), expected_email_text_body)
def test_that_flag_exploration_emails_are_correct(self): expected_email_html_body = ( 'Hello Moderator,<br>' 'newuser has flagged exploration "Title" on the following ' 'grounds: <br>' 'AD .<br>' 'You can modify the exploration by clicking ' '<a href="https://www.oppia.org/create/A">' 'here</a>.<br>' '<br>' 'Thanks!<br>' '- The Oppia Team<br>' '<br>' 'You can change your email preferences via the ' '<a href="https://www.example.com">Preferences</a> page.') expected_email_text_body = ( 'Hello Moderator,\n' 'newuser has flagged exploration "Title" on the following ' 'grounds: \n' 'AD .\n' 'You can modify the exploration by clicking here.\n' '\n' 'Thanks!\n' '- The Oppia Team\n' '\n' 'You can change your email preferences via the Preferences page.') with self.can_send_emails_ctx: moderator_services.enqueue_flag_exploration_email_task( self.exploration.id, self.report_text, self.new_user_id) self.process_and_flush_pending_tasks() # Make sure correct email is sent. messages = self.mail_stub.get_sent_messages(to=self.MODERATOR_EMAIL) self.assertEqual(len(messages), 1) self.assertEqual( messages[0].html.decode(), expected_email_html_body) self.assertEqual( messages[0].body.decode(), expected_email_text_body)
def post(self, exploration_id): moderator_services.enqueue_flag_exploration_email_task( exploration_id, self.payload.get('report_text'), self.user_id) self.render_json(self.values)
def post(self, exploration_id): moderator_services.enqueue_flag_exploration_email_task( exploration_id, self.payload.get('report_text'), self.user_id) self.render_json(self.values)