admins can edit and remove links

This commit is contained in:
2018-10-18 14:44:13 +02:00
parent a2e2b8992b
commit 6fca90977f
3 changed files with 32 additions and 10 deletions
+18 -6
View File
@@ -92,15 +92,27 @@ def serveCode(code):
@app.route("/edit", methods=['GET', 'POST'])
def edit():
code = request.form.get("code")
print ("code: {}".format(code))
code = request.form.get("code") if request.form.get("code") is not None else request.args.get("code")
url = request.form.get("url")
if codeLink(code) is False:
return render_template('invalid.html', code=code)
if codeLink(code) is not None:
return render_template('cantedit.html', url=codeLink(code))
url = request.form.get("url")
if current_user.is_authenticated:
if url==None:
return render_template('editlink.html', code=code, url=codeLink(code), admin=current_user.is_authenticated)
else:
if url=='remove':
url = ''
links[code]['url']=url
saveFile()
return render_template('message.html', message="Done Mr. Admin person")
else:
if codeLink(code) is not None:
return render_template('cantedit.html', url=codeLink(code))
if url is None:
return render_template('editlink.html', code=code)
return render_template('editlink.html', code=code, url='', admin=current_user.is_authenticated)
#Saving the link:
if url.lower().startswith('https://') is False and url.lower().startswith('http://') is False:
return render_template('message.html', message="Only http:// and https:// links alowed. Plz fix your link!")