mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-23 01:16:18 +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:
parent
c947219f59
commit
18383a6cc4
@ -243,52 +243,6 @@ def del_user(uid):
|
|||||||
|
|
||||||
return redirect(url_for('user_index'))
|
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')
|
@app.route('/user/<uid>/lastfm/link')
|
||||||
@me_or_uuid
|
@me_or_uuid
|
||||||
def lastfm_reg(uid, user):
|
def lastfm_reg(uid, user):
|
||||||
|
@ -33,8 +33,6 @@
|
|||||||
</table>
|
</table>
|
||||||
<div class="btn-toolbar" role="toolbar">
|
<div class="btn-toolbar" role="toolbar">
|
||||||
<a href="{{ url_for('add_user_form') }}" class="btn btn-default">Add</a>
|
<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>
|
||||||
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog">
|
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
|
Loading…
Reference in New Issue
Block a user