def total_hours(request): check_db.main() start_time = request.POST.get('from') end_time = request.POST.get('to') user_name = request.POST.get('user_name') pay_data = getPayPeriod(start_time, end_time, user_name) return render(request, 'total_hours.html', pay_data)
def total_hours(request): if(request.method == 'POST'): check_db.main() start_time = request.POST.get('from') end_time = request.POST.get('to') user_name = request.POST.get('user_name') pay_data = getPayPeriod(start_time, end_time, user_name) return render_to_response('total_hours.html', pay_data, context_instance=RequestContext(request)) return render_to_response('login.html', context_instance=RequestContext(request))
def get(self, request, timesheet_id): # accept = request.META['HTTP_ACCEPT'] # user = request.user try: timesheet = Timesheet.objects.get(id=timesheet_id) except Timesheet.DoesNotExist: return HttpResponseBadRequest(json.dumps("Timesheet %s does not exist" % str(timesheet_id)), content_type="application/json") # if 'application/json' in accept: # return HttpResponse(json.dumps({'timesheetList': timesheets}), content_type="application/json") check_db.main() start = date.fromtimestamp(timesheet.start) end = date.fromtimestamp(timesheet.end) empUsername = timesheet.employee.username pay_data = getPayPeriod(str(start), str(end), empUsername, timesheet.hourly_rate) return render(request, 'timesheetPayData.html', pay_data)
def get(self, request, timesheet_id): accept = request.META['HTTP_ACCEPT'] user = request.user try: timesheet = Timesheet.objects.get(id=timesheet_id) except Timesheet.DoesNotExist: return HttpResponseBadRequest(json.dumps("Timesheet %s does not exist" % str(timesheet_id)), content_type="application/json") if 'application/json' in accept: return HttpResponse(json.dumps({'timesheetList': timesheets}), content_type="application/json") check_db.main() start = date.fromtimestamp(timesheet.start) end = date.fromtimestamp(timesheet.end) empUsername = timesheet.employee.username pay_data = getPayPeriod(str(start), str(end), empUsername, timesheet.hourly_rate) t = loader.get_template('timesheetPayData.html') c = RequestContext(request, pay_data) return HttpResponse(t.render(c), content_type="text/html")