From 8adc4c220a3da86ce80687794d8486ee02a55f12 Mon Sep 17 00:00:00 2001 From: mrschnei <mrschnei@umich.edu> Date: Tue, 30 Jun 2020 16:20:36 -0400 Subject: [PATCH] Added user profile --- servicePoints/templates/index.html | 117 ++++++++++++++++++----- servicePoints/templates/userProfile.html | 19 ++++ servicePoints/views/accounts.py | 5 + 3 files changed, 119 insertions(+), 22 deletions(-) create mode 100644 servicePoints/templates/userProfile.html diff --git a/servicePoints/templates/index.html b/servicePoints/templates/index.html index 45eae11..50f2bab 100644 --- a/servicePoints/templates/index.html +++ b/servicePoints/templates/index.html @@ -2,37 +2,110 @@ <html> <head> <link rel="stylesheet" type="text/css" href="/css/style.css"> + + <style> + .dropbtn { + background-color: darkgray; + color: black; + padding: 8px; + font-size: 14px; + border: none; + cursor: pointer; + } + + .dropdown { + position: relative; + display: inline-block; + float:right; + } + + .dropdown-content { + display: none; + position: absolute; + background-color: #f1f1f1; + min-width: 160px; + overflow: auto; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); + right: 0; + z-index: 1; + } + + .dropdown-content a { + color: black; + padding: 12px 16px; + text-decoration: none; + display: block; + } + + .dropdown a:hover { + background-color: #ddd; + } + + .show { + display: block; + } + </style> +</head> +<body> + Username: {{username}} + <div class="dropdown"> + <button onclick="myFunction()" class="dropbtn">Settings</button> + <div id="myDropdown" class="dropdown-content"> + <a href="/accounts/profile/">Profile</a> + <a href="/accounts/logout/">Logout</a> + </div> + </div> + <h1 style="text-align:center">Welcome to ServicePoints!</h1> - <p>{{username}}</p> <p>{{org}}</p> <p>Hours: {{hours}}</p> - <a href="/accounts/logout/">logout</a> - <a href="/accounts/delete/">delete</a> <p> - <a href="/accounts/mask/"> - <img src=/images/mask.png alt="mask"> - </a> - <a href="/accounts/blood/"> - <img src=/images/blood.png alt="blood"> - </a> - <a href="/accounts/food/"> - <img src=/images/food.png alt="food"> - </a> - <a href="/accounts/tutorsu/"> - <img src=/images/tutor.png alt="tutorsu"> - </a> - <a href="/accounts/submitPoints/"> - <img src=/images/submit.png alt="mask"> - </a> - - {% if leader == 1 %} + <a href="/accounts/mask/"> + <img src=/images/mask.png alt="mask"> + </a> + <a href="/accounts/blood/"> + <img src=/images/blood.png alt="blood"> + </a> + <a href="/accounts/food/"> + <img src=/images/food.png alt="food"> + </a> + <a href="/accounts/tutorsu/"> + <img src=/images/tutor.png alt="tutorsu"> + </a> + <a href="/accounts/submitPoints/"> + <img src=/images/submit.png alt="mask"> + </a> + + {% if leader == 1 %} <a href="/accounts/mask/"> <img src=/images/view.png alt="mask"> </a> <a href="/accounts/mask/"> <img src=/images/requests.png alt="mask"> </a> - {% endif %} + {% endif %} </p> -</head> + + <script> + /* When the user clicks on the button, + toggle between hiding and showing the dropdown content */ + function myFunction() { + document.getElementById("myDropdown").classList.toggle("show"); + } + + // Close the dropdown 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'); + } + } + } + } + </script> +</body> </html> diff --git a/servicePoints/templates/userProfile.html b/servicePoints/templates/userProfile.html new file mode 100644 index 0000000..6ffce25 --- /dev/null +++ b/servicePoints/templates/userProfile.html @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<html> +<head> + <link rel="stylesheet" type="text/css" href="/css/style.css"> + <title>Profile</title> + + <a href="/">Home</a> +</head> +<body> + <h1 style="text-align:center">Profile</h1> + + <a href="/accounts/logout/">logout</a> + <a href="/accounts/delete/">delete</a> + + + +</body> + +</html> diff --git a/servicePoints/views/accounts.py b/servicePoints/views/accounts.py index 7ae7cf5..c23453f 100644 --- a/servicePoints/views/accounts.py +++ b/servicePoints/views/accounts.py @@ -263,6 +263,11 @@ def food(): context = {} return render_template('food.html', **context) +@servicePoints.app.route('/accounts/profile/') +def profile(): + context = {} + return render_template('userProfile.html', **context) + @servicePoints.app.route('/images/<path:filename>', methods=['GET', 'POST']) def images(filename): if "username" in flask.session: -- GitLab