def assignment_detail_by_date(request, date): date = dateutil.parser.parse(date).date() if not is_workday(date): return redirect(reverse("non_workday", kwargs={'date': date.strftime("%Y-%m-%d")})) assignment = get_object_or_404(Assignment, date=date) return assignment_detail(request, assignment.id)
def non_workday(request, date): date = dateutil.parser.parse(date).date() if is_workday(date): raise Http404() context = { 'holiday': is_holiday(date), 'weekend': is_weekend(date) } return render(request, "non-workday.html", context)
def eligibles(request, date): date = dateutil.parser.parse(date).date() if not is_workday(date): return redirect(reverse("non_workday", kwargs={'date': date.strftime("%Y-%m-%d")})) assignment = get_object_or_404(Assignment, date=date) eligibles = list(assignment.eligible_defer_targets()) min_deferral_weight = min([w.deferral_weight() for w in eligibles]) return render_to_response('eligibles.html', { 'date': date, 'eligibles': eligibles, 'min_deferral_weight': min_deferral_weight, 'norm_coeff': 1 / min_deferral_weight, 'assigned': assignment.worker if assignment else None })
def day_info(day): return { 'assignment': assignment_for_day(day), 'is_workday': 1 if is_workday(day) else 0 }