def update(self): id = request.params['id'] graph = Session.query(Graph)\ .filter(Graph.id == id).first() group = request.params['group_select'] graph.name = request.params['graph_title'] graph.filename = request.params['filename'] graph.group = Session.query(Group)\ .filter(Group.name == group).first() rrds = [] for k,v in request.params.iteritems(): if k == 'rrd_type': rrds.append(v) graph.rrd_types = ','.join(rrds) if not graph.name or not graph.group or not graph.rrd_types: session['flash'] = "Failed to update graph" session.save() return redirect(url( controller='graphs', action='index')) Session.add(graph) Session.commit() session['flash'] = "Successfully updated" session.save() grab_new_drraw(graph) generate_index() return redirect(url( controller='graphs', action='index'))
def create(self): graph_title = '' rrds = [] group = None for k,v in request.params.iteritems(): if k == 'rrd_type': rrds.append(v) elif k == 'graph_title': graph_title = v elif k == 'group_select': group = Session.query(Group)\ .filter(Group.name == v).first() else: pass graph = Graph() graph.name = graph_title graph.filename = 'g%s' % time() graph.rrd_types = ','.join(rrds) graph.group = group if not graph.name or not graph.rrd_types or not graph.group: session['flash'] = "Failed to created graph" session.save() return redirect(url( controller='graphs', action='index')) Session.add(graph) Session.commit() session['flash'] = "Successfully created %s" % graph.name session.save() grab_new_drraw(graph) generate_index() return redirect(url( controller='graphs', action='index'))