Пример #1
0
def check_timeslot_form_validation(start_str, stop_str, start_time, stop_time):
    form = TimeSlotForm({'start': start_str, 'stop': stop_str})
    form.is_valid()
    assert_true(form.is_valid())
    timeslot = form.save(commit=False)
    assert_equal(timeslot.start, start_time)
    assert_equal(timeslot.stop, stop_time)
Пример #2
0
def check_timeslot_form_validation(start_str, stop_str, start_time, stop_time):
    form = TimeSlotForm({'start': start_str, 'stop': stop_str})
    form.is_valid()
    assert_true(form.is_valid())
    timeslot = form.save(commit=False)
    assert_equal(timeslot.start, start_time)
    assert_equal(timeslot.stop, stop_time)
Пример #3
0
def fetch_hours(request):
    forms = []
    for dow, label in hours.DOW_CHOICES:
        form = TimeSlotForm(request.POST, prefix=dow)
        forms.append(form)
    if all(form.is_valid() for form in forms):
        instances = []
        for dow, form in zip([dow for dow, label in hours.DOW_CHOICES], forms):
            instance = form.save(commit=False)
            if instance:
                instance.dow = dow
                instances.append(instance)
        hour_string = hours.calculate_hour_string(instances)
        return HttpResponse(hour_string)
    else:
        return HttpResponse('')
Пример #4
0
def fetch_hours(request):
    forms = []
    for dow, label in hours.DOW_CHOICES:
        form = TimeSlotForm(request.POST, prefix=dow)
        forms.append(form)
    if all(form.is_valid() for form in forms):
        instances = []
        for dow, form in zip([dow for dow, label in hours.DOW_CHOICES], forms):
            instance = form.save(commit=False)
            if instance:
                instance.dow = dow
                instances.append(instance)
        hour_string = hours.calculate_hour_string(instances)
        return HttpResponse(hour_string)
    else:
        return HttpResponse('')