Exemplo n.º 1
0
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 e.message:
                print("Cannot invite. User already exists [%s]" % email)
            else:
                print(e)
    except NoResultFound:
        print("The inviter [%s] was not found." % inviter_email)
Exemplo n.º 2
0
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, groups=groups)

        try:
            user.save()
            invite_url = invite_user(org, user_from, user)
            print "An invitation was sent to [%s] at [%s]." % (name, email)
        except IntegrityError as e:
            if "email" in e.message:
                print "Cannot invite. User already exists [%s]" % email
            else:
                print e
    except models.User.DoesNotExist:
        print "The inviter [%s] was not found." % inviter_email
Exemplo n.º 3
0
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 e.message:
                print("Cannot invite. User already exists [%s]" % email)
            else:
                print(e)
    except NoResultFound:
        print("The inviter [%s] was not found." % inviter_email)
Exemplo n.º 4
0
def invite(email, name, inviter_email, groups, is_admin=False):
    org = models.Organization.get_by_slug('default')
    groups = build_groups(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, groups=groups)

        try:
            user.save()
            invite_url = invite_user(org, user_from, user)
            print "An invitation was sent to [%s] at [%s]." % (name, email)
        except IntegrityError as e:
            if "email" in e.message:
                print "Cannot invite. User already exists [%s]" % email
            else:
                print e
    except models.User.DoesNotExist:
        print "The inviter [%s] was not found." % inviterEmail