当前位置: 首页>>代码示例>>Python>>正文


Python User.name方法代码示例

本文整理汇总了Python中models.user.User.name方法的典型用法代码示例。如果您正苦于以下问题:Python User.name方法的具体用法?Python User.name怎么用?Python User.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.user.User的用法示例。


在下文中一共展示了User.name方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
def register():
    from forms.registration import ProfessorRegistrationForm

    form = ProfessorRegistrationForm()
    if form.validate_on_submit():
        user = User()
        user.name = form.name.data
        user.second_name = form.second_name.data
        user.middle_name = form.middle_name.data
        user.birthday = form.birthday.data
        user.password = form.password.data
        user.email = form.email.data
        # professor = Professor()
        # professor.post = form.post.data
        # professor.academic_degree = form.academic_degree.data
        # professor.rank = form.rank.data
        # professor.cathedra_id = form.cathedra.data.id
        # professor.user = user
        db.session.add(user)
        # db.session.add(professor)
        try:
            db.session.commit()
        except Exception:
            flash('Problem with registering')
            return redirect(url_for('site.register'))
        flash('Thanks for registering')
        return redirect(url_for('site.login'))
    return render_template('site/register/register.html', form=form)
开发者ID:mrhitman,项目名称:dgma,代码行数:30,代码来源:site.py

示例2: create_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
def create_user(user_id):
    user = User()
    user.name = "das"
    user.user_id = user_id
    db.session.add(user)
    db.session.commit()
    return user
开发者ID:rafagonc,项目名称:ReadingList-Server,代码行数:9,代码来源:helper.py

示例3: put

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
    def put(self):
        args = parser.parse_args()
        id = args['id']
        name = args['name']
        email = args['email']
        type = args['type']

        user = User.query.filter(User.id == id).first()
        setJSONFormat()
        if user is None:
            if type == 'force':
                user = User(name)
                user.email = email
                db.session.add(user)
                try:
                    db.session.commit()
                    return jsonify(user)
                except Exception as e:
                    return jsonify(message="Error : %s" %e)
            return jsonify(messages='User with id: %s is not exists' % id)
        else:
            if name:
                user.name = name
            if email:
                user.email = email

            try:
                db.session.commit()
                return jsonify(user)
            except Exception as e:
                return jsonify(message="Error : %s" %e)
开发者ID:tarigancana,项目名称:api_with_flask,代码行数:33,代码来源:user_api.py

示例4: create_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
 def create_user(self):
     user = User()
     user.username = 'test_username'
     user.password = 'test_password'
     user.name = 'test_name'
     user.email = '[email protected]'
     user.save()
     return user
开发者ID:aldarionsevero,项目名称:BusinemeWeb,代码行数:10,代码来源:test_post.py

示例5: create

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
def create(name, email, passwd):
    new = User()
    new.name = name
    new.email = email
    new.passwd = passwd
    db.session.add(new)
    db.session.commit()
    return login()
开发者ID:Sparklingj97,项目名称:Donquixote,代码行数:10,代码来源:app.py

示例6: convert_to_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
def convert_to_user(user_id, data_map):
    user = User(user_id)
    user.name = data_map['name']
    user.role = data_map['role']
    user.manager = data_map['manager']
    user.state = data_map['state']
    user.team = data_map['team']
    user.step = data_map['step']
    user.email = data_map['email']
    user.start_date = data_map['start_date']
    return user
开发者ID:LithiumH,项目名称:ChronoBot,代码行数:13,代码来源:chrono.py

示例7: test_create_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
 def test_create_user(self):
     time = datetime.now()
     user = User()
     user.id = 38413
     user.profIcon = 3134
     user.revisionDate = time
     user.level = 30
     user.name = 'intoxicated'
     
     self.assertEquals(user.id, 38413)
     self.assertEquals(user.profIcon, 3134)
     self.assertEquals(user.revisionDate, time)
     self.assertEquals(user.level, 30)
     self.assertEquals(user.name, 'intoxicated')
开发者ID:intoxicated,项目名称:RiotChat,代码行数:16,代码来源:user_test.py

示例8: create_test_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
def create_test_user():
    facebook_id = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
    user = User()
    user.name = 'Rafael Goncalves'
    user.facebook_id = facebook_id
    user.birthday = date.today()
    user.friends = 299
    user.gender = 'male'
    user.platform = USER_PLATFORM_iOS
    user.email = '[email protected]'
    db.session.add(user)
    db.session.commit()
    token = Token(user.id)
    db.session.add(token)
    db.session.commit()
    return user
开发者ID:rafagonc,项目名称:share,代码行数:18,代码来源:helper.py

