def leavespage (request): user = request.user if request.GET.has_key ("viewfor") and request.user.is_staff: user = User.objects.get (id = request.GET.get ("viewfor")) this_year = datetime.datetime.today().year cl, total_cl, sl, total_sl, el, total_el, ml, zl = Leave.counts_of_user (user, this_year) trackrecord = Leave.track_record_of_user (user, this_year) allusers = User.objects.all () return render (request, "leaves.html", locals())
def applyleave (request): if request.method == "POST": leaveform = LeaveForm (request.POST) if leaveform.is_valid (): from_ = leaveform.cleaned_data["from_"] to = leaveform.cleaned_data["to"] Leave.apply (request.user, leaveform.cleaned_data["leave_type"], leaveform.cleaned_data["partial"], from_, to, leaveform.cleaned_data["reason"]) return HttpResponseRedirect ("/leaves/?applied=true") else: leaveform = LeaveForm () return render (request, "apply.html", locals())
def leavespage(request): user = request.user if request.GET.has_key("viewfor") and request.user.is_staff: user = User.objects.get(id=request.GET.get("viewfor")) this_year = datetime.datetime.today().year cl, total_cl, sl, total_sl, el, total_el, ml, zl = Leave.counts_of_user( user, this_year) trackrecord = Leave.track_record_of_user(user, this_year) allusers = User.objects.all() return render(request, "leaves.html", locals())
def applyleave(request): if request.method == "POST": leaveform = LeaveForm(request.POST) if leaveform.is_valid(): from_ = leaveform.cleaned_data["from_"] to = leaveform.cleaned_data["to"] Leave.apply(request.user, leaveform.cleaned_data["leave_type"], leaveform.cleaned_data["partial"], from_, to, leaveform.cleaned_data["reason"]) return HttpResponseRedirect("/leaves/?applied=true") else: leaveform = LeaveForm() return render(request, "apply.html", locals())
def filealeave (request): employees = User.objects.all () if request.method == "POST": leaveform = LeaveForm (request.POST) u = User.objects.get (id = request.POST.get ("employee")) if leaveform.is_valid (): from_ = leaveform.cleaned_data["from_"] to = leaveform.cleaned_data["to"] Leave.apply (u, leaveform.cleaned_data["leave_type"], leaveform.cleaned_data["partial"], from_, to, leaveform.cleaned_data["reason"]) return HttpResponseRedirect ("/su/?created=true") else: leaveform = LeaveForm () return render (request, "filealeave.html", locals())
def leaveaction (request, leaveid, action): #print userid, action leave = Leave.byId (leaveid) if leave is None: return HttpResponseRedirect ("/su/?action=nosuchleave") leave.approve (request.user, action) return HttpResponseRedirect ("/su/?action=done")
def removeleave (request, leaveid): #print userid, action print request.META leave = Leave.byId (leaveid) if leave is None: return HttpResponseRedirect ("/su/?action=nosuchleave") leave.delete () return HttpResponseRedirect (request.GET.get ("next", "/"))
def superuser (request): all_requests = Leave.get_pending () mydepts = get_departments (request.user) pending_requests = [] for r in all_requests: if r.user.userprofile.department in mydepts or request.user.is_superuser: pending_requests.append (r) return render (request, "superuser.html", locals())
def indexpage (request): #profile = request. this_year = datetime.datetime.today().year cl, total_cl, sl, total_sl, el, total_el, ml, zl = Leave.counts_of_user (request.user, this_year) upcomingbday = UserProfile.upcoming_birthdays() upcomingholidays = Holiday.upcoming () reporting_managers = request.user.userprofile.get_all_managers return render (request, "index.html", locals())
def indexpage(request): #profile = request. this_year = datetime.datetime.today().year cl, total_cl, sl, total_sl, el, total_el, ml, zl = Leave.counts_of_user( request.user, this_year) upcomingbday = UserProfile.upcoming_birthdays() upcomingholidays = Holiday.upcoming() reporting_managers = request.user.userprofile.get_all_managers return render(request, "index.html", locals())