Example #1
0
    def notify_admin(user, invitation_id, membership_id, invitation_origin):
        """Admins should be notified if user has responded to invitation."""
        current_app.logger.debug('<notify_admin')
        admin_list = UserService.get_admins_for_membership(membership_id)
        invitation: InvitationModel = InvitationModel.find_invitation_by_id(
            invitation_id)
        context_path = CONFIG.AUTH_WEB_TOKEN_CONFIRM_PATH

        # Don't send email in case no admin exist in the org. (staff sent invitation)
        if len(admin_list) >= 1:
            admin_emails = ','.join([
                str(x.contacts[0].contact.email) for x in admin_list
                if x.contacts
            ])
        else:
            # No admin, find Sender email to notify sender (staff)
            admin_emails = invitation.sender.email

        if admin_emails != '':
            Invitation.send_admin_notification(
                user.as_dict(), '{}/{}'.format(invitation_origin,
                                               context_path), admin_emails,
                invitation.membership[0].org.name,
                invitation.membership[0].org.id)
            current_app.logger.debug('>notify_admin')

        return Invitation(invitation)
Example #2
0
 def notify_admin(user, invitation_id, membership_id, invitation_origin):
     """Admins should be notified if user has responded to invitation."""
     current_app.logger.debug('<notify_admin')
     admin_list = UserService.get_admins_for_membership(membership_id)
     invitation: InvitationModel = InvitationModel.find_invitation_by_id(invitation_id)
     context_path = CONFIG.AUTH_WEB_TOKEN_CONFIRM_PATH
     admin_emails = ','.join([str(x.contacts[0].contact.email) for x in admin_list if x.contacts])
     Invitation.send_admin_notification(user.as_dict(),
                                        '{}/{}'.format(invitation_origin, context_path),
                                        admin_emails, invitation.membership[0].org.name)
     current_app.logger.debug('>notify_admin')
     return Invitation(invitation)