dropdown menu, and fixes
This commit is contained in:
0
data/.hidden
Normal file
0
data/.hidden
Normal file
7
shop.py
7
shop.py
@@ -410,20 +410,23 @@ def register():
|
|||||||
|
|
||||||
@app.route('/profile', methods=['GET', 'POST'])
|
@app.route('/profile', methods=['GET', 'POST'])
|
||||||
def profile():
|
def profile():
|
||||||
|
if not session.get('logged_in'):
|
||||||
|
abort(401)
|
||||||
error = None
|
error = None
|
||||||
|
user=get_username(session.get('user'))
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
import re, string
|
import re, string
|
||||||
pattern = re.compile('[\W]+')
|
pattern = re.compile('[\W]+')
|
||||||
password=password_hash(request.form['password'])
|
password=password_hash(request.form['password'])
|
||||||
if len(request.form['password'])<5:
|
if len(request.form['password'])<5:
|
||||||
error="Password too short"
|
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=?',
|
g.db.execute('update users set pass=? where id=?',
|
||||||
[password,session.get('user')])
|
[password,session.get('user')])
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
flash('successfully updated profile.')
|
flash('successfully updated profile.')
|
||||||
return redirect(url_for('profile'))
|
return redirect(url_for('profile'))
|
||||||
return render_template('profile.html', error=error)
|
return render_template('profile.html', error=error,user=user)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,3 +23,47 @@ td { height: 1.75em; }
|
|||||||
.error { background: #f0d6d6; padding: 0.5em; }
|
.error { background: #f0d6d6; padding: 0.5em; }
|
||||||
.hidden { display: none; }
|
.hidden { display: none; }
|
||||||
.pointer { cursor: pointer; }
|
.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 <div> - 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;}
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,16 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class=page>
|
<div class=page>
|
||||||
<div class=metanav>
|
<div class=metanav>
|
||||||
<a href="{{ url_for('list_shops') }}">List shops</a>
|
<a href="{{ url_for('list_shops') }}">Shops</a>
|
||||||
|
<div class="dropdown">
|
||||||
|
<p onclick="dropDown()" class="dropbtn">⊆⊇</p>
|
||||||
|
<div id="Dropdown" class="dropdown-content">
|
||||||
<a href="#" onclick="reload();">Reload page</a>
|
<a href="#" onclick="reload();">Reload page</a>
|
||||||
<a href="{{ url_for('profile') }}">Profile</a>
|
<a href="{{ url_for('profile') }}">Profile</a>
|
||||||
<a href="{{ url_for('logout') }}">Logout</a>
|
<a href="{{ url_for('logout') }}">Logout</a>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% for message in get_flashed_messages() %}
|
{% for message in get_flashed_messages() %}
|
||||||
<div class=flash>{{ message }}</div>
|
<div class=flash>{{ message }}</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<form action="{{ url_for('profile') }}" method=post>
|
<form action="{{ url_for('profile') }}" method=post>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Username:
|
<dt>Username:
|
||||||
<dd>
|
<dd>{{ user }}
|
||||||
<dt>Password:
|
<dt>Password:
|
||||||
<dd><input type=password name=password>
|
<dd><input type=password name=password>
|
||||||
<dd><input type=submit value=Update>
|
<dd><input type=submit value=Update>
|
||||||
|
|||||||
Reference in New Issue
Block a user