Exemple #1
0
def _save_or_update_json_response(cmd):
    try:
        course = cmd()
    except CommandExecutionException:
        return JsonResponse({'errors': cmd.errors})
    short_form=facade.course_short_form()
    return JsonResponse(short_form.fill_with_model(course))
Exemple #2
0
def _save_or_update_json_response(cmd):
    try:
        course = cmd()
    except CommandExecutionException:
        return JsonResponse({'errors': cmd.errors})
    short_form = facade.course_short_form()
    return JsonResponse(short_form.fill_with_model(course))
Exemple #3
0
def index():
    cmd = facade.list_courses_cmd()
    courses = cmd()
    edit_path = router.to_path(edit)
    delete_path = router.to_path(delete)
    short_form = facade.course_short_form()

    def short_course_dict(course):
        course_dct = short_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

    short_courses = [short_course_dict(course) for course in courses]
    context = {'courses': short_courses,
               'new_path': router.to_path(new)}
    return TemplateResponse(context)
Exemple #4
0
def index():
    cmd = facade.list_courses_cmd()
    course_list = cmd()
    short_form=facade.course_short_form()
    course_short = [short_form.fill_with_model(m) for m in course_list]
    return JsonResponse(course_short)
Exemple #5
0
def index():
    cmd = facade.list_courses_cmd()
    course_list = cmd()
    short_form = facade.course_short_form()
    course_short = [short_form.fill_with_model(m) for m in course_list]
    return JsonResponse(course_short)