def after_create_object(self, role_invite, data, view_kwargs):
        """
        after create object method for role invite links
        :param role_invite:
        :param data:
        :param view_kwargs:
        :return:
        """
        user = User.query.filter_by(email=role_invite.email).first()
        if 'status' in data and data['status'] == 'accepted':
            role = Role.query.filter_by(name=role_invite.role_name).first()
            event = Event.query.filter_by(id=role_invite.event_id).first()
            uer = UsersEventsRoles.query.filter_by(user=user).filter_by(
                event=event).filter_by(role=role).first()
            if not uer:
                uer = UsersEventsRoles(user, event, role)
                save_to_db(uer, 'Role Invite accepted')

        event = Event.query.filter_by(id=role_invite.event_id).first()
        frontend_url = get_settings()['frontend_url']
        link = "{}/events/{}/role-invites/{}" \
            .format(frontend_url, event.id, role_invite.hash)

        send_email_role_invite(role_invite.email, role_invite.role_name, event.name, link)
        if user:
            send_notif_event_role(user, role_invite.role_name, event.name, link, event.id)
Ejemplo n.º 2
0
    def after_create_object(self, role_invite, data, view_kwargs):
        """
        after create object method for role invite links
        :param role_invite:
        :param data:
        :param view_kwargs:
        :return:
        """
        user = User.query.filter_by(email=role_invite.email).first()
        if 'status' in data and data['status'] == 'accepted':
            role = Role.query.filter_by(name=role_invite.role_name).first()
            event = Event.query.filter_by(id=role_invite.event_id).first()
            uer = UsersEventsRoles.query.filter_by(user=user).filter_by(
                event=event).filter_by(role=role).first()
            if not uer:
                uer = UsersEventsRoles(user, event, role)
                save_to_db(uer, 'Role Invite accepted')

        event = Event.query.filter_by(id=role_invite.event_id).first()
        frontend_url = get_settings()['frontend_url']
        link = "{}/events/{}/role-invites/{}" \
            .format(frontend_url, event.id, role_invite.hash)

        send_email_role_invite(role_invite.email, role_invite.role_name,
                               event.name, link)
        if user:
            send_notif_event_role(user, role_invite.role_name, event.name,
                                  link)
def test_send_notif_event_role(user):
    """Method to test event role invite notification"""
    send_notif_event_role(user, 'Dinosaur', 'Mass Extinction', link, 1)
    notification = Notification.query.first()
    assert notification.title == 'Invitation to be Dinosaur at Mass Extinction'
    assert (
        notification.message ==
        "You've been invited to be one of the <strong>Dinosaurs</strong> at <strong>Mass Extinction</strong>."
    )
Ejemplo n.º 4
0
    def after_create_object(self, role_invite, data, view_kwargs):
        """
        after create object method for role invite links
        :param role_invite:
        :param data:
        :param view_kwargs:
        :return:
        """
        user = User.query.filter_by(email=role_invite.email).first()
        event = Event.query.filter_by(id=role_invite.event_id).first()
        frontend_url = get_settings()['frontend_url']
        link = "{}/e/{}/role-invites?token={}" \
            .format(frontend_url, event.identifier, role_invite.hash)

        send_email_role_invite(role_invite.email, role_invite.role_name, event.name, link)
        if user:
            send_notif_event_role(user, role_invite.role_name, event.name, link, event.id)