Example #1
0
def index():
    cmd = facade.list_models_cmd()
    models = cmd()
    public_form = facade.model_public_form()
    model_public_dcts = [public_form.fill_with_model(model) for model in models]
    context = {'models': model_public_dcts,'admin_path':router.to_path(admin)}
    return TemplateResponse(context)
Example #2
0
def index():
    cmd = facade.list_models_cmd()
    models = cmd()
    edit_path = router.to_path(edit)
    delete_path = router.to_path(delete)
    short_form = facade.model_short_form()

    def short_model_dict(model):
        model_dct = short_form.fill_with_model(model)
        model_dct["edit_path"] = router.to_path(edit_path, model_dct["id"])
        model_dct["delete_path"] = router.to_path(delete_path, model_dct["id"])
        return model_dct

    short_models = [short_model_dict(model) for model in models]
    context = {"models": short_models, "new_path": router.to_path(new)}
    return TemplateResponse(context)