From: Tomas Sedovic <[email protected]>
---
src/app/controllers/resources/pools_controller.rb | 22 +++++++++++++++++---
src/app/views/resources/pools/_list.haml | 1 -
src/app/views/resources/pools/_properties.haml | 1 +
src/app/views/resources/pools/edit.haml | 8 +++++++
4 files changed, 27 insertions(+), 5 deletions(-)
create mode 100644 src/app/views/resources/pools/edit.haml
diff --git a/src/app/controllers/resources/pools_controller.rb
b/src/app/controllers/resources/pools_controller.rb
index 3cb44f7..e09a892 100644
--- a/src/app/controllers/resources/pools_controller.rb
+++ b/src/app/controllers/resources/pools_controller.rb
@@ -26,10 +26,6 @@ class Resources::PoolsController < ApplicationController
end
end
- def edit
- render :text => "Edit Pool #{params[:id]}"
- end
-
def new
require_privilege(Privilege::POOL_MODIFY)
@pool = Pool.new
@@ -52,6 +48,24 @@ class Resources::PoolsController < ApplicationController
end
end
+ def edit
+ require_privilege(Privilege::POOL_MODIFY)
+
+ @pool = Pool.find(params[:id])
+ end
+
+ def update
+ require_privilege(Privilege::POOL_MODIFY)
+
+ @pool = Pool.find(params[:id])
+ if @pool.update_attributes(params[:pool])
+ flash[:notice] = "Pool updated."
+ redirect_to :action => 'show', :id => @pool.id
+ else
+ render :action => :edit
+ end
+ end
+
protected
def load_pools
diff --git a/src/app/views/resources/pools/_list.haml
b/src/app/views/resources/pools/_list.haml
index 51791cd..b621dc2 100644
--- a/src/app/views/resources/pools/_list.haml
+++ b/src/app/views/resources/pools/_list.haml
@@ -1,6 +1,5 @@
- form_tag do
= restful_submit_tag "New Pool", "new", new_resources_pool_path, 'GET'
- = restful_submit_tag "Edit", "edit", edit_resources_pool_path(@pools.first),
'GET'
%p
Select:
= link_to "All", @url_params.merge(:select => 'all')
diff --git a/src/app/views/resources/pools/_properties.haml
b/src/app/views/resources/pools/_properties.haml
index f50055c..066a491 100644
--- a/src/app/views/resources/pools/_properties.haml
+++ b/src/app/views/resources/pools/_properties.haml
@@ -1,3 +1,4 @@
%h3
Properties for
= @pool.name
+= link_to "Edit", edit_resources_pool_path(@pool), { :class => 'button' }
diff --git a/src/app/views/resources/pools/edit.haml
b/src/app/views/resources/pools/edit.haml
new file mode 100644
index 0000000..43bb6d0
--- /dev/null
+++ b/src/app/views/resources/pools/edit.haml
@@ -0,0 +1,8 @@
+%h3
+ Editing pool
+ = @pool.name
+
+- form_for [:resources, @pool] do |form|
+ = form.text_field :name
+ = form.error_message_on :name, 'Name '
+ = form.submit 'Save'
--
1.7.3.3
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel