當前位置: 首頁>>代碼示例>>Python>>正文


Python APIPermissions.get_user_element_permissions方法代碼示例

本文整理匯總了Python中API.APIPermissions.get_user_element_permissions方法的典型用法代碼示例。如果您正苦於以下問題:Python APIPermissions.get_user_element_permissions方法的具體用法?Python APIPermissions.get_user_element_permissions怎麽用?Python APIPermissions.get_user_element_permissions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在API.APIPermissions的用法示例。


在下文中一共展示了APIPermissions.get_user_element_permissions方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_e_permissions_get_user_element_permissions

# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import get_user_element_permissions [as 別名]
	def test_e_permissions_get_user_element_permissions(self):
		user_key = ndb.Key("uk","guep")
		element_key = ndb.Key("ek","guep")
		ps.add_element_permissions(user_key,element_key,True)

		obj = ps.get_user_element_permissions(user_key,element_key)

		self.assertEqual(obj.user_key, user_key)
		self.assertEqual(obj.element_key, element_key)
		self.assertEqual(obj.access, True)
開發者ID:Keesaco,項目名稱:KeesaFlo,代碼行數:12,代碼來源:TestAPIPermissions.py

示例2: __check_app_access

# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import get_user_element_permissions [as 別名]
def __check_app_access(redir = False):
	authed_user = auth.get_current_user()
	if authed_user is None:
		return __unauthed_response(redir)
	else:
		elem = ps.get_element_key_by_ref('canLogIn')
		if elem is not None:
			user_key = ps.get_user_key_by_id(authed_user.user_id())
			if user_key is not None:
				perm = ps.get_user_element_permissions(user_key, elem)
				if perm is not None:
					if perm.access:
						return None
		return __not_signed_up_response(redir)
開發者ID:Keesaco,項目名稱:KeesaFlo,代碼行數:16,代碼來源:views.py

示例3: signup_handler

# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import get_user_element_permissions [as 別名]
def signup_handler(request):
	authed_user = auth.get_current_user()
	if authed_user is None:
		return __unauthed_response()

	user_key = ps.get_user_key_by_id(authed_user.user_id())
	if user_key is None:
		user_key = ps.add_user(authed_user)

	response_part = {
		'success'		: False
	}

	try:
		file_req = json.loads(request.raw_post_data)
	except ValueError:
		response_part.update({'error' : 'Invalid request payload.'})
		return HttpResponse(json.dumps(response_part), content_type="application/json")
		
	if 'action' not in file_req:
		response_part.update({'error' : 'Incomplete request.'})
		return HttpResponse(json.dumps(response_part), content_type="application/json")

	elem_key = ps.get_element_key_by_ref('canLogIn')
	if elem_key is None:
		elem_key = ps.add_element('canLogIn')

	user_elem = ps.get_user_element_permissions(user_key, elem_key)
	if user_elem is not None:
		response_part.update({'error' : 'Already signed up.'})
		return HttpResponse(json.dumps(response_part), content_type="application/json")
	else:
		ps.add_element_permissions(user_key, elem_key, True)

		response_part.update({'success' : True})
		return HttpResponse(json.dumps(response_part), content_type="application/json")
開發者ID:Keesaco,項目名稱:KeesaFlo,代碼行數:38,代碼來源:views.py

示例4: test_e_permissions_revoke_user_element_permissions

# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import get_user_element_permissions [as 別名]
	def test_e_permissions_revoke_user_element_permissions(self):
		user_key = ndb.Key("uk","ruep")
		element_key = ndb.Key("ek","ruep")
		ps.add_element_permissions(user_key,element_key,True)
		ps.revoke_user_element_permissions(user_key,element_key)
		self.assertIsNone(ps.get_user_element_permissions(user_key,element_key))
開發者ID:Keesaco,項目名稱:KeesaFlo,代碼行數:8,代碼來源:TestAPIPermissions.py


注:本文中的API.APIPermissions.get_user_element_permissions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。