示例9: create_new_user_impl

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
def create_new_user_impl(args):
    try:
        validate(args)
        user = None
        try:
            user = user_by_user_id(args["user_id"])
        except Exception as e:
            user = User()
            user.user_id = args["user_id"]
            db.session.add(user)
        user.auth_token = args["auth_token"]
        user.auth_token_secret = args["auth_token_secret"]
        user.name = args["name"]
        db.session.commit()
        return Response(True, "User Created", UserSchema().dumps(user).data).output()
    except Exception as e:
        return Response(False, str(e), None).output()
开发者ID:rafagonc,项目名称:ReadingList-Server,代码行数:19,代码来源:user.py

示例10: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
 def post(self, *args, **kwargs):
     name = self.get_argument('name', '')
     family = self.get_argument('family', '')
     username = self.get_argument('username', '')
     password = self.get_argument('password', '')
     type = self.get_argument('type', '')
     permissions = Redis.get(key='permissions', type='list')
     try:
         obj = Controller()
         obj.name = name
         obj.family = family
         obj.username = username
         obj.password = password
         obj.type = type
         obj.save()
         self.write('ok')
         self.render('register.html', action='done', permissions=permissions)
     except Exception, e:
         self.write(e.message)
         self.render('register.html', action='error', permissions=permissions)
开发者ID:ehsansh84,项目名称:Customs,代码行数:22,代码来源:user.py

示例11: new

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
    def new(self, name = "", email = "", balance = 0):

        if cherrypy.request.method == 'GET':
            template = self.templateEnv.get_template('users/form.html')
            return template.render(user=[], link='/users/new', button_value='New User', header='Welcome, fellow hacker <small>join the party!</small>')
        elif cherrypy.request.method == 'POST':

            user = User()
            user.name = name
            user.email = email

            if balance.isdigit():
                user.balance = int(float(balance) * 100)
            else:
                user.balance = 0

            cherrypy.request.db.add(user)
            cherrypy.request.db.flush()

            raise cherrypy.HTTPRedirect('/users/' + str(user.id))
        else:
            pass
开发者ID:r4mp,项目名称:mete_python_cherrypy_jinja2,代码行数:24,代码来源:users.py

示例12: create_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
def create_user():
    # print request.json
    if not request.json or not 'email' in request.json:
        abort(400)

    new_user = User()
    new_user.name = request.json['name']
    new_user.email = request.json['email']
    new_user.active = request.json['active']
    new_user.password = request.json['password']
    new_user.hash_password()

    # Acá sacar la fecha y hora actual.
    current_time = datetime.datetime.now()
    new_user.registry_date = request.json.get('registry_date', current_time)
    
    # Controlamos error en caso de que se inserte un usuario que ya existe
    try:
        new_user.save()
    except Exception, e:
        print e
        abort(400)
开发者ID:GonzaloLeyton,项目名称:rad,代码行数:24,代码来源:services.py

示例13: create_data

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
def create_data():
    #create some users
    facebook_id = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
    rafael = User()
    rafael.name = 'Rafael Goncalves'
    rafael.facebook_id = facebook_id
    rafael.birthday = date.today()
    rafael.friends = 299
    rafael.gender = 'male'
    rafael.nickname = 'rafael'
    rafael.email = '[email protected]'
    db.session.add(rafael)
    token = Token(rafael.id)
    db.session.commit()

    facebook_id2 = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
    bola = User()
    bola.name = 'Bola Domingues'
    bola.facebook_id = facebook_id2
    bola.birthday = date.today()
    bola.friends = 532
    bola.gender = 'male'
    bola.nickname = 'bola'
    bola.email = '[email protected]'
    db.session.add(bola)
    token = Token(bola.id)
    db.session.commit()

    facebook_id3 = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
    bolovo = User()
    bolovo.name = 'Doutor Bolovo'
    bolovo.facebook_id = facebook_id3
    bolovo.birthday = date.today()
    bolovo.friends = 23
    bolovo.gender = 'male'
    bolovo.nickname = 'bolovo'
    bolovo.email = '[email protected]'
    db.session.add(bolovo)
    token = Token(bolovo.id)
    db.session.commit()

    #create some groups
    share_t = Group()
    share_t.active = True
    share_t.title = "Share Your Thoughts"
    share_t.description = "Grupo copiado do facebook chamado share-your-thoughts"
    share_t.admins.append(bola)
    share_t.subscriptions.append(bola)
    share_t.subscriptions.append(bolovo)
    share_t.subscriptions.append(rafael)
    db.session.add(share_t)
    db.session.commit()

    shammu = Group()
    shammu.active = True
    shammu.title = "Salvem as Baleias!"
    shammu.description = "Grupo dedicado ao salvamento de baleias e o fechamentos de parques de entretenimento que usam animais em cativeiro para estrelar em suas atracoes"
    shammu.admins.append(bola)
    shammu.subscriptions.append(bolovo)
    shammu.subscriptions.append(bola)
    db.session.add(shammu)
    db.session.commit()

    share_c = Group()
    share_c.active = True
    share_c.title = "Share Your Career"
    share_c.description = "Grupo dedicado ao compartilhamento de informacoes sobre estagios, empregos e carreiras em geral"
    share_c.admins.append(bolovo)
    share_c.subscriptions.append(bolovo)
    share_c.subscriptions.append(rafael)
    share_c.subscriptions.append(bola)
    db.session.add(share_c)
    db.session.commit()

    #create some posts to share_t
    share_t_post1 = Post('E possivel a contratacao de anoes para animar festar de criancas acima de 11 anos?', 0)
    share_t_post1.group_id = bola.id
    share_t_post1.user_id = share_t.id
    db.session.add(share_t_post1)
    db.session.commit()

    share_t_post2 = Post('Algo para fazer esse fds??? Geoconda ta com nada me disseram migas!', 0)
    share_t_post2.group_id = bolovo.id
    share_t_post2.user_id = share_t.id
    db.session.add(share_t_post2)
    db.session.commit()

    #create some posts to share_t
    share_c_post1 = Post('[PUC][FACULDADE] Puc ou mackenzie!!!??', 0)
    share_c_post1.group_id = bolovo.id
    share_c_post1.user_id = share_c.id
    db.session.add(share_c_post1)
    db.session.commit()

    share_c_post2 = Post('[EMPREGO][ENTREVISTA] Como e fazer uma entrevista no JPMorgan gente?', 0)
    share_c_post2.group_id = bolovo.id
    share_c_post2.user_id = share_c.id
    db.session.add(share_c_post2)
    db.session.commit()

