admins can edit and remove links
This commit is contained in:
+18
-6
@@ -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!")
|
||||
|
||||
Reference in New Issue
Block a user