def send_notif_monthly_fee_payment(user,
                                   event_name,
                                   previous_month,
                                   amount,
                                   app_name,
                                   link,
                                   event_id,
                                   follow_up=False):
    """
    Send notification about monthly fee payments.
    :param user:
    :param event_name:
    :param previous_month:
    :param amount:
    :param app_name:
    :param link:
    :param event_id:
    :return:
    """
    key = MONTHLY_PAYMENT_FOLLOWUP_NOTIF if follow_up else MONTHLY_PAYMENT_NOTIF
    message_settings = MessageSettings.query.filter_by(action=key).first()
    if not message_settings or message_settings.notification_status == 1:
        actions = get_monthly_payment_notification_actions(event_id, link)
        notification = NOTIFS[key]
        title = notification['subject'].format(date=previous_month,
                                               event_name=event_name)
        message = notification['message'].format(
            event_name=event_name,
            date=previous_month,
            amount=amount,
            app_name=app_name,
        )

        send_notification(user, title, message, actions)
def send_notif_monthly_fee_payment(user, event_name, previous_month, amount, app_name, link, event_id):
    """
    Send notification about monthly fee payments.
    :param user:
    :param event_name:
    :param previous_month:
    :param amount:
    :param app_name:
    :param link:
    :param event_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_monthly_payment_notification_actions(event_id, link)
        notification = NOTIFS[MONTHLY_PAYMENT_NOTIF]
        title = notification['title'].format(date=previous_month,
                                             event_name=event_name)
        message = notification['message'].format(
            event_name=event_name,
            date=previous_month,
            amount=amount,
            app_name=app_name,
        )

        send_notification(user, title, message, actions)
def send_notif_monthly_fee_payment(user, event_name, previous_month, amount,
                                   app_name, link, event_id):
    """
    Send notification about monthly fee payments.
    :param user:
    :param event_name:
    :param previous_month:
    :param amount:
    :param app_name:
    :param link:
    :param event_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_monthly_payment_notification_actions(event_id, link)
        notification = NOTIFS[MONTHLY_PAYMENT_NOTIF]
        title = notification['title'].format(date=previous_month,
                                             event_name=event_name)
        message = notification['message'].format(
            event_name=event_name,
            date=previous_month,
            amount=amount,
            app_name=app_name,
        )

        send_notification(user, title, message, actions)
Example #4
0
    def test_monthly_payment_notification(self):
        """Method to test the actions associated with a notification of monthly payments"""

        with self.app.test_request_context():
            request_url = 'https://localhost/e/345525/payment'
            request_event_id = 1
            response = get_monthly_payment_notification_actions(
                request_event_id, request_url)
            expected_action = NotificationAction(subject='event',
                                                 link=request_url,
                                                 subject_id=request_event_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)