(email, name, inviter_email, groups, is_admin=False, organization="default")
Sends an invitation to the given NAME and EMAIL from INVITER_EMAIL.
Sends an invitation to the given NAME and EMAIL from INVITER_EMAIL.
Sends an invitation to the given NAME and EMAIL from INVITER_EMAIL .
def invite(email, name, inviter_email, groups, is_admin=False, organization="default"):
    """
    Sends an invitation to the given NAME and EMAIL from INVITER_EMAIL.
    """
    org = models.Organization.get_by_slug(organization)
    groups = build_groups(org, groups, is_admin)
    try:
        user_from = models.User.get_by_email_and_org(inviter_email, org)
        user = models.User(org=org, name=name, email=email, group_ids=groups)
        models.db.session.add(user)
        try:
            models.db.session.commit()
            invite_user(org, user_from, user)
            print("An invitation was sent to [%s] at [%s]." % (name, email))
        except IntegrityError as e:
            if "email" in str(e):
                print("Cannot invite. User already exists [%s]" % email)
            else:
                print(e)
    except NoResultFound:
        print("The inviter [%s] was not found." % inviter_email)
def invite ( email , name , inviter_email , groups , is_admin = False , organization = "default" ) : org = models . Organization . get_by_slug ( organization ) groups = build_groups ( org , groups , is_admin ) try : user_from = models . User . get_by_email_and_org ( inviter_email , org ) user = models . User ( org = org , name = name , email = email , group_ids = groups ) models . db . session . add ( user ) try : models . db . session . commit ( ) invite_user ( org , user_from , user ) print ( "An invitation was sent to [%s] at [%s]." % ( name , email ) ) except IntegrityError as e : if "email" in str ( e ) : print ( "Cannot invite. User already exists [%s]" % email ) else : print ( e ) except NoResultFound : print ( "The inviter [%s] was not found." % inviter_email )