本文整理汇总了Python中api.models.User.current_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.current_user方法的具体用法?Python User.current_user怎么用?Python User.current_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.models.User
的用法示例。
在下文中一共展示了User.current_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import current_user [as 别名]
def delete(self, project_id, collaborator_id):
collaborator = Collaborator.get(collaborator_id)
current_user = User.current_user()
if current_user.key() != collaborator.user.key():
collaborator.remove()
else:
self.error(404)
示例2: post
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import current_user [as 别名]
def post(self):
data = json.loads(self.request.body)
current_user = User.current_user()
project = Project(
name=data.get('name'),
note=data.get('note'))
project.put()
collaborator = Collaborator(
project=project,
user=current_user,
is_manager=True)
collaborator.put()
self.response.write(json.dumps(project.to_dict()))
示例3: get
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import current_user [as 别名]
def get(self, project_id=None):
current_user = User.current_user()
if project_id:
project = Project.get(project_id)
if project.deleted_at is not None:
self.error(404)
if not current_user.is_collaborator_on(project):
self.error(403)
self.response.write(json.dumps(project.to_dict()))
else:
collaborators = Collaborator.all()\
.filter('user =', current_user)
projects = [c.project for c in collaborators if c.project.deleted_at is None]
projects.sort(key=lambda a: a.updated_at)
content = json.dumps([p.to_dict() for p in projects])
self.response.write(content)