stc

a simple time card webapp
git clone _git@git.brennen.work:stc.git
Log | Files | Refs | README

commit f0fe96107a404bcc617e5f9f63fe0090f570224b
parent b375dfc7df89bab957019a091e65f44edf83afc5
Author: Brennen T. Mazur <brennen@madis.cool>
Date:   Wed, 21 Dec 2022 12:29:58 -0700

changed admin and dashboard index to layout files reflecting use. Created reports, roles, and agreements widgets and pages

Diffstat:
Mapp.py | 24+++++++++++++++---------
Atemplates/admin/agreements/widget.html | 31+++++++++++++++++++++++++++++++
Dtemplates/admin/index.html | 0
Atemplates/admin/layout.html | 16++++++++++++++++
Atemplates/admin/layout.html.old | 10++++++++++
Atemplates/admin/reports/widget.html | 6++++++
Dtemplates/admin/roles.html | 0
Atemplates/admin/roles/index.html | 14++++++++++++++
Atemplates/admin/roles/widget.html | 31+++++++++++++++++++++++++++++++
Mtemplates/base.html | 9+++++----
Dtemplates/dashboard/index.html | 10----------
Atemplates/dashboard/layout.html | 17+++++++++++++++++
Mtemplates/punchclock/index.html | 37+++++++++++++++++++++----------------
Mtemplates/punchclock/widget.html | 6+++---
14 files changed, 169 insertions(+), 42 deletions(-)

