Admin fix für unterschidliche Playlists
This commit is contained in:
parent
f3d0f6bd7b
commit
1d906d4d5f
2 changed files with 19 additions and 17 deletions
34
app.py
34
app.py
|
|
@ -87,16 +87,12 @@ def zeit(sekunden):
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def hello_world():
|
def hello_world():
|
||||||
liste = request.args.get("liste")
|
liste = request.args.get("liste")
|
||||||
print("/")
|
|
||||||
print(liste)
|
|
||||||
if liste is None:
|
if liste is None:
|
||||||
return redirect("/playlists")
|
return redirect("/playlists")
|
||||||
print(liste)
|
|
||||||
with open(liste+".json","r") as f:
|
with open(liste+".json","r") as f:
|
||||||
songs = json.load(f)
|
songs = json.load(f)
|
||||||
for song in songs:
|
for song in songs:
|
||||||
kartenGeneriren(song)
|
kartenGeneriren(song)
|
||||||
print(songs)
|
|
||||||
gesamtLaenge = 0
|
gesamtLaenge = 0
|
||||||
for song in songs:
|
for song in songs:
|
||||||
gesamtLaenge += song["laenge"]
|
gesamtLaenge += song["laenge"]
|
||||||
|
|
@ -107,15 +103,11 @@ def hello_world():
|
||||||
def playlists():
|
def playlists():
|
||||||
listen = glob("*.json")
|
listen = glob("*.json")
|
||||||
listen = (liste.replace(".json","") for liste in listen)
|
listen = (liste.replace(".json","") for liste in listen)
|
||||||
print("/playlists")
|
|
||||||
print(listen)
|
|
||||||
return render_template('playlists.html',lists=listen)
|
return render_template('playlists.html',lists=listen)
|
||||||
|
|
||||||
@app.route("/neueliste")
|
@app.route("/neueliste")
|
||||||
def neueliste():
|
def neueliste():
|
||||||
name = request.args.get("name")
|
name = request.args.get("name")
|
||||||
print("/neueliste")
|
|
||||||
print(name)
|
|
||||||
if name is not None:
|
if name is not None:
|
||||||
with open(name +".json", "x") as f:
|
with open(name +".json", "x") as f:
|
||||||
json.dump([],f)
|
json.dump([],f)
|
||||||
|
|
@ -127,8 +119,6 @@ def neueliste():
|
||||||
def suche():
|
def suche():
|
||||||
such = request.args.get("suche")
|
such = request.args.get("suche")
|
||||||
liste = request.args.get("liste")
|
liste = request.args.get("liste")
|
||||||
print("/suche")
|
|
||||||
print(liste)
|
|
||||||
if such is not None:
|
if such is not None:
|
||||||
ergebnisse = wikisuche(such)
|
ergebnisse = wikisuche(such)
|
||||||
else:
|
else:
|
||||||
|
|
@ -143,22 +133,34 @@ def suche_finden():
|
||||||
song = {"wikiid":request.form.get("id")}
|
song = {"wikiid":request.form.get("id")}
|
||||||
kartenGeneriren(song)
|
kartenGeneriren(song)
|
||||||
songs.append(song)
|
songs.append(song)
|
||||||
print(liste)
|
|
||||||
with open(liste+".json","w") as f:
|
with open(liste+".json","w") as f:
|
||||||
json.dump(songs,f,indent=2,ensure_ascii=False)
|
json.dump(songs,f,indent=2,ensure_ascii=False)
|
||||||
return redirect("/suche?liste="+liste,303)
|
return redirect("/suche?liste="+liste,303)
|
||||||
|
|
||||||
@app.route("/ADMIN")
|
@app.route("/rm")
|
||||||
def admin():
|
def admin():
|
||||||
|
liste = request.args.get("liste")
|
||||||
|
if liste is None:
|
||||||
|
return redirect("/playlists")
|
||||||
|
with open(liste+".json","r") as f:
|
||||||
|
songs = json.load(f)
|
||||||
|
for song in songs:
|
||||||
|
kartenGeneriren(song)
|
||||||
gesamtLaenge = 0
|
gesamtLaenge = 0
|
||||||
for song in songs:
|
for song in songs:
|
||||||
gesamtLaenge += song["laenge"]
|
gesamtLaenge += song["laenge"]
|
||||||
return render_template('index.html', karten=songs,gesamtLaenge=gesamtLaenge,admin=True )
|
return render_template('index.html', karten=songs,gesamtLaenge=gesamtLaenge,liste=liste,admin=True)
|
||||||
|
|
||||||
@app.route("/ADMIN",methods=["POST"])
|
@app.route("/rm",methods=["POST"])
|
||||||
def loeschen():
|
def loeschen():
|
||||||
|
liste = request.args.get("liste")
|
||||||
song = int(request.form.get("index"))
|
song = int(request.form.get("index"))
|
||||||
|
with open(liste+".json","r") as f:
|
||||||
|
print(liste+".json")
|
||||||
|
songs = json.load(f)
|
||||||
|
print(songs)
|
||||||
|
print(songs)
|
||||||
del songs[song]
|
del songs[song]
|
||||||
with open("songs.json","w") as f:
|
with open(liste+".json","w") as f:
|
||||||
json.dump(songs,f,indent=2,ensure_ascii=False)
|
json.dump(songs,f,indent=2,ensure_ascii=False)
|
||||||
return redirect("/ADMIN",303)
|
return redirect("/rm?liste="+liste,303)
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
{% if ergebnisse %}
|
{% if ergebnisse %}
|
||||||
<form method="post"><ol>
|
<form method="post"><ol>
|
||||||
{% for ergebnis in ergebnisse %}
|
{% for ergebnis in ergebnisse %}
|
||||||
<li><button name="id" value={{ergebnis.id}}>{{ ergebnis["display-label"].value }}</button> <ul><li>{{ ergebnis.description.value }}</li></ul></li>
|
<p><button name="id" value={{ergebnis.id}}>{{ ergebnis["display-label"].value }}</button><p>{{ ergebnis.description.value }}</p></p>
|
||||||
{% endfor %}</ol></form>
|
{% endfor %}</ol></form>
|
||||||
|
|
||||||
{%elif anfrage%}
|
{%elif anfrage%}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue