Greetings!
Please review the pull request #28: 9429 prevent editing node name opened by (djsauble2)
Some more information about the pull request:
- Opened: Wed Sep 14 17:16:55 UTC 2011
- Based on: puppetlabs:master (2d92f0f2e9440b082fbafe7e4696d39b3f7fd2da)
- Requested merge: djsauble2:9429_prevent_editing_node_name (055de0116f2090a5c9e49b9f1bb5118ff68c2724)
Description:
Changes made to the node model (name attribute is now attr_readonly), and edit node view (name field is now readonly).
Thanks!
The Pull Request Bot
Diff follows:
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb
index 3545aa2..cff2847 100644
--- a/app/controllers/nodes_controller.rb
+++ b/app/controllers/nodes_controller.rb
@@ -65,6 +65,8 @@ class NodesController < InheritedResources::Base
end
def edit
+ # Make the node name readonly
+ @readonly_name = "readonly"
edit! do |format|
format.html {
set_group_and_class_autocomplete_data_sources(@node)
diff --git a/app/models/node.rb b/app/models/node.rb
index 14012f1..8111029 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -8,6 +8,7 @@ class Node < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :name
+ attr_readonly :name
has_many :node_class_memberships, :dependent => :destroy
has_many :node_classes, :through => :node_class_memberships
diff --git a/app/views/nodes/_form.html.haml b/app/views/nodes/_form.html.haml
index 3ed9347..64b5efd 100644
--- a/app/views/nodes/_form.html.haml
+++ b/app/views/nodes/_form.html.haml
@@ -1,4 +1,4 @@
-= focus :node_name
+= focus (@readonly_name) ? :node_description : :node_name
= header_for(form)
@@ -7,7 +7,7 @@
.element
= form.label :node, "Node"
- = form.text_field :name, :placeholder => "Enter the node name here"
+ = form.text_field :name, :placeholder => "Enter the node name here", :readonly => @readonly_name
.element.textarea
= form.label :description
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index e5a92ec..8aaaa5e 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -281,7 +281,8 @@ body {
margin-right: 5%;
float: left; }
body .section {
- margin-bottom: 1.5em; }
+ margin-bottom: 1.5em;
+ overflow: auto; }
body .section.error {
-webkit-border-radius: 0.35em 0.35em 0.35em 0.35em;
-moz-border-radius: 0.35em 0.35em 0.35em 0.35em;
diff --git a/public/stylesheets/forms.css b/public/stylesheets/forms.css
index 0dbf77f..f7dadce 100644
--- a/public/stylesheets/forms.css
+++ b/public/stylesheets/forms.css
@@ -67,6 +67,10 @@ form .header input {
width: 80%;
}
+form input[readonly] {
+ background-color: #EEE;
+}
+
form .header label {
display: none;
}
diff --git a/public/stylesheets/sass/application.scss b/public/stylesheets/sass/application.scss
index 419af24..9fd611a 100644
--- a/public/stylesheets/sass/application.scss
+++ b/public/stylesheets/sass/application.scss
@@ -506,6 +506,7 @@ body {
.section {
margin-bottom: 1.5em;
+ overflow: auto;
&.error {
@include icony_section('failed',
diff --git a/spec/controllers/nodes_controller_spec.rb b/spec/controllers/nodes_controller_spec.rb
index 9c0184c..c854034 100644
--- a/spec/controllers/nodes_controller_spec.rb
+++ b/spec/controllers/nodes_controller_spec.rb
@@ -98,8 +98,7 @@ describe NodesController do
%w[foo,_-' bar/\\$^ <ba"z>>].each do |name|
it "should handle a node named #{name}" do
- @node.name = name
- @node.save
+ node = Node.generate!(:name => name)
get :index, :format => "csv"
response.should be_success
@@ -332,9 +331,9 @@ describe NodesController do
describe 'and the data provided make the node valid' do
it 'should update the node with the data provided' do
- @params[:node]['name'] = 'new name'
+ @params[:node]['description'] = 'new description'
do_put
- Node.find(@node.id).name.should == 'new name'
+ Node.find(@node.id).description.should == 'new description'
end
it 'should have a valid node' do
diff --git a/spec/models/node_spec.rb b/spec/models/node_spec.rb
index 8fa63e2..2804f4f 100644
--- a/spec/models/node_spec.rb
+++ b/spec/models/node_spec.rb
@@ -15,6 +15,7 @@ describe Node do
it { should have_db_column(:name).of_type(:string) }
it { should validate_presence_of(:name) }
it { should validate_uniqueness_of(:name) }
+ it { should have_readonly_attribute(:name) }
end
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
