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


Python dao.UserDao类代码示例

本文整理汇总了Python中dao.UserDao的典型用法代码示例。如果您正苦于以下问题:Python UserDao类的具体用法?Python UserDao怎么用?Python UserDao使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: get_users

def get_users():
    current_user = get_current_user()
    result = []
    customers = assigneesHandler.get_customers(current_user.get('username'))
    if authentication.has_full_access(current_user):
        # super user, master admin
        result = [_set_customers(u) for u in UserDao.get_all()]
    elif authentication.user_is_master(current_user):
        if authentication.user_is_assigned_master(current_user):
            # master user (assigned master customer)
            users = [_set_customers(u) for u in UserDao.get_all()]
            result = [u for u in users if authentication.allow_semi_user_changes(u)]
        else:
            # master user (not assigned master customer)
            for customer in customers:
                assigned_users = assigneesHandler.get_assignees(customer.get('customer'))
                users = [get_user(a['user']) for a in assigned_users]
                result = result + [u for u in users if authentication.allow_semi_user_changes(u)]
    else:
        # can only be assigned to one..
        customer = customers[0]
        assigned_users = assigneesHandler.get_assignees(customer.get('customer'))
        users = [get_user(a['user']) for a in assigned_users]
        result = [u for u in users if u and authentication.allow_semi_user_changes(u)]
    return result
开发者ID:letterix,项目名称:rasp-temp,代码行数:25,代码来源:userHandler.py

示例2: logout

 def logout(self):
     user = authentication.get_current_user()
     if user:
         authentication.logout(cherrypy.session)
         UserDao.delete_cookie(user.get('username'))
         self.usetCookie()
     redirect(URL_LOGIN)
开发者ID:letterix,项目名称:rasp-temp,代码行数:7,代码来源:server.py

示例3: post

	def post(self):
		'''用户注册
		paras:
			*	email_or_phone: 	用户可以输入自己的手机号或者邮箱用来注册
			*	user_name:			用来显示用户名称,不唯一
			*	pwd:				用户登录密码
			*	pwd_confirm:		用户登录密码确认
			*	accept:				用户是否接受使用条款
		'''
		email_or_phone = self.get_argument('email_or_phone')
		user_name = self.get_argument('user_name')
		pwd = self.get_argument('pwd')
		
		enroll_type = StringUtil.is_email_or_phone(email_or_phone)
		if enroll_type == 'neither':
			#如果用户输入不是邮箱或者电话号,则注册失败
			self.write(RESPONSE.WRONG_TYPE)
			return
		elif enroll_type == 'email':
			#如果email已经注册,则注册失败
			if UserDao.get_user_by_email(email_or_phone):
				self.write(RESPONSE.EMAIL_EXIST)
				return
		else:
			#如果手机号已经注册,则注册失败
			if UserDao.get_user_by_phone(email_or_phone):
				self.write(RESPONSE.PHONE_EXIST)
				return
		#进行用户注册流程
		UserDao.register(email_or_phone, enroll_type, user_name, pwd)
		self.write(RESPONSE.SUCCESS)
开发者ID:wh1100717,项目名称:poly_emm,代码行数:31,代码来源:UserController.py

示例4: full_update_user

def full_update_user(user):
    password = user.get('password')
    if password and password != validator.PASSWORD_PLACEHOLDER:
        set_password_salt(user)
        UserDao.update_user_with_pw_and_salt(user)
    else:
        UserDao.update_user(user)
    assigneesHandler.update_assignee(user)
    return True
开发者ID:letterix,项目名称:rasp-temp,代码行数:9,代码来源:userHandler.py

示例5: semi_update_user

def semi_update_user(user):
    password = user.get('password')
    old_user = get_user(user.get('username'))
    user['role'] = old_user.get('role')
    if password and password != validator.PASSWORD_PLACEHOLDER:
        set_password_salt(user)
        UserDao.update_user_with_pw_and_salt(user)
    else:
        UserDao.update_user(user)
    return True
开发者ID:letterix,项目名称:rasp-temp,代码行数:10,代码来源:userHandler.py

示例6: test_005_onMessage_create_user_ok

    def test_005_onMessage_create_user_ok(self):
        num_users_before = len(UserDao.get_all())
        user_template = testData.USER_CREATE_OK
        user_data = json.loads(user_template['data'])
        SyncManager.onMessage(user_template)
        num_users_after = len(UserDao.get_all())

        user_created = UserDao.get_user(user_data['username'])
        self.assertEquals(num_users_after, num_users_before + 1)
        self.assertEquals(user_created['username'], user_data['username'])
开发者ID:letterix,项目名称:rasp-temp,代码行数:10,代码来源:sycManagerTest.py

示例7: test_008_onMessage_delete_user_ok

    def test_008_onMessage_delete_user_ok(self):
        user_delete = testData.USER_DELETE
        user_data = json.loads(user_delete['data'])
        user_before = UserDao.get_user(user_data['username'])
        self.assertIsNotNone(user_before)

        SyncManager.onMessage(user_delete)

        user_after = UserDao.get_user(user_data['username'])
        self.assertIsNone(user_after)
开发者ID:letterix,项目名称:rasp-temp,代码行数:10,代码来源:sycManagerTest.py

