def init_empty_site(self, dbsession:Session, user:UserMixin):
"""When the first user signs up build the admin groups and make the user member of it.
Make the first member of the site to be admin and superuser.
"""
# Try to reflect related group class based on User model
i = inspection.inspect(user.__class__)
Group = i.relationships["groups"].mapper.entity
# Do we already have any groups... if we do we probably don'¨t want to init again
if dbsession.query(Group).count() > 0:
return
g = Group(name=Group.DEFAULT_ADMIN_GROUP_NAME)
dbsession.add(g)
g.users.append(user)
评论列表
文章目录