def deleteNoteID(NoteID): sessionUser = checkCookiesSessionUser(); response.content_type = 'application/json'; returnedMessage = { "NoteID" : NoteID, "valid" : "false", "deleted": "false", "status" : "You're not allowed to do this action" } if (sessionUser == None): return json.dumps(returnedMessage); note = db.getNotebyNoteID(NoteID); if (note == None): returnedMessage["deleted"] = "false"; returnedMessage["status"] = "This note doesn't exist on our system or has changed location"; return json.dumps(returnedMessage); # The note doesn't exist on our database userID_note = note['UserID']; userID_session = sessionUser['UserID']; if (userID_note == userID_session): if (db.deleteNote(NoteID)): returnedMessage['valid'] = 'true'; returnedMessage['deleted'] = "true"; returnedMessage['status'] = "We have deleted your note!"; else: returnedMessage['deleted'] = "false"; returnedMessage['status'] = "You're not allowed to delete this note."; return json.dumps(returnedMessage);
def deleteNoteID(NoteID): sessionUser = checkCookiesSessionUser(); if (sessionUser == None): return template('login') note = db.getNotebyNoteID(NoteID); if (note == None): return redirectHome(); # The note doesn't exist on our database userID_note = note['UserID']; userID_session = sessionUser['UserID']; if (userID_note == userID_session): if (db.deleteNote(NoteID)): return template('note-deleted', user=sessionUser); else: return "Problems deleting that note<a href='/'>Go to your profile</a>" return template('error') else: return redirectPrivateZone(); # Private note. Guest can't read this note