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)
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)