def saveRestrictees(request): alpha = request.user.username.split('m') alpha = alpha[1] cMid = Mid.objects.get(alpha=alpha) cCompany = cMid.company cUnit = Unit.objects.get(company = cCompany) if request.method != "POST" : return HttpResponseRedirect('/') cRest = Restriction.objects.get(daysRemaining__gt = 0, mid = Mid.objects.get(alpha = request.POST['alpha'])) cRest.checked = date.today() cRest.save() if time(datetime.now().hour, datetime.now().minute, 0) < time(8, 0, 0): cDate = date.today() - timedelta(days = 1) else : cDate = date.today() cReport = Zero8.objects.get(reportDate = reportDate, company = cUnit) cInspection = Inspections(zero8 = cReport, type = "C", inspector = cMid, inspectee = Mid.objects.get(alpha = request.POST['alpha']), time = time(8,0,0), scoreEarned = 0, scorePossible = 0, SAT = True, comment = "" ) cInspection.save() return HttpResponseRedirect(reverse('zero8:restrictees'))
def saveStudyHour(request): alpha = request.user.username.split('m') alpha = alpha[1] cMid = Mid.objects.get(alpha=alpha) cCompany = cMid.company cUnit = Unit.objects.get(company = cCompany) #Safety feature, makes sure we POST data to this view if request.method != "POST" : return HttpResponseRedirect('/') if time(datetime.now().hour, datetime.now().minute, 0) < time(8, 0, 0): cDate = date.today() - timedelta(days = 1) else : cDate = date.today() cReport = Zero8.objects.get(reportDate = cDate, company = cUnit) SAT = request.POST['SAT'] if SAT == "True" : SAT = True else : SAT = False cInspection = Inspections(zero8 = cReport, type = "S", inspector = cMid, room = Room.objects.get(roomNumber = request.POST['roomNumber']), time = time(8,0,0), scoreEarned = 0, scorePossible = 0, SAT = SAT, comment = request.POST['comment'] ) cInspection.save() return HttpResponseRedirect(reverse('zero8:studyHour'))