mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-23 01:16:18 +00:00
Converting frontend:playlists
This commit is contained in:
parent
d7728e7645
commit
5f1502d41d
@ -20,13 +20,13 @@
|
|||||||
|
|
||||||
from flask import request, session, flash, render_template, redirect, url_for
|
from flask import request, session, flash, render_template, redirect, url_for
|
||||||
import uuid
|
import uuid
|
||||||
from web import app
|
from web import app, store
|
||||||
import db
|
from db import Playlist
|
||||||
|
|
||||||
@app.route('/playlist')
|
@app.route('/playlist')
|
||||||
def playlist_index():
|
def playlist_index():
|
||||||
return render_template('playlists.html', mine = db.Playlist.query.filter(db.Playlist.user_id == uuid.UUID(session.get('userid'))),
|
return render_template('playlists.html', mine = store.find(Playlist, Playlist.user_id == uuid.UUID(session.get('userid'))),
|
||||||
others = db.Playlist.query.filter(db.Playlist.user_id != uuid.UUID(session.get('userid'))))
|
others = store.find(Playlist, Playlist.user_id != uuid.UUID(session.get('userid'))))
|
||||||
|
|
||||||
@app.route('/playlist/<uid>')
|
@app.route('/playlist/<uid>')
|
||||||
def playlist_details(uid):
|
def playlist_details(uid):
|
||||||
@ -36,7 +36,7 @@ def playlist_details(uid):
|
|||||||
flash('Invalid playlist id')
|
flash('Invalid playlist id')
|
||||||
return redirect(url_for('playlist_index'))
|
return redirect(url_for('playlist_index'))
|
||||||
|
|
||||||
playlist = db.Playlist.query.get(uid)
|
playlist = store.get(Playlist, uid)
|
||||||
if not playlist:
|
if not playlist:
|
||||||
flash('Unknown playlist')
|
flash('Unknown playlist')
|
||||||
return redirect(url_for('playlist_index'))
|
return redirect(url_for('playlist_index'))
|
||||||
@ -51,7 +51,7 @@ def playlist_update(uid):
|
|||||||
flash('Invalid playlist id')
|
flash('Invalid playlist id')
|
||||||
return redirect(url_for('playlist_index'))
|
return redirect(url_for('playlist_index'))
|
||||||
|
|
||||||
playlist = db.Playlist.query.get(uid)
|
playlist = store.get(Playlist, uid)
|
||||||
if not playlist:
|
if not playlist:
|
||||||
flash('Unknown playlist')
|
flash('Unknown playlist')
|
||||||
return redirect(url_for('playlist_index'))
|
return redirect(url_for('playlist_index'))
|
||||||
@ -63,7 +63,7 @@ def playlist_update(uid):
|
|||||||
else:
|
else:
|
||||||
playlist.name = request.form.get('name')
|
playlist.name = request.form.get('name')
|
||||||
playlist.public = request.form.get('public') in (True, 'True', 1, '1', 'on', 'checked')
|
playlist.public = request.form.get('public') in (True, 'True', 1, '1', 'on', 'checked')
|
||||||
db.session.commit()
|
store.commit()
|
||||||
flash('Playlist updated.')
|
flash('Playlist updated.')
|
||||||
|
|
||||||
return playlist_details(uid)
|
return playlist_details(uid)
|
||||||
@ -76,14 +76,14 @@ def playlist_delete(uid):
|
|||||||
flash('Invalid playlist id')
|
flash('Invalid playlist id')
|
||||||
return redirect(url_for('playlist_index'))
|
return redirect(url_for('playlist_index'))
|
||||||
|
|
||||||
playlist = db.Playlist.query.get(uid)
|
playlist = store.get(Playlist, uid)
|
||||||
if not playlist:
|
if not playlist:
|
||||||
flash('Unknown playlist')
|
flash('Unknown playlist')
|
||||||
elif str(playlist.user_id) != session.get('userid'):
|
elif str(playlist.user_id) != session.get('userid'):
|
||||||
flash("You're not allowed to delete this playlist")
|
flash("You're not allowed to delete this playlist")
|
||||||
else:
|
else:
|
||||||
db.session.delete(playlist)
|
store.remove(playlist)
|
||||||
db.session.commit()
|
store.commit()
|
||||||
flash('Playlist deleted')
|
flash('Playlist deleted')
|
||||||
|
|
||||||
return redirect(url_for('playlist_index'))
|
return redirect(url_for('playlist_index'))
|
||||||
|
Loading…
Reference in New Issue
Block a user