Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #3912 - add inheritance for locations / organizations #1105

Closed
wants to merge 1 commit into from

Conversation

isratrade
Copy link
Member

No description provided.

@@ -203,6 +203,7 @@ select{padding: initial;}
.collapse .inputs-list li{ margin-left:20px; }

.delete{color: #b94a48 !important; cursor: auto;}
.inherited{font-weight: bold !important; cursor: auto;}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just to differentiate disabled items that are disabled because used by host or disabled because inherited. There is is a tooltip if disabled because inherited

@isratrade
Copy link
Member Author

re-committed. added some tests and ready for review

@@ -35,6 +35,14 @@ def new
end
end

def nest
@taxonomy = taxonomy_class.new
Taxonomy.no_taxonomy_scope do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why without scope? shouldnt it be the parent scope or something like that? could this be abused?

@isratrade
Copy link
Member Author

@ohadlevy, do you want this feature merged soon?

@ohadlevy
Copy link
Member

ohadlevy commented Jan 7, 2014

@isratrade yes please :)

@isratrade
Copy link
Member Author

@abenari, I have one failure caused by test/unit/classification_test.rb:38
It seems to have to do with the matcher but I didn't add inheritance in the fixtures, so I'm confused what changed.

<"test"> expected but was
<"secret">. (test_0004_enc_should_return_updated_cluster_param)
/var/lib/workspace/workspace/test_develop_pull_request@4/database/sqlite3/puppet/3.0/ruby/1.8.7/test/unit/classification_test.rb:38    

@ohadlevy
Copy link
Member

ohadlevy commented Jan 9, 2014

@isratrade ping?

@isratrade
Copy link
Member Author

@ohadlevy, I don't understand the test failure to classification_test. It would be good if another set of eyes could look at it.

@isratrade
Copy link
Member Author

@ohadlevy, classification_test now passes after some not changing to_label. Note that without PR #1104, the inherited items from parent (on the right selected side) can be unselected which is not good.

@isratrade
Copy link
Member Author

re-committed and access_permission_test now passes. [test]

@isratrade
Copy link
Member Author

same issue. failure only on mysql / ruby 2 that I don't think is relevant

@isratrade
Copy link
Member Author

Added new commit to disable used locations/organizations on edit form for domain, subnet, etc. I also included the js needed in PR #1104

@isratrade
Copy link
Member Author

re-committed with fixes to taxonomix.rb that caused failing tests

@domcleal
Copy link
Contributor

@isratrade ignore the sqlite/1.9.3 error, but you have integration test failures

@isratrade
Copy link
Member Author

@domcleal, not sure about the integration failures that popped up. I can't reproduce them locally. I'm continue tomorrow.

@@ -17,6 +17,7 @@ class ApplicationController < ActionController::Base
before_filter :set_taxonomy, :require_mail, :check_empty_taxonomy
before_filter :welcome, :only => :index, :unless => :api_request?
before_filter :authorize
before_filter :clean_taxonomy_ids, :only => [:create, :update]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is needed, since the the locations / organizations tab was switch to use multi-select.js and apparently this js library sends duplicate ids
ex.
params[:domain][:location_ids] = [","45", "45"] even though the [selected_ids] array does not have any duplicates.

@isratrade
Copy link
Member Author

there are still two test failures on cloning location / organization because Smart Proxy fixtures are not valid due to duplicate URL's

conditions[:organization_id] = Array.wrap(org).map(&:id) if org
conditions[:location_id] = Array.wrap(loc).map(&:id) if loc
conditions[:organization_id] = org.path_ids if org
conditions[:location_id] = loc.path_ids if loc
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all tests should now pass. I also made this change above and squashed it.

@isratrade
Copy link
Member Author

added new commit. changes are.

  1. context of viewing of hosts (or other objects), scope by location / organization and their children (not parents)
  2. context of creating new host, scope objects by location / organization and their parents
    [test]

end

def selected_or_inherited_parameters
LocationParameter.where(:reference_id => path_ids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't as intelligent as Hostgroup#parameters. The hg version will iterate over the ancestry in order and override parameters as it gets deeper, while this implementation won't - we should unify them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@domcleal, to re-factor this efficiently, I either need to cherry-pick the changes to NestedAncestryCommon in PR ##1155 or wait until it's merged. Or, I can temporarily duplicate code from hostgroup.rb here in location.rb if this PR is going to be merged first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do 1155 first then, thanks.

@domcleal
Copy link
Contributor

By the way, you have some integration test failures.

One more difference I noticed between this and host groups is that the parent host group is shown in a select box when you edit it. Could we add this to the taxonomy edit page? I think it'd be safe to make it editable even, but if there's an issue, then it could be left disabled.

}

scoped_search :on => :label, :complete_value => :true, :default_order => true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was added to location.rb and organization.rb even though it appears in the NestedAncestryCommon mix. Otherwise, the autocompleter won't find "label = "

@isratrade
Copy link
Member Author

I assume the failure on Ruby 1.8.7 sqlite3 only is from jenkins.

@@ -87,6 +95,9 @@ def destroy
else
process_error
end
rescue Ancestry::AncestryException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[done] Can you add this to the taxonomies API controller concern too please?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, added to api controller

@isratrade
Copy link
Member Author

re-factored and with all fixes to comments.

@@ -70,8 +75,7 @@ def step2

def update
result = Taxonomy.no_taxonomy_scope do
(params[taxonomy_single.to_sym][:ignore_types] -= ["0"]) if params[taxonomy_single.to_sym][:ignore_types]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is now handle in the before_validation in the model

@isratrade
Copy link
Member Author

@domcleal, if I use the same code for inherited parameters in locs/orgs as in hostgroups, then it doesn't show inherited values. Should this bug http://projects.theforeman.org/issues/4348 need to prevent the merger of this PR?

@domcleal
Copy link
Contributor

@isratrade no, let's fix that later, it's only a UI issue

@isratrade
Copy link
Member Author

@ohadlevy, removed unused view partial and re-commited

@isratrade
Copy link
Member Author

rebased after multi-select commit

@domcleal
Copy link
Contributor

Thanks @isratrade! Merged as 1fa008a for Foreman 1.5. Nice work :)

@domcleal domcleal closed this Feb 19, 2014
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants