|
|
|
@ -20,7 +20,7 @@ Trestle.resource(:users) do |
|
|
|
toolbar.link 'CV', instance, action: :generate, method: :get, style: :primary, icon: "fa fa-file-pdf", target: "_blank" |
|
|
|
toolbar.link 'CLS', instance, action: :generate_cls, method: :get, style: :secondary, icon: "fa", target: "_blank" |
|
|
|
toolbar.link 'JSON', instance, action: :generate_json, method: :get, style: :secondary, icon: "fa", target: "_blank" |
|
|
|
# TODO: Add a new action to clone the user and all its associations passing a "cloned" label to the new user. |
|
|
|
toolbar.link 'Clone', instance, action: :clone, method: :post, style: :secondary, icon: "fa fa-copy" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
@ -59,11 +59,19 @@ Trestle.resource(:users) do |
|
|
|
ac = ActionController::Base.new() |
|
|
|
ac.render_to_string(layout: false, template: "templates/awesome/#{template}", locals: { "@user": user } ) |
|
|
|
end |
|
|
|
|
|
|
|
def clone |
|
|
|
user = admin.find_instance(params) |
|
|
|
cloned_user = user.clone!(label: "cloned") |
|
|
|
flash[:message] = "User cloned as ##{cloned_user.id}." |
|
|
|
redirect_to users_admin_path(cloned_user) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
routes do |
|
|
|
get :generate, on: :member |
|
|
|
get :generate_cls, on: :member |
|
|
|
get :generate_json, on: :member |
|
|
|
post :clone, on: :member |
|
|
|
end |
|
|
|
end |
|
|
|
|