diff --git a/qr-labels.py b/qr-labels.py index 54ca8f3..03e18bf 100644 --- a/qr-labels.py +++ b/qr-labels.py @@ -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!") diff --git a/templates/editlink.html b/templates/editlink.html index 9cda40a..26040f2 100644 --- a/templates/editlink.html +++ b/templates/editlink.html @@ -1,12 +1,21 @@ {% extends 'base.html' %} {% block content %} -
+{% if admin == True %} + +{% endif %} + {% endblock %} \ No newline at end of file diff --git a/templates/list.html b/templates/list.html index a5a7852..05a4450 100644 --- a/templates/list.html +++ b/templates/list.html @@ -5,7 +5,8 @@ {% for label in linklist %}
{{label['code']}}:
- Show QR | Edit
+
+ Show QR | Edit
{{label['url']}}