Example #1
0
 def _create_user(id_, first_name=u'Guinea', last_name=u'Pig', rb_admin=False, admin=False, email=None, groups=None,
                  legacy=False):
     user = User.get(id_)
     if user:
         return user.as_avatar if legacy else user
     user = User()
     user.id = id_
     user.first_name = first_name
     user.last_name = last_name
     user.email = email or u'{}@example.com'.format(id_)
     user.is_admin = admin
     user.local_groups = {g.group for g in (groups or ())}
     db.session.add(user)
     db.session.flush()
     if rb_admin:
         rb_settings.acls.add_principal('admin_principals', user)
     db.session.flush()
     return user.as_avatar if legacy else user
Example #2
0
 def _create_user(id_, first_name=u'Guinea', last_name=u'Pig', rb_admin=False, admin=False, email=None, groups=None,
                  legacy=False):
     user = User.get(id_)
     if user:
         return user.as_avatar if legacy else user
     user = User()
     user.id = id_
     user.first_name = first_name
     user.last_name = last_name
     user.email = email or u'{}@example.com'.format(id_)
     user.is_admin = admin
     user.local_groups = {g.group for g in (groups or ())}
     db.session.add(user)
     db.session.flush()
     if rb_admin:
         rb_settings.acls.add_principal('admin_principals', user)
     db.session.flush()
     return user.as_avatar if legacy else user
Example #3
0
 def _create_user(id_, name=u'Pig', surname=u'Guinea', rb_admin=False, email=None, groups=None):
     user = User.get(id_)
     if user:
         return user.as_avatar
     user = User()
     user.id = id_
     user.first_name = name
     user.last_name = surname
     user.email = email or u'{}@example.com'.format(id_)
     user.local_groups = {g.group for g in (groups or ())}
     db.session.add(user)
     db.session.flush()
     if rb_admin:
         rb_settings.set('admin_principals', rb_settings.get('admin_principals') + [user.as_principal])
     db.session.flush()
     _users.add(user)
     avatar = user.as_avatar
     avatar.email = user.email
     return avatar