diff --git a/data/.hidden b/data/.hidden new file mode 100644 index 0000000..e69de29 diff --git a/run.py b/debug.py similarity index 100% rename from run.py rename to debug.py diff --git a/shop.py b/shop.py index e9be3ee..fa10336 100644 --- a/shop.py +++ b/shop.py @@ -410,20 +410,23 @@ def register(): @app.route('/profile', methods=['GET', 'POST']) def profile(): + if not session.get('logged_in'): + abort(401) error = None + user=get_username(session.get('user')) if request.method == 'POST': import re, string pattern = re.compile('[\W]+') password=password_hash(request.form['password']) if len(request.form['password'])<5: error="Password too short" - return render_template('profile.html', error=error) + return render_template('profile.html', error=error,user=user) g.db.execute('update users set pass=? where id=?', [password,session.get('user')]) g.db.commit() flash('successfully updated profile.') return redirect(url_for('profile')) - return render_template('profile.html', error=error) + return render_template('profile.html', error=error,user=user) diff --git a/static/script.js b/static/script.js index 1dfd807..b8115bc 100644 --- a/static/script.js +++ b/static/script.js @@ -28,3 +28,21 @@ function hidetoggle(name) { }} } } +function dropDown() { + document.getElementById("Dropdown").classList.toggle("show"); +} + +// Close the dropdown menu if the user clicks outside of it +window.onclick = function(event) { + if (!event.target.matches('.dropbtn')) { + + var dropdowns = document.getElementsByClassName("dropdown-content"); + var i; + for (i = 0; i < dropdowns.length; i++) { + var openDropdown = dropdowns[i]; + if (openDropdown.classList.contains('show')) { + openDropdown.classList.remove('show'); + } + } + } +} diff --git a/static/style.css b/static/style.css index eb40e93..026c2a7 100644 --- a/static/style.css +++ b/static/style.css @@ -23,3 +23,47 @@ td { height: 1.75em; } .error { background: #f0d6d6; padding: 0.5em; } .hidden { display: none; } .pointer { cursor: pointer; } + +/* dropdown */ + +.dropbtn { + color: #377ba8; + text-decoration: underline; + cursor: pointer; + font-weight: bold; + letter-spacing:-0.1em; +} + +/* Dropdown button on hover & focus */ +.dropbtn:hover, .dropbtn:focus { + background-color: #ccc; +} + +/* The container
- needed to position the dropdown content */ +.dropdown { + position: relative; + display: inline-block; +} + +/* Dropdown Content (Hidden by Default) */ +.dropdown-content { + display: none; + right: 0px; + position: absolute; + background-color: #fafafa; + min-width: 160px; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); +} + +/* Links inside the dropdown */ +.dropdown-content a { + padding: 12px 16px; + display: block; +} + +/* Change color of dropdown links on hover */ +.dropdown-content a:hover {background-color: #f1f1f1} + +/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */ +.show {display:block;} + diff --git a/templates/layout.html b/templates/layout.html index 7148691..6372840 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -13,10 +13,15 @@
- List shops - Reload page - Profile - Logout + Shops +
{% for message in get_flashed_messages() %}
{{ message }}
diff --git a/templates/profile.html b/templates/profile.html index c261d60..22a4650 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -5,7 +5,7 @@
Username: -
+
{{ user }}
Password: