def create_user(**kwargs): if User.objects(username=kwargs['username']).count() > 0: raise ValueError('Пользователь уже существует') token = utility.create_user_without_password(**kwargs) mail_controller.send_user_created_email(token) return token
def check_super_user(): if User.objects(username=root_username).count() == 0: utility.create_user(root_username, root_password, 'root', role='super_admin')