示例8: test_020_put

 def test_020_put(self):
     global cherrypy
     cherrypy.session = {'roles': ['admin', 'planner', 'driver']}
     olduser = UserDao.get_user("username")
     self.assertEqual(olduser['email'], "[email protected]")
     
     user.put(olduser['id'], olduser['username'], olduser['surname'], olduser['name'], olduser['number'], olduser['password'], '[email protected]')
     changeduser = UserDao.get_user("username")
     self.assertEqual(changeduser['name'], "name")
     self.assertEqual(changeduser['number'], "1234567890")
     self.assertEqual(changeduser['email'], "[email protected]")
开发者ID:letterix,项目名称:rasp-temp,代码行数:11,代码来源:usertest.py

示例9: test_012_test_user_correction_ack

    def test_012_test_user_correction_ack(self):

        user_conflict_ack = testData.USER_CORRECTION_ACK
        correction = json.loads(user_conflict_ack['correction'])
        user_before = UserDao.get_user(correction['username'])
        self.assertNotEqual(correction, user_before)

        SyncManager.onMessage(user_conflict_ack)

        user_after = UserDao.get_user(correction['username'])
        self.assertEqual(correction, user_after)
开发者ID:letterix,项目名称:rasp-temp,代码行数:11,代码来源:sycManagerTest.py

示例10: delete_user

def delete_user(username):
    user = UserDao.get_user(username)
    if user and authentication.allow_full_user_changes(username):
        UserDao.delete_user(username)
    user = UserDao.get_user(username)
    if not user:
        assignees = assigneesHandler.get_customers(username)
        for assignee in assignees:
            assigneesHandler.delete(assignee.get('user'), assignee.get('customer'))
        assignees = assigneesHandler.get_customers('username')
        if not assignees or len(assignees) == 0:
            return True
    return False
开发者ID:letterix,项目名称:rasp-temp,代码行数:13,代码来源:userHandler.py

示例11: test

def test(user_ids):
	# user_ids is an array of ids []
	r = redis.Redis()
	user_dao = UserDao(r)
	
	for user in user_ids:
		got_user = user_dao.get_user(user)
		print "Here's a user..."
		print got_user.screenname
		print got_user.id
		print got_user.oauth_token_secret
		print got_user.oauth_token
		print "-end-"
开发者ID:qoelet,项目名称:buzzfire,代码行数:13,代码来源:redis_dumpdata.py

示例12: test_010_test_not_accept_user_update

    def test_010_test_not_accept_user_update(self):

        user_update_conflict = testData.USER_UPDATE_CONFLICT
        user_conflict_data = json.loads(user_update_conflict['data'])
        user_conflict_prev = json.loads(user_update_conflict['prev'])
        user_before = UserDao.get_user(user_conflict_data['username'])
        self.assertNotEqual(user_before, user_conflict_prev)

        config.LOCAL = True

        SyncManager.send_correction_ack = MagicMock(return_value="ok")
        SyncManager.onMessage(user_update_conflict)

        user_after = UserDao.get_user(user_conflict_data['username'])

        self.assertEqual(user_before, user_after)
        SyncManager.send_correction_ack.assert_called_with(user_update_conflict['id'], user_update_conflict['burner_sn'], user_before)
开发者ID:letterix,项目名称:rasp-temp,代码行数:17,代码来源:sycManagerTest.py

示例13: test_007_onMessage_update_user_ok

    def test_007_onMessage_update_user_ok(self):
        user_update = testData.USER_UPDATE
        config.LOCAL = False
        user_before = UserDao.get_user(json.loads(user_update['data'])['username'])
        SyncManager.onMessage(user_update)
        user_after = UserDao.get_user(json.loads(user_update['data'])['username'])

        self.assertNotEquals(user_before['email'], user_after['email'])
        self.assertNotEquals(user_before['surname'], user_after['surname'])
        self.assertNotEquals(user_before['name'], user_after['name'])
        self.assertNotEquals(user_before['phone'], user_after['phone'])
        self.assertNotEquals(user_before['password'], user_after['password'])
        self.assertNotEquals(user_before['salt'], user_after['salt'])

        self.assertEquals(user_before['role'], user_after['role'])
        self.assertEquals(user_before['username'], user_after['username'])
        self.assertEquals(user_before['burner_sn'], user_after['burner_sn'])
开发者ID:letterix,项目名称:rasp-temp,代码行数:17,代码来源:sycManagerTest.py

示例14: test_010_post

 def test_010_post(self):
     global cherrypy
     cherrypy.session = {'roles': ['admin', 'planner', 'driver']}
     user.post("username", "surname", "name", "1234567890", "password", "[email protected]")
     createduser = UserDao.get_user("username")
     self.assertEqual(createduser['name'], "name")
     self.assertEqual(createduser['number'], "1234567890")
     self.assertEqual(createduser['username'], "username")
     self.assertEqual(createduser['role'], "user")
开发者ID:letterix,项目名称:rasp-temp,代码行数:9,代码来源:usertest.py

示例15: resp

def resp(token, did):
	user = UserDao.get_user_by_token(token)
	if not user: return RESPONSE.WRONG_TOKEN
	devices = DeviceDao.get_devices_by_user(user)
	for device in devices:
		if device['did'] == did:
			#TODO 需要进行一些数据清理工作
			return RESPONSE.SUCCESS
	return RESPONSE.WRONG_DID
开发者ID:wh1100717,项目名称:poly_emm,代码行数:9,代码来源:AndroidDao.py


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