Exemplo n.º 1
0
def update(request, schedule_id):
    schedule = Schedule()
    schedule.Id = request.POST['id']
    schedule.Name = request.POST['name']
    schedule.StartDateDisplay = request.POST['startdate']
    schedule.StartDate = time.strptime(schedule.StartDateDisplay, "%d/%m/%Y")
    schedule.StatusTypeId = request.POST['statustype']
    schedule.StatusDateDisplay = request.POST.get('statusdate', '')
    schedule.StatusDate = time.strptime(schedule.StatusDateDisplay,
                                        "%d/%m/%Y") if schedule.StatusDateDisplay != '' else None

    schedule = UpdateWorkingDays(request, schedule)
    scheduleService = ScheduleService

    if schedule_id != 0:
        scheduleService.Update(schedule)
    else:
        scheduleService.Add(schedule)

    return HttpResponseRedirect('/schedule')