Пример #1
0
    def create_user(self,
                    name=None,
                    email=None,
                    user_password=None,
                    realname=None,
                    role_id=None,
                    **kwargs):
        if name is None:
            name = base._random_name("user")
        if realname is None:
            realname = base._random_name("realname")
        if email is None:
            email = '%s@%s.com' % (realname, "vmware")
        if user_password is None:
            user_password = "******"
        if role_id is None:
            role_id = 0

        client = self._get_client(**kwargs)
        user = swagger_client.User(username=name,
                                   email=email,
                                   password=user_password,
                                   realname=realname,
                                   role_id=role_id)
        _, status_code, header = client.users_post_with_http_info(user)

        base._assert_status_code(201, status_code)

        return base._get_id_from_header(header), name
Пример #2
0
 def create_user(self,
                 name=None,
                 email=None,
                 password=None,
                 realname=None,
                 **kwargs):
     if name is None:
         name = base._random_name("user")
     if realname is None:
         realname = base._random_name("realname")
     if email is None:
         email = '%s@%s.com' % (realname, "vmware")
     if password is None:
         password = "******"
     client = self._get_client(**kwargs)
     user = swagger_client.User(None, name, email, password, realname, None,
                                None, None, None, None, None, None, None,
                                None)
     print user
     _, _, header = client.users_post_with_http_info(user)
     return base._get_id_from_header(header), name
Пример #3
0
def signup():
    """クリエイターの登録画面"""
    if current_user.is_authenticated:
        logout_user()
        if 'token' in session:
            session.pop('token')
        return redirect_(url_for('creator.signup'))
    form = SignupForm(request.form)
    if request.method == 'POST':
        if form.validate_on_submit():
            user = sw.User()
            user.nickname = form.username.data
            user.email = form.email.data
            user.password = form.password.data
            try:
                creator_api = sw.CreatorApi(api_client=g.api)
                creator_api.creators_post(user=user)
                return redirect_(url_for('creator.login'))
            except ApiException as ex:
                flash('登録済みのメールアドレスです', category='error')
                current_app.logger.warning(ex)
    return render_template('creator_signup.html', form=form)
try:
    #get user
    user = UserApi.get_user()
    user_dict = user.to_dict()
    print()
    print('Current username:'******'user']['first_name'] + ' ' +
          user_dict['user']['last_name'])
except ApiException as e:
    print("Exception when calling UserApi -> get_user: %s\n" % e)
"""
    Example 3 (PUT Request): Changing user's name to all upper case and back.
"""
try:
    user_obj = swagger_client.User(
        first_name=user_dict['user']['first_name'].upper(),
        last_name=user_dict['user']['last_name'].upper())
    update_user_obj = swagger_client.UpdateUser(
        first_name=user_dict['user']['first_name'].upper(),
        last_name=user_dict['user']['last_name'].upper())
    user_upper = UserApi.put_user(update_user_obj)
    print()
    print('Username is updated to:')
    print(user_upper.resource['firstName'] + ' ' +
          user_upper.resource['lastName'])

    #put user back to initial state
    update_user_obj = swagger_client.UpdateUser(
        first_name=user_dict['user']['first_name'],
        last_name=user_dict['user']['last_name'])
    user_restore = UserApi.put_user(update_user_obj)