def get(self): apt_name = self.request.get(IDENTIFIER_APT_NAME) user_email = self.request.get(IDENTIFIER_USER_EMAIL) apt_lst = Apartment.query(Apartment.apt_name == apt_name).fetch() # print "called: " + user_email + ", " + apt_name cur_apt = None for apt in apt_lst: if user_email in apt.user_email_lst: cur_apt = apt cur_notebook_lst = NoteBook.query( NoteBook.notebook_id == cur_apt.notebook_id).fetch() if len(cur_notebook_lst) == 0: response = {} response[ 'error'] = 'we dont have notebook for the apt: ' + apt_name return self.respond(**response) cur_notebook = cur_notebook_lst[0] retList = [] for noteid in cur_notebook.note_id_lst: note_lst = Note.query(Note.id == noteid).fetch() cur_note = note_lst[0] ret_note = {} ret_note['author'] = cur_note.author_email ret_note['description'] = cur_note.description date = str(cur_note.date) ret_note['last_edit_date'] = date retList.append(ret_note) self.respond(AllNoteLst=retList, status="Success")
def get(self): apt_name = self.request.get(IDENTIFIER_APT_NAME) user_email = self.request.get(IDENTIFIER_USER_EMAIL) apt_lst = Apartment.query(Apartment.apt_name == apt_name).fetch() # print "called: " + user_email + ", " + apt_name cur_apt = None for apt in apt_lst: if user_email in apt.user_email_lst: cur_apt = apt cur_notebook_lst = NoteBook.query( NoteBook.notebook_id == cur_apt.notebook_id).fetch() if len(cur_notebook_lst) == 0: response = {} response['error'] = 'we dont have notebook for the apt: ' + apt_name return self.respond(**response) cur_notebook = cur_notebook_lst[0] retList = [] for noteid in cur_notebook.note_id_lst: note_lst = Note.query(Note.id == noteid).fetch() cur_note = note_lst[0] ret_note = {} ret_note['author'] = cur_note.author_email ret_note['description'] = cur_note.description date = str(cur_note.date) ret_note['last_edit_date'] = date retList.append(ret_note) self.respond(AllNoteLst = retList, status="Success")
def get(self): # req_json = json.loads(self.request.body) # user_email = req_json[IDENTIFIER_USER_EMAIL] user_email = self.request.get(IDENTIFIER_USER_EMAIL) # apt_name = req_json[IDENTIFIER_APT_NAME] apt_name = self.request.get(IDENTIFIER_APT_NAME) # description = req_json[IDENTIFIER_DESCRIPTION_NAME] description = self.request.get(IDENTIFIER_DESCRIPTION_NAME) apt_lst = Apartment.query(Apartment.apt_name == apt_name).fetch() cur_apt = None for apt in apt_lst: if user_email in apt.user_email_lst: cur_apt = apt if cur_apt == None: response = {} response[ 'error'] = 'the apt: ' + apt_name + ' is not available for user: '******'error'] = 'we dont have notebook for the apt: ' + apt_name return self.respond(**response) cur_note_book = cur_note_book_lst[0] note_id = uuid.uuid4() note = Note(id=str(note_id), description=description, author_email=user_email, notebook_id=cur_note_book_id) cur_note_book.note_id_lst.append(str(note_id)) cur_note_book.put() note.put() self.respond(note_id=str(note_id), notebook_id=cur_note_book_id, status="Success")
def get(self): # req_json = json.loads(self.request.body) # user_email = req_json[IDENTIFIER_USER_EMAIL] user_email = self.request.get(IDENTIFIER_USER_EMAIL) # apt_name = req_json[IDENTIFIER_APT_NAME] apt_name = self.request.get(IDENTIFIER_APT_NAME) # description = req_json[IDENTIFIER_DESCRIPTION_NAME] description = self.request.get(IDENTIFIER_DESCRIPTION_NAME) apt_lst = Apartment.query(Apartment.apt_name == apt_name).fetch() cur_apt = None for apt in apt_lst: if user_email in apt.user_email_lst: cur_apt = apt if cur_apt == None: response = {} response['error'] = 'the apt: ' + apt_name + ' is not available for user: '******'error'] = 'we dont have notebook for the apt: ' + apt_name return self.respond(**response) cur_note_book = cur_note_book_lst[0] note_id = uuid.uuid4() note = Note(id = str(note_id), description = description, author_email = user_email, notebook_id = cur_note_book_id) cur_note_book.note_id_lst.append(str(note_id)) cur_note_book.put() note.put() self.respond(note_id = str(note_id), notebook_id = cur_note_book_id, status="Success")