def _save_or_update_json_response(cmd, _resp):
    try:
        course = cmd()
    except CommandExecutionException:
        _resp.status_code = 400
        return JsonResponse({'errors': cmd.errors})
    course_form=course_facade.course_form()
    return JsonResponse(course_form.fill_with_model(course))
def index(course_id):
    course = course_facade.get_course_cmd(course_id)()
    course_form = course_facade.course_form()
    context = {
        'save_path': router.to_path(save, course_id),
        'course': course_form.fill_with_model(course)
    }
    return TemplateResponse(context, 'courses/course_form.html')
Exemple #3
0
def index():
    cmd = course_facade.list_courses_cmd()
    courses = cmd()
    edit_path = router.to_path(edit)
    delete_path = router.to_path(delete)
    course_form = course_facade.course_form()

    def localize_course(course):
        course_dct = course_form.fill_with_model(course)
        course_dct['edit_path'] = router.to_path(edit_path, course_dct['id'])
        course_dct['delete_path'] = router.to_path(delete_path, course_dct['id'])
        return course_dct

    localized_courses = [localize_course(course) for course in courses]
    context = {'courses': localized_courses,
               'new_path': router.to_path(new)}
    return TemplateResponse(context, 'courses/course_home.html')
def index():
    cmd = course_facade.list_courses_cmd()
    course_list = cmd()
    course_form=course_facade.course_form()
    course_dcts = [course_form.fill_with_model(m) for m in course_list]
    return JsonResponse(course_dcts)
Exemple #5
0
def index(course_id):
    course = course_facade.get_course_cmd(course_id)()
    course_form = course_facade.course_form()
    context = {'save_path': router.to_path(save, course_id), 'course': course_form.fill_with_model(course)}
    return TemplateResponse(context, 'courses/course_form.html')