當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。