示例#1
0
    def test_session_accept_reject_notif(self):
        """Method to test the actions associated with a notification of a session getting accepted/rejected."""

        with self.app.test_request_context():
            request_url = 'https://localhost/e/session/345525'
            request_session_id = 1
            response = get_session_accept_reject_notification_actions(
                request_session_id, request_url)
            expected_action = NotificationAction(subject='session',
                                                 link=request_url,
                                                 subject_id=request_session_id,
                                                 action_type='view')
            expected_action = [expected_action]
            expected_length = len(expected_action)
            response_length = len(response)
            self.assertIsInstance(response, list)
            self.assertEqual(expected_action[0].subject, response[0].subject)
            self.assertEqual(expected_length, response_length)
示例#2
0
def send_notif_session_accept_reject(user, session_name, acceptance, link, session_id):
    """
    Send notification to the session creator about a session being accepted or rejected.
    :param user:
    :param session_name:
    :param acceptance:
    :param link:
    :param session_id:
    :return:
    """
    message_settings = MessageSettings.query.filter_by(action=SESSION_ACCEPT_REJECT).first()
    if not message_settings or message_settings.notification_status == 1:
        actions = get_session_accept_reject_notification_actions(session_id, link)
        notification = NOTIFS[SESSION_ACCEPT_REJECT]
        title = notification['title'].format(session_name=session_name,
                                             acceptance=acceptance)
        message = notification['message'].format(
            session_name=session_name,
            acceptance=acceptance
        )

        send_notification(user, title, message, actions)