diff --git a/app.py b/app.py @@ -1,27 +1,33 @@ import datetime from flask import Flask, render_template, abort, redirect, url_for, request; +OrganizationName = "Youth Employment Program" + app = Flask(__name__) @app.route('/') def hello(): - return render_template('index.html') + return render_template('index.html',ORGNAME = OrganizationName) #This implimentation is messy, maybe abstract to a defPage()? @app.route("/dashboard") def dashboard(): - return render_template('dashboard/index.html',currenttime=datetime.datetime.utcnow()) + return render_template('dashboard/layout.html',currenttime=datetime.datetime.utcnow(),ORGNAME=OrganizationName) -@app.route("/crewlist") -def crewlist(): - return render_template ('crewlist/index.html') +@app.route("/admin") +def admin(): + return render_template ('admin/layout.html',ORGNAME=OrganizationName) -@app.route("/changehours")#modify to take userid ex. /changehours<userid> -def changeHours():#userid goes into call to db to get user[] -> then returns formatted table (punchclock/index.html - return render_template ('punchclock/index.html') +@app.route("/hours")#modify to take userid ex. /hours<userid> for "admin" +def hours():#userid goes into call to db to get user[] -> then returns formatted table (punchclock/index.html + return render_template ('punchclock/index.html',ORGNAME=OrganizationName) @app.route("/fleet") def fleet(): - return render_template('fleet/index.html') + return render_template('fleet/index.html',ORGNAME=OrganizationName) + +@app.route("/admin/roles") +def roles(): + return render_template('admin/roles/index.html',ORGNAME=OrganizationName) # @app.route("/login",methods = ['POST', 'GET']) # def login(): diff --git a/templates/admin/agreements/widget.html b/templates/admin/agreements/widget.html @@ -0,0 +1,31 @@ +<section class="activeusers"> + <h3>Clocked in Crew List</h3> + <form> + <input type="submit" value="Clock Crew Out"> + <table><!-- replace w/ function getUserHours(username) --> + <tr><!-- FOR EACH clocked in user iterate user ...does each user need to be its own form? --> + <td><input type="button" onclick="alert('route to /changehours<user1>')" value="user1.name"></td> + <td><input type="checkbox" name="onCrew" checked><label for="onCrew">On Crew</label></td> + <td><input type="checkbox" name="perdium"><label for="perdium">Perdium</label></td> + <td><input type="button" onclick="alert('route to /changehours<user1>')" value="user1.timeIn"></td> + <td><input type="submit" value="Clock Out"></td> + </tr> + <tr><!-- FOR EACH clocked in user iterate user ...does each user need to be its own form? --> + <td><input type="button" onclick="alert('route to /changehours<user2>')" value="user2.name"></td> + <td><input type="checkbox" name="onCrew" checked><label for="onCrew">On Crew</label></td> + <td><input type="checkbox" name="perdium"><label for="perdium">Perdium</label></td> + <td><input type="button" onclick="alert('route to /changehours<user2>')" value="user2.timeIn"></td> + <td><input type="submit" value="Clock Out"></td> + </tr> + </form> + <form> + <tr><!-- clock in clocked out user --> + <th><select><option value="user3.name" selected>user3.name</option><option value="user4.name">user4.name</option><option value="user5.name">user5.name</option></select></th> + <td><input type="checkbox" name="onCrew" checked><label for="onCrew">On Crew</label></td> + <td><input type="checkbox" name="perdium"><label for="perdium">Perdium</label></td> + <td><input type="time" value="12:12"/></td> + <td><input type="submit" value="Clock in New Member"></td> + </tr> + </table> + </form> +</section> diff --git a/templates/admin/index.html b/templates/admin/index.html diff --git a/templates/admin/layout.html b/templates/admin/layout.html @@ -0,0 +1,16 @@ +{% extends 'base.html' %} + +{% block title %}Management{% endblock %} + +{% block content %} + <section class="admin-grid"> + <!--functioncall checking role for admin. while loop return permissioned 'widgets' --> + + <!-- returned values from admin check is array of permissive ACCESS else return 'missing permissions response' --> + {%- for x in ['reports','agreements','roles'] %} + {% include 'admin/'~x~'/widget.html' %} + {%- else-%} + {{ 'You do not have permission to access this page' }} + {%- endfor %} + </section> +{% endblock %} diff --git a/templates/admin/layout.html.old b/templates/admin/layout.html.old @@ -0,0 +1,10 @@ +{% extends 'base.html' %} + +{% block content %} + <section class="admin-grid"> + <!--functioncall checking role for admin. while loop return permissioned 'widgets' --> + {% include 'admin/roles/widget.html' %}<!--roles widget should allow role selection. role page should allow per user selection of permissions and add/"remove" user --> + {% include 'admin/reports/widget.html' %} <!-- graph/chart of funding for most recent projects. page allows selections of what to return for payroll etc. --> + {% include 'admin/agreements/widget.html' %} <!-- add modify organization agreements --> + </section> +{% endblock %} diff --git a/templates/admin/reports/widget.html b/templates/admin/reports/widget.html @@ -0,0 +1,6 @@ +<section class="activeusers"> + <h3>Reports</h3> + <input type="button" value="Current Payperiod"> + <input type="button" value="Agreements"> + <input type="button" value="Employee"> +</section> diff --git a/templates/admin/roles.html b/templates/admin/roles.html diff --git a/templates/admin/roles/index.html b/templates/admin/roles/index.html @@ -0,0 +1,14 @@ +{% extends 'base.html' %} +{% block title %}Employees/Crew/Roles{% endblock %} + +{% block content %} +<table> <tr><th>Name</th><th>Role</th><th>Active Employee</th></tr> + <tr> + <td><input type="button" onClick="alert('route to /user<userid>')" value="Brennen T. Mazur"></td><td><select><option value="Crew Lead" selected>Crew Lead</option><option value="Crew">Crew</option><option value="Accounting">Accounting</option><option value="Admin">Admin</option></select></td><td><input type="checkbox" name="activeEmployee" checked></td> + </tr> + <tr> + <td><input type="button" onClick="alert('route to /user<userid>')" value="Nikolas Mazur"></td><td><select><option value="Crew" selected>Crew</option><option value="Crew Lead">Crew Lead</option><option value="Accounting">Accounting</option><option value="Admin">Admin</option></select></td><td><input type="checkbox" name="activeEmployee"></td> + </tr> + <tr><td><input type="button" onClick="alert('route to /newuser')" value="[new Employee]"</td></tr> + +{% endblock %} diff --git a/templates/admin/roles/widget.html b/templates/admin/roles/widget.html @@ -0,0 +1,31 @@ +<section class="activeusers"> + <h3>Clocked in Crew List</h3> + <form> + <input type="submit" value="Clock Crew Out"> + <table><!-- replace w/ function getUserHours(username) --> + <tr><!-- FOR EACH clocked in user iterate user ...does each user need to be its own form? --> + <td><input type="button" onclick="alert('route to /changehours<user1>')" value="user1.name"></td> + <td><input type="checkbox" name="onCrew" checked><label for="onCrew">On Crew</label></td> + <td><input type="checkbox" name="perdium"><label for="perdium">Perdium</label></td> + <td><input type="button" onclick="alert('route to /changehours<user1>')" value="user1.timeIn"></td> + <td><input type="submit" value="Clock Out"></td> + </tr> + <tr><!-- FOR EACH clocked in user iterate user ...does each user need to be its own form? --> + <td><input type="button" onclick="alert('route to /changehours<user2>')" value="user2.name"></td> + <td><input type="checkbox" name="onCrew" checked><label for="onCrew">On Crew</label></td> + <td><input type="checkbox" name="perdium"><label for="perdium">Perdium</label></td> + <td><input type="button" onclick="alert('route to /changehours<user2>')" value="user2.timeIn"></td> + <td><input type="submit" value="Clock Out"></td> + </tr> + </form> + <form> + <tr><!-- clock in clocked out user --> + <th><select><option value="user3.name" selected>user3.name</option><option value="user4.name">user4.name</option><option value="user5.name">user5.name</option></select></th> + <td><input type="checkbox" name="onCrew" checked><label for="onCrew">On Crew</label></td> + <td><input type="checkbox" name="perdium"><label for="perdium">Perdium</label></td> + <td><input type="time" value="12:12"/></td> + <td><input type="submit" value="Clock in New Member"></td> + </tr> + </table> + </form> +</section> diff --git a/templates/base.html b/templates/base.html @@ -2,18 +2,19 @@ <html> <head> <meta charset="UTF-8"> - <title>{% block title %} {% endblock %} - {% block orgname %} {% endblock %}</title> + <title>{% block title %} {% endblock %} - {{ ORGNAME }}</title> <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}"> </head> <body> + <nav> + <!-- functioncall for inserting <a> for permissive pages --> + </nav> + <section class="appview"> {% block content %} {% endblock %} <!-- functioncall for checking role IF logged in route /dashboard else LOGIN(templates/index.html) --> </section> - <nav> - <!-- functioncall for inserting <a> for permissive pages --> - </nav> </body> </html> diff --git a/templates/dashboard/index.html b/templates/dashboard/index.html @@ -1,10 +0,0 @@ -{% extends 'base.html' %} - -{% block content %} - <div class="base-grid"> - <!-- for loop or while loop displaying each 'widget' the logged in user has permission to access --> - {% include 'punchclock/widget.html' %} - {% include 'activeusers/widget.html' %} - {% include 'fleet/widget.html' %} - </div> -{% endblock %} diff --git a/templates/dashboard/layout.html b/templates/dashboard/layout.html @@ -0,0 +1,17 @@ +{% extends 'base.html' %} + +{% block title %}Dashboard{% endblock %} + +{% block content %} + <section class="base-grid"> + <!-- TODO: function call for permissive ACCESS, returns array of strings --> + + <!-- For loop takes getWidget()'s -> [] iterates through to include Accessabe widgets, else deny's request --> + {%- for x in ['punchclock','activeusers','fleet'] %} + {% include x~'/widget.html' %} + {%- else %} + {{ 'You do not have permission to access this page' }}<!--reroute to login page on no access? --> + {%- endfor %} + + </section> +{% endblock %} diff --git a/templates/punchclock/index.html b/templates/punchclock/index.html @@ -1,5 +1,7 @@ {% extends 'base.html' %} +{% block title %}Hours{% endblock %} + {% block content %} <section class="hours-grid"> <h3>username</h3><!-- abstract to 'welcome' function more like python var insert. IF logged in user has permission allow this username section to be a dropdown for modifying user time sheets. --> @@ -15,31 +17,34 @@ <th>Project</th> <th>Start</th> <th>Finish</th> + <th>Lunch</th> <th>Purdium</th> <th>Add Project</th> <th>Remove Time</th> </tr> <tr><!-- for loop iterating over document entries --> - <th><input type="date"value="2023-01-03"min="2023-01-01"max="2023-01-15">or Wednesday Jan 3rd?</th> - <th><select><option selected>Project #1</option><option>Project #2</option><option>Project #3</option></select></th> - <th><input type="time" value="12:12"/></th> - <th><input type="time" value="01:11"/></th> - <th><input type="checkbox"></input></th> - <th><button>+</button></th> - <th><button>-</button></th> + <td><input type="date"value="2023-01-03"min="2023-01-01"max="2023-01-15">or Wednesday Jan 3rd?</td> + <td><select><option selected>Project #1</option><option>Project #2</option><option>Project #3</option></select></td> + <td><input type="time" value="12:12"/></td> + <td><input type="time" value="01:11"/></td> + <td><input type="checkbox"></input></td> + <td><input type="checkbox"></input></td> + <td><button>+</button></td> + <td><button>-</button></td> </tr> <tr> - <th>Wednesday Jan 2rd</th> - <th><select><option>Project #1</option><option selected>Project #2</option><option>Project #3</option></select></th> - <th><input type="time" value="12:12"/></th> - <th><input type="time" value="01:11"/></th> - <th><input type="checkbox"></input></th> - <th><button>+</button></th> - <th><button>-</button></th> + <td>Wednesday Jan 2rd</td> + <td><select><option>Project #1</option><option selected>Project #2</option><option>Project #3</option></select></td> + <td><input type="time" value="12:12"/></td> + <td><input type="time" value="01:11"/></td> + <td><input type="checkbox"></input></td> + <td><input type="checkbox"></input></td> + <td><button>+</button></td> + <td><button>-</button></td> </tr> <tr><!-- getUserHours(username) if note present returns following tr --> - <th></th><!-- date space --> - <th>note:<input type="text" value="reason for requested change"/></th> + <td></td><!-- date space --> + <td>note:<input type="text" value="reason for requested change"/></td> </tr> </table> </form> diff --git a/templates/punchclock/widget.html b/templates/punchclock/widget.html @@ -1,13 +1,13 @@ <section class="punchclock"> <h2>{{ currenttime }}</h2> - <button href="{{ url_for('changeHours') }}">Modify Hours</button><!--routes to userhours.html--> + <button><a href="{{ url_for('hours') }}">Modify Hours</a></button><!--routes to userhours.html--> <form> <select name="Project Name"><!--replace w/ selectProject() or FOR EACH loop for array passed as available Projects... Leaning towards latter --> <option value="#">$#</option><!-- for/while loop displaying each $projectName user has permission for --> <option value="2" selected>second project</option> - <option value="3" selected>third project</option> + <option value="3">third project</option> </select> - <input type="submit" value="Clock In"><!--if user.isClockedIn()returns true value="Clock Out" elseif user.isClockedIn() returns true AND Project Name = isClockedIn().projectname CLOCK OUT and CLOCK IN with new PROJECT NAME --> + <input type="submit" value="Clock In"><!--if user.isClockedIn()returns true value="Clock Out" AND Purdium changes to Lunch checkbox, elseif user.isClockedIn() returns true AND Project Name = isClockedIn().projectname CLOCK OUT and CLOCK IN with new PROJECT NAME --> <input type="checkbox" name="Perdium" value="perdium"> <label for="Perdium">Perdium</label> </form>