def delete(id): item = Niktos().find(id) if request.method == "POST": item.delete() return redirect(url_for('.index')) else: return render_template('niktos_delete.html', nikto=item)
def nimport(): parsed = [] imported = "/tmp/snerimport" if request.method == "POST": # PARSING imported = request.form['imported'] try: for path in imported.split("\n"): path = path.rstrip() for f in [ os.path.join(path,f) for f in os.listdir(path) if os.path.isfile(os.path.join(path,f)) ]: nikto = Niktos().new_from_file(f) parsed.append(dict(nikto)) except Exception as e: print e return render_template('niktos_import.html', imported=imported, parsed="error parsing data") if request.form['submit'] == 'import': #IMPORT for tmp in parsed: n = Niktos(**tmp) n.save() return render_template('niktos_index.html', niktos=Niktos()) return render_template('niktos_import.html', imported=imported, parsed=parsed)
def untag(): oid = request.args.get('oid', '') tag = request.args.get('tag', '') n = Niktos().find(oid) if "tags" in n and tag in n["tags"]: n["tags"].remove(tag) n.save() return redirect(request.referrer)
def tag(): oid = request.args.get('oid', '') tag = request.args.get('tag', '') n = Niktos().find(oid) if "tags" not in n: n["tags"] = [] n["tags"].append(tag) n["tags"] = list(set(n["tags"])) n.save() return redirect(request.referrer)