stc

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

commit ce5e2abb52fb55d760c2e946d4cd782f650d1404
parent e60128477e36bf3cef1c7c73d84e6e45879d3be1
Author: Youth Employment Program Production <youthemployment22@gmail.com>
Date:   Thu,  6 Jul 2023 20:36:21 -0600

fix lunch nd per diem submit for user and standard hours add

Diffstat:
Mapp/routes.py | 49++++++++++++++++++++++++++++++++++++++++---------
Mapp/templates/admin/total_timedata_report/widget.html | 9+++++++--
2 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/app/routes.py b/app/routes.py @@ -541,22 +541,26 @@ def new_time(usernm): 'date' : dateentry, 'clock_in' : [starttime], 'clock_out' : [endtime], - 'project' : form.projectSel.data}) + 'project' : form.projectSel.data, + 'lunch': form.lunchSel.data, + 'per_diem':form.perDiemSel.data}) else: mongo.db.time_collection.insert_one({ 'modified_by' : [usernm, current_user.username], 'date' : dateentry, 'clock_in' : [starttime], 'clock_out' : [endtime], - 'project' : form.projectSel.data}) + 'project' : form.projectSel.data, + 'lunch': form.lunchSel.data, + 'per_diem':form.perDiemSel.data}) return redirect(url_for('dashboard')) return render_template('dashboard/punchclock/otheruser.html',form=form,ORGNAME=OrganizationName) -@app.route("/newusertime/<usernm>",methods=['GET','POST']) +@app.route("/newusertime",methods=['GET','POST']) @login_required -def new_user_time(usernm): +def new_user_time(): clocked_in_users = mongo.db.time_collection.find({'clock_out': {'$exists':False}}) availableProjects = [] for project in mongo.db.projects_collection.find(): @@ -591,16 +595,20 @@ def new_user_time(usernm): 'date' : dateentry, 'clock_in' : [starttime], 'clock_out' : [endtime], - 'project' : form.projectSel.data}) + 'project' : form.projectSel.data, + 'lunch': form.lunchSel.data, + 'per_diem':form.perDiemSel.data}) else: mongo.db.time_collection.insert_one({ 'modified_by' : [form.userSel.data, current_user.username], 'date' : dateentry, 'clock_in' : [starttime], 'clock_out' : [endtime], - 'project' : form.projectSel.data}) + 'project' : form.projectSel.data, + 'lunch': form.lunchSel.data, + 'per_diem':form.perDiemSel.data}) - return redirect(url_for('dashboard')) + return redirect(url_for('new_user_time')) return render_template('dashboard/punchclock/otheruser.html',form=form,ORGNAME=OrganizationName) @@ -1178,7 +1186,11 @@ def time_data_total_report(): } ] )# Time Spent Per Project (filter entries by username, then group and sum hours by project) - return render_template ('admin/reports/total_timedata_report.html', hours=hours, tspp=tspp, ORGNAME=OrganizationName) + everyhours_by_user = mongo.db.time_collection.aggregate([ {'$sort':{'modified_by.0':1,'date':1}} ]) + + everyhours_by_project = mongo.db.time_collection.aggregate([ {'$sort':{'project':1,'modified_by.0':1}} ]) + + return render_template ('admin/reports/total_timedata_report.html', usors = everyhours_by_user, projours = everyhours_by_project, hours=hours, tspp=tspp, ORGNAME=OrganizationName) ####### TESTING END ####### ###### TESTING Period selection START ####### @app.route('/dev/select-date-range', methods=["GET","POST"]) @@ -1209,6 +1221,25 @@ def time_bound_report(startday,endday): begin = datetime.datetime.strptime(startday,'%Y-%m-%d') end = datetime.datetime.strptime(endday, '%Y-%m-%d') + usertimes = mongo.db.time_collection.aggregate([ + { + "$match": { + "$and":[{"date":{"$gte":begin}},{"date":{"$lt":end}}] + } + }, + { + "$lookup":{ + 'from':'user_collection', + 'localField':'modified_by.0', + 'foreignField':"username", + 'as':'userinfo' + } + }, + { + "$sort":{"userinfo.username":1} + } + ]) + allhours = mongo.db.time_collection.aggregate( [ { "$match": { @@ -1299,7 +1330,7 @@ def time_bound_report(startday,endday): ] ) - return render_template ('admin/reports/total_timedata_report.html', allhours=allhours, hours=hours, tspp=tspp, projectlookup=ptl, ORGNAME=OrganizationName) + return render_template ('admin/reports/total_timedata_report.html', usertimes=usertimes, allhours=allhours, hours=hours, tspp=tspp, projectlookup=ptl, ORGNAME=OrganizationName) ####### TESTING END ####### @app.route('/admin/reports/pay-period', methods=['GET']) diff --git a/app/templates/admin/total_timedata_report/widget.html b/app/templates/admin/total_timedata_report/widget.html @@ -68,12 +68,17 @@ {% endfor %} </table> </div> - <div>Test section - {% for elmnt in projectlookup %} + <div>Test Div + {% for elmnt in usors %} {{elmnt}}</br> {% endfor %} </div> + <div>Projours Div + {% for elmnt in projours %} + {{elmnt}}</br> + {% endfor %} + </div> </section> <section id="data-by-project">