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


Python Shift.read方法代码示例

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


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

示例1: publish

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def publish(self, id):
     # NOTE: should maybe take publishData url parameter - David 9/5/2009
     loggedInUser = helper.getLoggedInUser()
     theShift = Shift.read(id, loggedInUser)
     if not theShift:
         return error("Resource does not exist.", ResourceDoesNotExistError)
     if theShift.type != "shift":
         return error("Resource is not of type shift", ResourceTypeError)
     publishData = json.loads(helper.getRequestBody())
     # convert targets to actual database references
     if publishData.get("targets"):
         from server.models.group import Group
         from server.models.ssuser import SSUser
         theUser = SSUser.read(loggedInUser)
         targets = publishData["targets"]
         # convert short names to group ids
         shortNames = [target[1:] for target in targets if target[0] == "&"]
         groupIds = Group.shortNamesToIds(shortNames)
         # convert user name to user ids
         userNames = [target[1:] for target in targets if target[0] == "@"]
         userIds = SSUser.namesToIds(userNames)
         # create list of dbs being published to
         dbs = [Group.db(groupId) for groupId in groupIds]
         dbs.extend([SSUser.db(userId) for userId in userIds])
         # validate
         writeable = theUser.writeable()
         if set(writeable) != set(dbs):
             return error("Operation not permitted. You don't have permission to publish to some of these gruops", PermissionError)
         publishData["dbs"] = dbs
     return data(theShift.publish(publishData))
开发者ID:gmatters,项目名称:shiftspace,代码行数:32,代码来源:shift.py

示例2: unpublish

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def unpublish(self, id):
     loggedInUser = helper.getLoggedInUser()
     theShift = Shift.read(id, loggedInUser)
     if not theShift:
         return error("Resource does not exist.", ResourceDoesNotExistError)
     if theShift.type != "shift":
         return error("Resource is not of type shift", ResourceTypeError)
     return data(theShift.unpublish())
开发者ID:gmatters,项目名称:shiftspace,代码行数:10,代码来源:shift.py

