commit 2e1612082208ec41adb9d54c8c9720534fa37deb
parent b393f0757edea13eb425d215ebe08f1b9f1d61a2
Author: Brennen T. Mazur <brennen@madis.cool>
Date: Fri, 3 Feb 2023 15:12:41 -0700
fixed navigation layout, linked logout route(doesn't work yet though, throws method not allowed (405)
Diffstat:
10 files changed, 57 insertions(+), 27 deletions(-)
diff --git a/app/models.py b/app/models.py
@@ -76,6 +76,7 @@ class User():
return jsonify(user), 200
+#ought to update this fn
def signout(self):
session.clear()
return redirect('/login')
@@ -90,6 +91,7 @@ class User():
# return jsonify({ 'error': 'Invalid login' }), 401
+#ought to update this fn
@validator('username')
def username_alphanumeric(cls, v):
assert v.isalnum(), 'Username must be alphanumeric'
diff --git a/app/routes.py b/app/routes.py
@@ -38,7 +38,6 @@ def hello():
return render_template('index.html',ORGNAME = OrganizationName) #This implimentation of ORGNAME is messy, maybe abstract to a defPage()?
@app.route("/logout", methods=['GIT'])
-@login_required
def logout():
logout_user()
return redirect(url_for('login'))
@@ -86,27 +85,41 @@ def dashboard():
return render_template('dashboard/layout.html',currenttime=currenttime,projects=available_projects,form=form,ORGNAME=OrganizationName)
@app.route("/admin")
+@login_required
def admin():
return render_template ('admin/layout.html',ORGNAME=OrganizationName)
-@app.route("/hours")#modify to take userid ex. /hours<userid> for "admin"
+@app.route("/hours")#modify to take userid ex. /hours<userid> for "admin" currently pulls from current_user... simply always pass username to hours(if possible set a default to current_user)
+@login_required
def hours():#userid goes into call to db to get user[] -> then returns formatted table (punchclock/index.html
- return render_template ('dashboard/punchclock/index.html',user=user,ORGNAME=OrganizationName)
+ return render_template ('dashboard/punchclock/index.html',ORGNAME=OrganizationName)
-@app.route("/fleet")
-def fleet():
- return render_template('dashboard/fleet/index.html',ORGNAME=OrganizationName)
+# Don't really need this until additional functionality is added, not in current project scope
+#@app.route("/fleet")
+#def fleet():
+# return render_template('dashboard/fleet/index.html',ORGNAME=OrganizationName)
@app.route("/admin/roles")
+@login_required
def roles():
return render_template('admin/roles/index.html',ORGNAME=OrganizationName)
@app.route("/admin/agreement")
+@login_required
def agreement():
return render_template('admin/agreement/index.html',ORGNAME=OrganizationName)
@app.route("/docs")
+@login_required
def knowlegebase():
return render_template('knowlegebase/index.html',ORGNAME=OrganizationName)
# Page Routes
+
+# DEVELOPMENT ROUTES, remove before production
+
+@app.route("/usrs")
+@login_required
+def listusers():
+ allusers = mongo.db.user_collection.find()
+ return render_template('dev/usrs.html', allusers=allusers)
diff --git a/app/static/css/main.css b/app/static/css/main.css
@@ -36,9 +36,9 @@ header {
padding:0rem 1.5rem 0rem 1.5rem;
margin:1rem 0rem 0rem 0rem;
width:auto;
- height:5em;
- grid-template-columns: min-content auto min-content min-content;
- grid-template-areas: "logo navi doc logout";
+ height:3em;
+ grid-template-columns: min-content auto min-content;
+ grid-template-areas: "logo navi logout";
align-self:center;
#logo {
grid-area:logo;
@@ -56,10 +56,6 @@ header {
place-self:center;
}
- #doc {
- grid-area:doc;
- align-self:center;
- }
#logout {
grid-area:logout;
justify-self:end;
@@ -67,6 +63,13 @@ header {
}
}
+#doc {
+ position:fixed;
+ z-index:2;
+ bottom:1rem;
+ right:1.5rem;
+ align-self:center;
+}
/********** LOGIN PAGE **********/
.login-grid {
display: grid;
diff --git a/app/static/imgs/logo.svg b/app/static/imgs/logo.svg
@@ -3,8 +3,8 @@
<svg
version="1.1"
id="svg2"
- width="5em"
- height="5em"
+ width="4rem"
+ height="4rem"
viewBox="0 0 302 295"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
@@ -30,8 +30,8 @@
inkscape:label="Image"
id="g8">
<image
- width="302"
- height="295"
+ width="100%"
+ height="100%"
preserveAspectRatio="none"
style="image-rendering:optimizeQuality"
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAS4AAAEnCAYAAAAXT66LAAAgAElEQVR42uy9f3xcVZ3//zxnbm5u
diff --git a/app/static/imgs/question-mark-inside-a-circle-svgrepo-com.svg b/app/static/imgs/question-mark-inside-a-circle-svgrepo-com.svg
@@ -1,10 +1,9 @@
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<svg fill="#000000" height="800px" width="800px" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 29.536 29.536" xml:space="preserve">
+<svg fill="#000000" height="3rem" width="3rem" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 29.536 29.536" xml:space="preserve">
<g id="SVGRepo_bgCarrier" stroke-width="0"/>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
-<g id="SVGRepo_iconCarrier"> <g> <path d="M14.768,0C6.611,0,0,6.609,0,14.768c0,8.155,6.611,14.767,14.768,14.767s14.768-6.612,14.768-14.767 C29.535,6.609,22.924,0,14.768,0z M14.768,27.126c-6.828,0-12.361-5.532-12.361-12.359c0-6.828,5.533-12.362,12.361-12.362 c6.826,0,12.359,5.535,12.359,12.362C27.127,21.594,21.594,27.126,14.768,27.126z"/> <path d="M14.385,19.337c-1.338,0-2.289,0.951-2.289,2.34c0,1.336,0.926,2.339,2.289,2.339c1.414,0,2.314-1.003,2.314-2.339 C16.672,20.288,15.771,19.337,14.385,19.337z"/> <path d="M14.742,6.092c-1.824,0-3.34,0.513-4.293,1.053l0.875,2.804c0.668-0.462,1.697-0.772,2.545-0.772 c1.285,0.027,1.879,0.644,1.879,1.543c0,0.85-0.67,1.697-1.494,2.701c-1.156,1.364-1.594,2.701-1.516,4.012l0.025,0.669h3.42 v-0.463c-0.025-1.158,0.387-2.162,1.311-3.215c0.979-1.08,2.211-2.366,2.211-4.321C19.705,7.968,18.139,6.092,14.742,6.092z"/> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> <g> </g> </g> </g>
+<g id="SVGRepo_iconCarrier"> <path d="M14.768,0C6.611,0,0,6.609,0,14.768c0,8.155,6.611,14.767,14.768,14.767s14.768-6.612,14.768-14.767 C29.535,6.609,22.924,0,14.768,0z M14.768,27.126c-6.828,0-12.361-5.532-12.361-12.359c0-6.828,5.533-12.362,12.361-12.362 c6.826,0,12.359,5.535,12.359,12.362C27.127,21.594,21.594,27.126,14.768,27.126z"/> <path d="M14.385,19.337c-1.338,0-2.289,0.951-2.289,2.34c0,1.336,0.926,2.339,2.289,2.339c1.414,0,2.314-1.003,2.314-2.339 C16.672,20.288,15.771,19.337,14.385,19.337z"/> <path d="M14.742,6.092c-1.824,0-3.34,0.513-4.293,1.053l0.875,2.804c0.668-0.462,1.697-0.772,2.545-0.772 c1.285,0.027,1.879,0.644,1.879,1.543c0,0.85-0.67,1.697-1.494,2.701c-1.156,1.364-1.594,2.701-1.516,4.012l0.025,0.669h3.42 v-0.463c-0.025-1.158,0.387-2.162,1.311-3.215c0.979-1.08,2.211-2.366,2.211-4.321C19.705,7.968,18.139,6.092,14.742,6.092z"/> </g></g></g>
</svg>
diff --git a/app/templates/base.html b/app/templates/base.html
@@ -10,11 +10,11 @@
<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
</head>
<body onload="startTime()">
- <header>
- <div id="logo"><a href="/"><img src="{{ url_for('static', filename='imgs/logo.svg') }}" /></a></div> <!-- should direct to login,dashboard/admin, or main organization webpage? -->
- {% block navigation %}{% endblock %} <!-- Above function call adds admin if permissive -->
- <div id="doc"><a href="/docs"><svg fill="var(--accent)" height="4rem" width="4rem" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 29.536 29.536" xml:space="preserve"><g stroke-linecap="round" stroke-linejoin="round"/><path d="M14.768,0C6.611,0,0,6.609,0,14.768c0,8.155,6.611,14.767,14.768,14.767s14.768-6.612,14.768-14.767 C29.535,6.609,22.924,0,14.768,0z M14.768,27.126c-6.828,0-12.361-5.532-12.361-12.359c0-6.828,5.533-12.362,12.361-12.362 c6.826,0,12.359,5.535,12.359,12.362C27.127,21.594,21.594,27.126,14.768,27.126z"/> <path d="M14.385,19.337c-1.338,0-2.289,0.951-2.289,2.34c0,1.336,0.926,2.339,2.289,2.339c1.414,0,2.314-1.003,2.314-2.339 C16.672,20.288,15.771,19.337,14.385,19.337z"/> <path d="M14.742,6.092c-1.824,0-3.34,0.513-4.293,1.053l0.875,2.804c0.668-0.462,1.697-0.772,2.545-0.772 c1.285,0.027,1.879,0.644,1.879,1.543c0,0.85-0.67,1.697-1.494,2.701c-1.156,1.364-1.594,2.701-1.516,4.012l0.025,0.669h3.42 v-0.463c-0.025-1.158,0.387-2.162,1.311-3.215c0.979-1.08,2.211-2.366,2.211-4.321C19.705,7.968,18.139,6.092,14.742,6.092z"/></svg></a></div>
+ <header> <!-- logo , if userHasPermission(current_user.role) [admin] | if route is admin [dashboard] else [empty space], if current_user.is_anonymous [login] else [logout] -->
+ <div id="logo"><a href="{{ url_for('dashboard') }}"><img src="{{ url_for('static', filename='imgs/logo.svg') }}" /></a></div>
+ {% block navigation %}{% endblock %} <!-- remove from here and template pgs after nav logic above finished -->
</header>
+ <div id="doc"><a href="/docs"><svg fill="var(--accent)" height="2rem" width="2rem" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 29.536 29.536" xml:space="preserve"><g stroke-linecap="round" stroke-linejoin="round"/><path d="M14.768,0C6.611,0,0,6.609,0,14.768c0,8.155,6.611,14.767,14.768,14.767s14.768-6.612,14.768-14.767 C29.535,6.609,22.924,0,14.768,0z M14.768,27.126c-6.828,0-12.361-5.532-12.361-12.359c0-6.828,5.533-12.362,12.361-12.362 c6.826,0,12.359,5.535,12.359,12.362C27.127,21.594,21.594,27.126,14.768,27.126z"/> <path d="M14.385,19.337c-1.338,0-2.289,0.951-2.289,2.34c0,1.336,0.926,2.339,2.289,2.339c1.414,0,2.314-1.003,2.314-2.339 C16.672,20.288,15.771,19.337,14.385,19.337z"/> <path d="M14.742,6.092c-1.824,0-3.34,0.513-4.293,1.053l0.875,2.804c0.668-0.462,1.697-0.772,2.545-0.772 c1.285,0.027,1.879,0.644,1.879,1.543c0,0.85-0.67,1.697-1.494,2.701c-1.156,1.364-1.594,2.701-1.516,4.012l0.025,0.669h3.42 v-0.463c-0.025-1.158,0.387-2.162,1.311-3.215c0.979-1.08,2.211-2.366,2.211-4.321C19.705,7.968,18.139,6.092,14.742,6.092z"/></svg></a></div>
<section class="appview">
{% block content %} {% endblock %}
@@ -24,6 +24,7 @@
<footer>
Engineered with ❤ for {{ ORGNAME }} with Sawtooth Systems
</footer>
+{% if current_user.is_authenticated %}
<script>
function startTime() {
const today = new Date();
@@ -41,6 +42,7 @@ function checkTime(i) {
return i;
}
</script>
+{% endif %}
</body>
</html>
diff --git a/app/templates/dashboard/layout.html b/app/templates/dashboard/layout.html
@@ -2,7 +2,7 @@
{% block title %}Dashboard{% endblock %}
-{% block navigation %}<div id="navi"><a href="/admin">Admin</a></div><a href="/"><div id="logout">Logout</div></a>{% endblock %}
+{% block navigation %}<div id="navi"><a href="{{ url_for('admin') }}">Admin</a></div><a href="{{ url_for('logout') }}"><div id="logout">Logout</div></a>{% endblock %}
{% block content %}
<section class="base-grid">
diff --git a/app/templates/dashboard/punchclock/index.html b/app/templates/dashboard/punchclock/index.html
@@ -6,7 +6,7 @@
{% block content %}
<section class="hours-grid">
- <h3>{{ user.fname }} {{ user.lname }}</h3><!-- IF logged in user has permission allow this username section to be a dropdown for modifying user time sheets. -->
+ <h3>{{ current_user.fname }} {{ current_user.lname }}</h3><!-- IF logged in user has permission allow this username section to be a dropdown for modifying user time sheets. -->
<h1 id="clock"></h1>
<div><!-- abstract to payPeriod() -->
<h6>$payperiod range</h6>
diff --git a/app/templates/dev/usrs.html b/app/templates/dev/usrs.html
@@ -0,0 +1,11 @@
+{% extends 'base.html' %}
+
+{% block title %}users in db{% endblock %}
+
+{% block content %}
+ {%- for x in allusers %}
+ {%- print(x) %}
+ </br>
+ </br>
+ {%- endfor %}
+{% endblock %}
diff --git a/app/templates/index.html b/app/templates/index.html
@@ -2,7 +2,7 @@
{% block title %} Resource Management System {% endblock %}
-{% block navigation %}<div id="nav" href="#"></div><div id="logout"></div>{% endblock %}
+{% block navigation %}<div id="nav" href="{{ url_for('logout') }}"></div><div id="logout"></div>{% endblock %}
{% block content %}
<section class="singlepage">