Beispiel #1
0
 def comment(self, id):
     loggedInUser = helper.getLoggedInUser()
     jsonData = helper.getRequestBody()
     if jsonData != "":
         theData = json.loads(jsonData)
         if shift.canComment(id, loggedInUser["_id"]):
             theUser = user.readById(loggedInUser["_id"])
             theShift = shift.read(id)
             event.create({
                     "meta": "comment",
                     "objectRef": "shift:%s" % id,
                     "streamId": shift.commentStream(id),
                     "displayString": "%s just commented on your %s on %s" % (theUser["userName"], theShift["space"]["name"], theShift["href"]),
                     "createdBy": loggedInUser["_id"],
                     "content": {
                         "href": theShift["href"],
                         "domain": theShift["domain"],
                         "text": theData["text"]
                         }
                     })
             return ack
         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)
Beispiel #2
0
 def create(self):
     loggedInUser = helper.getLoggedInUser()
     jsonData = helper.getRequestBody()
     if jsonData != "":
         theData = json.loads(jsonData)
         streamId = theData["streamId"]
         if not streamId:
             return error("You did not specify a stream to post to", CreateEventError)
         if stream.canPost(streamId, loggedInUser["_id"]):
             return data(event.create(theData))
     else:
         return error("No data for event.", NoDataError)
Beispiel #3
0
 def post(self, id):
     loggedInUser = helper.getLoggedInUser()
     if stream.canPost(id, loggedInUser["_id"]):
         jsonData = helper.getRequestBody()
         if jsonData != "":
             theData = json.loads(jsonData)
             theData["streamId"] = id
             theData["createdBy"] = loggedInUser["_id"]
             if stream.canPost(id, loggedInUser["_id"]):
                 return data(event.create(theData))
         else:
             return error("No data for event.", NoDataError)
     else:
         return error("Operation not permitted. You don't have permission to post to this stream.", PermissionError)