示例3: testDelete

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def testDelete(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     self.assertNotEqual(newShift, None)
     newShift.delete()
     theShift = Shift.read(newShift.id, self.fakemary.id)
     self.assertEqual(theShift, None)
开发者ID:xncroft,项目名称:shiftspace,代码行数:10,代码来源:shift_model_test.py

示例4: testUpdate

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def testUpdate(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     newShift.update({"summary":"changed!"})
     theShift = Shift.read(newShift.id, self.fakemary.id)
     self.assertEqual(theShift.summary, "changed!")
     db = core.connect(SSUser.privateDb(self.fakemary.id))
     del db[theShift.id]
开发者ID:xncroft,项目名称:shiftspace,代码行数:11,代码来源:shift_model_test.py

示例5: testRead

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def testRead(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     theShift = Shift.read(newShift.id, self.fakemary.id)
     self.assertEqual(theShift.source.server, newShift.source.server)
     self.assertEqual(theShift.source.database, newShift.source.database)
     self.assertEqual(theShift.createdBy, self.fakemary.id)
     db = core.connect(SSUser.privateDb(self.fakemary.id))
     del db[theShift.id]
开发者ID:xncroft,项目名称:shiftspace,代码行数:12,代码来源:shift_model_test.py

示例6: comment

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def comment(self, id):
     loggedInUser = helper.getLoggedInUser()
     jsonData = helper.getRequestBody()
     if jsonData != "":
         theShift = Shift.read(id)
         if not theShift:
             return error("Resource does not exist.", ResourceDoesNotExistError)
         if theShift.type != "shift":
             return error("Resource is not of type shift", ResourceTypeError)
         from server.models.ssuser import SSUser
         theUser = SSUser.read(loggedInUser)
         theData = json.loads(jsonData)
         if theUser.canRead(theShift):
             from server.models.comment import Comment
             Comment.create(theUser.id, theShift.id, theData["text"], theData.get("subscribe") or False)
             return data(Shift.read(theShift.id, theUser.id))
         else:
             return error("Operation not permitted. You don't have permission to comment on this shift.", PermissionError)
     else:
         return error("No data for comment.", NoDataError)
开发者ID:gmatters,项目名称:shiftspace,代码行数:22,代码来源:shift.py

示例7: share

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def share(self, id, users):
     from server.models.ssuser import SSUser
     loggedInUser = helper.getLoggedInUser()
     theShift = Shift.read(id)
     if not theShift or theShift.publishData.private:
         return error("You don't have permission to view this shift.", PermissionError)
     targets = users.split(" ")
     userNames = [target[1:] for target in targets if target[0] == "@"]
     userIds = SSUser.namesToIds(userNames)
     theShift.shareWith(userIds, fromUser=SSUser.read(loggedInUser))
     return ack
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:13,代码来源:shift.py

示例8: read

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def read(self, id):
     from server.models.ssuser import SSUser
     loggedInUser = helper.getLoggedInUser()
     theUser = SSUser.read(loggedInUser)
     theShift = Shift.read(id, loggedInUser)
     if theShift and theUser.canRead(theShift):
         return data(theShift)
     else:
         if not theShift:
             return error("Resource does not exist.", ResourceDoesNotExistError)
         else:
             return error("Operation not permitted. You don't have permission to view this shift. %s" % theShift, PermissionError)
开发者ID:gmatters,项目名称:shiftspace,代码行数:14,代码来源:shift.py

示例9: comments

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def comments(self, id, start=None, end=None, limit=25):
     loggedInUser = helper.getLoggedInUser()
     theShift = Shift.read(id)
     if not theShift:
         return error("Resource does not exist.", ResourceDoesNotExistError)
     if theShift.type != "shift":
         return error("Resource is not of type shift", ResourceTypeError)
     from server.models.ssuser import SSUser
     theUser = SSUser.read(loggedInUser)
     if theShift.isPublic() or theUser.canRead(theShift):
         return data(theShift.comments(start=start, end=end, limit=limit))
     else:
         return error("Operation not permitted. You don't have permission to view comments on this shift.", PermissionError)
开发者ID:gmatters,项目名称:shiftspace,代码行数:15,代码来源:shift.py

示例10: unfavorite

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def unfavorite(self, id):
     loggedInUser = helper.getLoggedInUser()
     theShift = Shift.read(id)
     if not theShift:
         return error("Resource does not exist.", ResourceDoesNotExistError)
     if theShift.type != "shift":
         return error("Resource is not of type shift", ResourceTypeError)
     from server.models.ssuser import SSUser
     theUser = SSUser.read(loggedInUser)
     if theUser.canRead(theShift):
         return data(theUser.unfavorite(theShift))
     else:
         return error("Operation not permitted. You don't have permission to unfavorite this shift.", PermissionError)
开发者ID:gmatters,项目名称:shiftspace,代码行数:15,代码来源:shift.py

示例11: delete

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def delete(self, id):
     from server.models.ssuser import SSUser
     loggedInUser = helper.getLoggedInUser()
     theShift = Shift.read(id, loggedInUser)
     if not theShift:
         return error("Resource does not exist.", ResourceDoesNotExistError)
     if theShift.type != "shift":
         return error("Resource is not of type shift", ResourceTypeError)
     from server.models.ssuser import SSUser
     theUser = SSUser.read(loggedInUser)
     if theUser.canModify(theShift):
         theShift.delete()
         return ack
     else:
         return error("Operation not permitted. You don't have permission to delete this shift.", PermissionError)
开发者ID:gmatters,项目名称:shiftspace,代码行数:17,代码来源:shift.py

示例12: unnotify

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def unnotify(self, id):
     loggedInUser = helper.getLoggedInUser()
     theShift = Shift.read(id)
     if not theShift:
         return error("Resource does not exist.", ResourceDoesNotExistError)
     if theShift.type != "shift":
         return error("Resource is not of type shift", ResourceTypeError)
     from server.models.ssuser import SSUser
     theUser = SSUser.read(loggedInUser)
     if theUser.canRead(theShift):
         if theUser.isSubscribed(theShift):
             theUser.unsubscribe(theShift)
             return ack
         else:
             return error("You are not getting notification from this comment thread.", NotBeingNotifiedError)
     else:
         return error("Operation not permitted. You don't have permission to be notified of events on this stream.", PermissionError)
开发者ID:gmatters,项目名称:shiftspace,代码行数:19,代码来源:shift.py

示例13: update

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def update(self, id):
     from server.models.ssuser import SSUser
     loggedInUser = helper.getLoggedInUser()
     jsonData = helper.getRequestBody()
     if jsonData != "":
         theShift = Shift.read(id, loggedInUser)
         if not theShift:
             return error("Resource does not exist.", ResourceDoesNotExistError)
         if theShift.type != "shift":
             return error("Resource is not of type shift", ResourceTypeError)
         from server.models.ssuser import SSUser
         shiftData = json.loads(jsonData)
         theUser = SSUser.read(loggedInUser)
         if theUser.canModify(theShift):
             return data(theShift.update(shiftData))
         else:
             return error("Operation not permitted. You don't have permission to update this shift.", PermissionError)
     else:
         return error("No data for shift.", NoDataError)
开发者ID:gmatters,项目名称:shiftspace,代码行数:21,代码来源:shift.py

示例14: unfavorite

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def unfavorite(self, aShift):
     from server.models.favorite import Favorite
     from server.models.shift import Shift
     Favorite.readByUserAndShift(self.id, aShift.id).delete()
     return Shift.joinData(Shift.read(aShift.id), self.id)
开发者ID:gmatters,项目名称:shiftspace,代码行数:7,代码来源:ssuser.py

示例15: favorite

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import read [as 别名]
 def favorite(self, aShift):
     from server.models.favorite import Favorite
     from server.models.shift import Shift
     Favorite.create(self.id, aShift.id)
     return Shift.joinData(Shift.read(aShift.id), self.id)
开发者ID:gmatters,项目名称:shiftspace,代码行数:7,代码来源:ssuser.py


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