def put(self): ''' POST verb call Returns: JSON/HTML/PDF view of the data. ''' fileID = int(self.hasMember('file')) author = self.hasMember('author') programText = self.hasMember('programText') title = self.hasMember('title') readOnly = self.hasMember('readOnly') if readOnly is "true": data = {"error": "ReadOnly file", "missing": "false readOnly"} view = errorView(data=data) return view.returnData() else: readOnly = False fileData = fileDoc(hashID=fileID, author=author, programText=programText, title=title, readOnly=readOnly) fileData.save() fileData = fileDoc.view("file/admin", key=fileID).first() fileData = dict(fileData) fileData['update'] = True view = fileView(data=fileData) return view.returnData()
def post(self): ''' PUT verb call Returns: JSON/HTML/PDF view of the data ''' fileID = ''.join(random.choice(hashChoice) for i in range(10)) programText = self.hasMember('programText') author = self.hasMember('author') title = self.hasMember('title') readOnly = self.hasMember('readOnly') if readOnly is "true": readOnly = True else: readOnly = False fileData = fileDoc(hashID=int(fileID)) fileData.programText = programText fileData.title = title fileData.author = author fileData.readOnly = readOnly fileData.save() fileData = fileDoc.view("file/admin", key=fileID).first() fileData = dict(fileData) fileData['save'] = True view = fileView(data=fileData) return view.returnData()
def get(self): ''' GET verb call Returns: JSON/HTML/PDF view of the data. ''' fileID = int(self.hasMember('file')) fileData = fileDoc.view("file/admin", key=fileID).first() fileData = dict(fileData) view = fileView(data=fileData) return view.returnData()
def delete(self): ''' DELETE verb call Goes through and tells the database to delete the given document And returns the data with value 'delete' as true Returns: JSON/HTML/PDF view of the dat ''' fileID = int(self.hasMember('file')) name = database.view("file/admin", key=fileID).first()['value'] name['delete'] = True a = name['_id'] database.delete_doc(a) fileData = dict(name) view = fileView(data=fileData) return view.returnData()