1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-09 19:52:16 +00:00

Removed users import/export

That was some method I was using by the time I deleted/recreated the
database on each schema change
This commit is contained in:
spl0k 2017-11-24 19:24:00 +01:00
parent c947219f59
commit 18383a6cc4
2 changed files with 0 additions and 48 deletions

View File

@ -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/<uid>/lastfm/link')
@me_or_uuid
def lastfm_reg(uid, user):

View File

@ -33,8 +33,6 @@
</table>
<div class="btn-toolbar" role="toolbar">
<a href="{{ url_for('add_user_form') }}" class="btn btn-default">Add</a>
<a href="{{ url_for('export_users') }}" class="btn btn-default">Export</a>
<a href="{{ url_for('import_users') }}" class="btn btn-default">Import</a>
</div>
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">