Ejemplo n.º 1
0
def send_notif_new_session_organizer(user, event_name, link, session_id):
    """
    Send notification to the event organizer about a new session.
    :param user:
    :param event_name:
    :param link:
    :param session_id:
    :return:
    """
    message_settings = MessageSettings.query.filter_by(action=NEW_SESSION).first()
    if not message_settings or message_settings.notification_status == 1:
        actions = get_new_session_notification_actions(session_id, link)
        notification = NOTIFS[NEW_SESSION]
        title = notification['title'].format(event_name=event_name)
        message = notification['message'].format(event_name=event_name, link=link)

        send_notification(user, title, message, actions)
Ejemplo n.º 2
0
    def test_new_session_notification(self):
        """Method to test the actions associated with a notification of an event getting a new session proposal."""

        with self.app.test_request_context():
            request_url = 'https://localhost/e/session/345525'
            request_session_id = 1
            response = get_new_session_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)