Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

activation keys / systems - minor refactor to allow for reuse on syst…

…em groups

For content views, we will be updating system groups to allow
the admin to change the env/view for all systems in a group.
This will use a similar env/view widget to what is currently
used in both activation keys and systems.  In preparation for
that, this commit is moving some of the logic to be common.

This commit primarily addresses:
1. moves the definition of 'no content view' - placing it in common_i18n
   and application_helper
2. moves the logic for obtaining the content view select labels
   to application_helper
  • Loading branch information...
commit f3a46a2e0390582a9f47c7bcb80d3b966150d9bd 1 parent 37263f2
@bbuckingham bbuckingham authored
View
15 src/app/controllers/activation_keys_controller.rb
@@ -183,15 +183,6 @@ def new
setup_environment_selector(current_organization, accessible_envs)
@environment = first_env_in_path(accessible_envs)
- @content_view_labels = [[no_content_view, '']]
- if @environment
- @content_view_labels += ContentView.readable(@organization).non_default.
- in_environment(@environment).collect {|cv| [cv.name, cv.id]}
- else
- @content_view_labels = []
- end
- @selected_content_view = no_content_view
-
render :partial => "new", :locals => {:activation_key => activation_key,
:accessible_envs => accessible_envs}
end
@@ -201,18 +192,12 @@ def edit
accessible_envs = current_organization.environments
setup_environment_selector(current_organization, accessible_envs)
- content_view_labels = [[no_content_view, '']]
- content_view_labels += ContentView.readable(@organization).non_default.
- in_environment(@activation_key.environment).collect {|cv| [cv.name, cv.id]}
- selected_content_view = @activation_key.content_view.nil? ? no_content_view : @activation_key.content_view_id
products = @activation_key.content_view ? @activation_key.content_view.products(@environment) : @environment.products
render :partial => "edit", :locals => {:activation_key => @activation_key,
:editable => ActivationKey.manageable?(current_organization),
:name => controller_display_name,
:accessible_envs => accessible_envs,
- :content_view_labels => content_view_labels,
- :selected_content_view => selected_content_view,
:products => products
}
end
View
3  src/app/helpers/activation_keys_helper.rb
@@ -11,7 +11,4 @@
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
module ActivationKeysHelper
- def no_content_view
- _("No Content View")
- end
end
View
20 src/app/helpers/application_helper.rb
@@ -278,4 +278,24 @@ def kt_form_for(object, options = {}, &block)
options[:builder] = KatelloFormBuilder
form_for(object, options, &block)
end
+
+ def no_content_view
+ _("No Content View")
+ end
+
+ def content_view_select_labels(organization, environment)
+ labels = [[no_content_view, '']]
+ if environment
+ labels += ContentView.readable(organization).non_default.
+ in_environment(environment).collect {|cv| [cv.name, cv.id]}
+ else
+ labels = []
+ end
+ labels
+ end
+
+ def selected_content_view(content_view)
+ content_view.nil? ? no_content_view : content_view.id
+ end
+
end
View
4 src/app/helpers/systems_helper.rb
@@ -52,10 +52,6 @@ def content_view_select(org, env)
{:tabindex => 2})
end
- def no_content_view
- _('Select Content View')
- end
-
def system_content_view_opts
keys = {}
ContentView.readable(current_organization).non_default.each do |view|
View
4 src/app/views/activation_keys/_edit.html.haml
@@ -59,7 +59,9 @@
%label #{_("Content View")}:
.grid_10.la
- if editable
- = select_tag 'activation_key[content_view_id]', options_for_select(content_view_labels, selected_content_view)
+ = select_tag 'activation_key[content_view_id]',
+ options_for_select(content_view_select_labels(@organization, @activation_key.environment),
+ selected_content_view(@activation_key.content_view))
- else
= @content_view.nil? ? no_content_view : @content_view.name
View
3  src/app/views/activation_keys/_new.html.haml
@@ -23,7 +23,8 @@
- if Katello.config.katello?
= form.field :content_view_id, :label => _("Content View"), :wrapper => {:id => "content_views"}, :grid => [2,7] do
- = select_tag 'activation_key[content_view_id]', options_for_select(@content_view_labels, @selected_content_view),
+ = select_tag 'activation_key[content_view_id]',
+ options_for_select(content_view_select_labels(@organization, @environment), no_content_view),
:tabindex => auto_tab_index
= form.field :usage_limit, :label => _("Usage Limit"), :grid => [2,7] do
View
1  src/app/views/activation_keys/index.html.haml
@@ -19,6 +19,5 @@
= javascript do
:plain
localize({
- "noContentView": '#{no_content_view}',
"update_view": '#{escape_javascript(_('Select a Content View'))}'
});
View
3  src/app/views/common/_common_i18n.html.haml
@@ -35,5 +35,6 @@
"description": '#{escape_javascript(_('Description'))}',
"import_in_progress": function(m){ return '#{escape_javascript(_("Import in progress (%M)"))}'.replace("%M", m);},
"current_default_org" : '#{escape_javascript(_('This is your default organization.'))}',
- "make_default_org" : '#{escape_javascript(_('Make this your default organization.'))}'
+ "make_default_org" : '#{escape_javascript(_('Make this your default organization.'))}',
+ "no_content_view" : '#{no_content_view}'
});
View
1  src/app/views/systems/_new.html.haml
@@ -55,7 +55,6 @@
= javascript do
:plain
localize({
- "noContentView": '#{no_content_view}',
"update_view": '#{escape_javascript(_('Select a View'))}'
});
View
2  src/public/javascripts/activation_key.js
@@ -263,7 +263,7 @@ KT.activation_key = (function($) {
var opt_template = KT.utils.template("<option value='<%= key %>'><%= text %></option>");
// create an html option list using the response
- options += opt_template({key: "", text: i18n.noContentView});
+ options += opt_template({key: "", text: i18n.no_content_view});
$.each(response, function(key, item) {
options += opt_template({key: item.id, text: item.name});
});
View
2  src/public/javascripts/systems.js
@@ -418,7 +418,7 @@ KT.systems_page = (function() {
var opt_template = KT.utils.template("<option value='<%= key %>'><%= text %></option>");
// create an html option list using the response
- options += opt_template({key: "", text: i18n.noContentView});
+ options += opt_template({key: "", text: i18n.no_content_view});
$.each(response, function(key, item) {
options += opt_template({key: item.id, text: item.name});
});
Please sign in to comment.
Something went wrong with that request. Please try again.