#.........这里部分代码省略.........
开发者ID:rafagonc,项目名称:share,代码行数:103,代码来源:data_simuator.py

示例14: get

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import name [as 别名]
	def get(self):
		verifier = self.request.get("oauth_verifier")
		
		if verifier:
			# Get access token
			handler = auth.OAuthHandler(config.CONSUMER_KEY, config.CONSUMER_SECRET)
			handler.set_request_token(self.session.get("request_token_key"), self.session.get("request_token_secret"))
			access_token = handler.get_access_token(verifier)
			
			if access_token:
				# Get user			
				logging.info("Access token: %s" %(access_token))
				user = User.all().filter("twitter_access_token_key", access_token.key).get()
				
				if((not user) or (user and user.updated < datetime.now() - timedelta(0,86400))):
					logging.info("Connecting to the Twitter API")
					api = API(handler)
					temp_user = api.verify_credentials()
					temp_image = urlfetch.Fetch(str(temp_user.profile_image_url).replace("_normal", "")).content

					# Transform image into .PNG
					image_manager = images.Image(image_data=temp_image)
					image_manager.rotate(360)
					temp_png = image_manager.execute_transforms()
					logging.info("Encoded into .PNG")

					# Save or update image in Cloud storage
					filename = config.FOLDER + "/" + str(temp_user.id)
					gcs_file = gcs.open(filename,'w',content_type="image/png",options={"x-goog-acl":"public-read"})
					gcs_file.write(temp_png)
					gcs_file.close()
					logging.info("Image saved to Google Cloud Storage")

					# Get avatar
					blob_filename = "/gs" + filename
					blobkey = blobstore.create_gs_key(blob_filename)
					temp_avatar = str(images.get_serving_url(blobkey))
								
					if not user:
						logging.info("User did not exist")

						user = User(
							twitter_id = str(temp_user.id),
							twitter_access_token_key = str(access_token.key),
							twitter_access_token_secret = str(access_token.secret),
							username = str(temp_user.screen_name).lower(),
							name = temp_user.name,
							bio = temp_user.description,
							avatar = temp_avatar,
						)
						
					else:
						logging.info("User had to be updated")

						user.twitter_id = str(temp_user.id)
						user.twitter_access_token_key = str(access_token.key)
						user.twitter_access_token_secret = str(access_token.secret)
						user.username = str(temp_user.screen_name).lower()
						user.name = temp_user.name
						user.bio = temp_user.description
						user.avatar = temp_avatar
											
					user.put()
					logging.info("User @%s saved in datastore"%(user.username))
				
				# Save user in session
				self.session["id"] = user.key().id()
				
			else:
				logging.error("No access token from Twitter")
				print "Error"
		else:
			logging.error("No verifier")
			print "Error"
		
		# Redirect users to the page they came from or the page they're supposed to head to
		next = self.session.get("next")
		redirect = self.session.get("referer")
		if next:
			redirect = next
		self.redirect(str(redirect))
开发者ID:detcherry,项目名称:gopitch,代码行数:83,代码来源:auth.py


注:本文中的models.user.User.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。