def delete(id): sner = Sners().find(id) if request.method == "POST": sner.delete() return redirect(url_for('.index')) else: return render_template('sners_delete.html', sner=sner)
def delete_all(): sner = Sners() if request.method == "POST": sner.delete_all() return redirect(url_for('.index')) else: return render_template('sners_delete.html', sner="all data")
def simport(): 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)) ]: #sner1 compat if not f.endswith("/00dump.rdb"): sner = Sners().new_from_file(f) parsed.append(dict(sner)) except Exception as e: print e return render_template('sners_import.html', imported=imported, parsed="error parsing data") if request.form['submit'] == 'import': #IMPORT for tmp in parsed: s = Sners(**tmp) s.save() return render_template('sners_index.html', sner=Sners()) return render_template('sners_import.html', imported=imported, parsed=parsed)