def destroy_comment(self, id, commentid): comment = Session.query(NodeComment)\ .filter(NodeComment.id == commentid).first() Session.delete(comment) Session.commit() return redirect(url( controller='nodes', action='show', id=id))
def destroy_game(self, id): game = Session.query(Game).filter(Game.id == id).first() Session.delete(game) Session.commit() session['flash'] = "Success" session.save() return {'success': True}
def destroy_studio(self, id): studio = Session.query(Studio).filter(Studio.id == id).first() Session.delete(studio) Session.commit() session['flash'] = "Success" session.save() return {'success': True}
def destroy(self, id, backup_id): dbbackup = Session.query(NodeDatabaseBackup)\ .filter(NodeDatabaseBackup.id == backup_id).first() Session.delete(dbbackup) Session.commit() session['flash'] = "Successfully destroyed dbbackup" session.save() return redirect(url(controller='dbbackups', action='index', id=id))
def delete(self, id): if id.isdigit(): graph = Session.query(Graph)\ .filter(Graph.id == int(id)).first() else: graph = Session.query(Graph)\ .filter(Graph.name == id).first() Session.delete(graph) Session.commit() session['flash'] = "Successfully deleted %s" % graph.name session.save() return redirect(url( controller='graphs', action='index'))
def update_disks(self, diskinfo): if self.disks: current_serials = [d.serial_no for d in self.disks] new_serials = [d['serial_no'] for d in diskinfo['disks']] diff_serials = list(set(new_serials) - set(current_serials)) remove_serials = [ serial for serial in current_serials \ if serial not in new_serials ] for s in remove_serials: for rd in self.disks: if rd.serial_no == s: self.disks.remove(rd) Session.delete(rd) for s in diff_serials: for disk in diskinfo['disks']: if disk['serial_no'] == s: new_disk = Disk() new_disk.serial_no = disk['serial_no'] new_disk.capacity = disk['capacity'] new_disk.type = disk['type'] new_disk.controller_slot = disk['controller_slot'] new_disk.controller_id = DiskController\ .grab_controller(disk['controller']) Session.add(new_disk) self.disks.append(new_disk) else: self.disks = [] for disk in diskinfo['disks']: new_disk = Disk() new_disk.serial_no = disk['serial_no'] new_disk.capacity = disk['capacity'] new_disk.type = disk['type'] new_disk.controller_slot = disk['controller_slot'] new_disk.controller_id = DiskController\ .grab_controller(disk['controller']) Session.add(new_disk) self.disks.append(new_disk) Session.add(self) Session.commit()
def update_disks(self, diskinfo): if self.disks: current_serials = [d.serial_no for d in self.disks] new_serials = [d["serial_no"] for d in diskinfo["disks"]] diff_serials = list(set(new_serials) - set(current_serials)) remove_serials = [serial for serial in current_serials if serial not in new_serials] for s in remove_serials: for rd in self.disks: if rd.serial_no == s: self.disks.remove(rd) Session.delete(rd) for s in diff_serials: for disk in diskinfo["disks"]: if disk["serial_no"] == s: new_disk = Disk() new_disk.serial_no = disk["serial_no"] new_disk.capacity = disk["capacity"] new_disk.type = disk["type"] new_disk.controller_slot = disk["controller_slot"] new_disk.controller_id = DiskController.grab_controller(disk["controller"]) Session.add(new_disk) self.disks.append(new_disk) else: self.disks = [] for disk in diskinfo["disks"]: new_disk = Disk() new_disk.serial_no = disk["serial_no"] new_disk.capacity = disk["capacity"] new_disk.type = disk["type"] new_disk.controller_slot = disk["controller_slot"] new_disk.controller_id = DiskController.grab_controller(disk["controller"]) Session.add(new_disk) self.disks.append(new_disk) Session.add(self) Session.commit()
def delete(self, backup_id): dbbackup = Session.query(NodeDatabaseBackup)\ .filter(NodeDatabaseBackup.id == backup_id).first() Session.delete(dbbackup) Session.commit() return {"success": True}
def destroy_comment(self, id, commentid): comment = Session.query(NodeComment)\ .filter(NodeComment.id == commentid).first() Session.delete(comment) Session.commit() return redirect(url(controller='nodes', action='show', id=id))
def destroy(self, id): network_device = Session.query(NetworkDevice).filter( NetworkDevice.id == id).first() Session.delete(network_device) Session.commit() return {'success': True}