def edit(request, week_id, hours_id): """ Edits a person assigned to a week """ week = get_object_or_404(Week, pk=week_id) person_hours = get_object_or_404(WeekDayPersonHours, pk=hours_id) if request.method == 'POST': form = WeekDayPersonHoursAssignForm(request.POST, instance=person_hours) if form.is_valid(): form.save() return HttpResponseRedirect('../../view/') else: form = WeekDayPersonHoursAssignForm(instance=person_hours) data = {} data['title'] = 'Edit Assignment' data['form'] = form data['week'] = week return direct_to_template(request, 'admin/board/week/assign.html', data)
def assign(request, week_id): """ Assigns a person to a week """ week = get_object_or_404(Week, pk=week_id) if request.method == 'POST': form = WeekDayPersonHoursAssignForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('../view/') else: person_hours = WeekDayPersonHours() person_hours.week = week form = WeekDayPersonHoursAssignForm(instance=person_hours) data = {} data['title'] = 'Assign Week' data['form'] = form data['week'] = week return direct_to_template(request, 'admin/board/week/assign.html', data)