From 18383a6cc4ea9fcb15a9d56ff1e11ffdf0b3eec8 Mon Sep 17 00:00:00 2001 From: spl0k Date: Fri, 24 Nov 2017 19:24:00 +0100 Subject: [PATCH] Removed users import/export That was some method I was using by the time I deleted/recreated the database on each schema change --- supysonic/frontend/user.py | 46 ---------------------------------- supysonic/templates/users.html | 2 -- 2 files changed, 48 deletions(-) diff --git a/supysonic/frontend/user.py b/supysonic/frontend/user.py index 4ccf609..db9484e 100644 --- a/supysonic/frontend/user.py +++ b/supysonic/frontend/user.py @@ -243,52 +243,6 @@ def del_user(uid): return redirect(url_for('user_index')) -@app.route('/user/export') -@admin_only -def export_users(): - resp = make_response('\n'.join([ '%s,%s,%s,%s,"%s",%s,%s,%s' % (u.id, u.name, u.mail, u.password, u.salt, u.admin, u.lastfm_session, u.lastfm_status) - for u in store.find(User) ])) - resp.headers['Content-disposition'] = 'attachment;filename=users.csv' - resp.headers['Content-type'] = 'text/csv' - return resp - -@app.route('/user/import') -@admin_only -def import_users(): - return render_template('importusers.html') - -@app.route('/user/import', methods = [ 'POST' ]) -@admin_only -def do_user_import(): - if not request.files['file']: - return render_template('importusers.html') - - users = [] - reader = csv.reader(request.files['file']) - for id, name, mail, password, salt, admin, lfmsess, lfmstatus in reader: - mail = None if mail == 'None' else mail - admin = admin == 'True' - lfmsess = None if lfmsess == 'None' else lfmsess - lfmstatus = lfmstatus == 'True' - - user = User() - user.id = uuid.UUID(id) - user.name = name - user.password = password - user.salt = salt - user.admin = admin - user.lastfm_session = lfmsess - user.lastfm_status = lfmstatus - - users.append(user) - - store.find(User).remove() - for u in users: - store.add(u) - store.commit() - - return redirect(url_for('user_index')) - @app.route('/user//lastfm/link') @me_or_uuid def lastfm_reg(uid, user): diff --git a/supysonic/templates/users.html b/supysonic/templates/users.html index 6005569..7ac46f4 100644 --- a/supysonic/templates/users.html +++ b/supysonic/templates/users.html @@ -33,8 +33,6 @@