Skip to content

Commit

Permalink
Merge pull request #16836 from mzazrivec/migrate_display_names_for_mo…
Browse files Browse the repository at this point in the history
…dels

Migrate model display names from locale/en.yml to models
  • Loading branch information
bdunne authored Jun 7, 2018
2 parents ab46fd5 + 4d31b2a commit 0bd16ab
Show file tree
Hide file tree
Showing 152 changed files with 611 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/models/auth_private_key.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
class AuthPrivateKey < Authentication
acts_as_miq_taggable

def self.display_name(number = 1)
n_('Private Key', 'Private Keys', number)
end
end
4 changes: 4 additions & 0 deletions app/models/auth_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ def auth_key=(val)
@auth_changed = true if val != auth_key
super(val)
end

def self.display_name(number = 1)
n_('Authentication Token', 'Authentication Tokens', number)
end
end
4 changes: 4 additions & 0 deletions app/models/auth_userid_password.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ def userid=(val)
@auth_changed = true if val != userid
super(val)
end

def self.display_name(number = 1)
n_('Password', 'Passwords', number)
end
end
3 changes: 3 additions & 0 deletions app/models/authentication_allow_all.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class AuthenticationAllowAll < Authentication
def self.display_name(number = 1)
n_('Authentication (Allow All)', 'Authentications (Allow All)', number)
end
end
3 changes: 3 additions & 0 deletions app/models/authentication_github.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class AuthenticationGithub < Authentication
def self.display_name(number = 1)
n_('Authentication (GitHub)', 'Authentications (GitHub)', number)
end
end
3 changes: 3 additions & 0 deletions app/models/authentication_google.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class AuthenticationGoogle < Authentication
def self.display_name(number = 1)
n_('Authentication (Google)', 'Authentications (Google)', number)
end
end
3 changes: 3 additions & 0 deletions app/models/authentication_htpasswd.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class AuthenticationHtpasswd < Authentication
def self.display_name(number = 1)
n_('Authentication (HTTP Password)', 'Authentications (HTTP Password)', number)
end
end
4 changes: 4 additions & 0 deletions app/models/authentication_ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ def assign_values(options)
end
super(hash)
end

def self.display_name(number = 1)
n_('Authentication (LDAP)', 'Authentications (LDAP)', number)
end
end
3 changes: 3 additions & 0 deletions app/models/authentication_open_id.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class AuthenticationOpenId < Authentication
def self.display_name(number = 1)
n_('Authentication (OpenID)', 'Authentications (OpenID)', number)
end
end
3 changes: 3 additions & 0 deletions app/models/authentication_rhsm.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class AuthenticationRhsm < Authentication
def self.display_name(number = 1)
n_('Authentication (RHSM)', 'Authentications (RHSM)', number)
end
end
4 changes: 4 additions & 0 deletions app/models/chargeback_container_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ def self.report_col_options
}
end

def self.display_name(number = 1)
n_('Chargeback for Image', 'Chargebacks for Image', number)
end

private

def init_extra_fields(consumption, _region)
Expand Down
4 changes: 4 additions & 0 deletions app/models/chargeback_container_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def self.report_col_options
}
end

def self.display_name(number = 1)
n_('Chargeback for Projects', 'Chargebacks for Projects', number)
end

private

def init_extra_fields(consumption, _region)
Expand Down
4 changes: 4 additions & 0 deletions app/models/chargeback_vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ def self.vms(region)
end
end

def self.display_name(number = 1)
n_('Chargeback for VMs', 'Chargebacks for VMs', number)
end

private

def init_extra_fields(consumption, region)
Expand Down
4 changes: 4 additions & 0 deletions app/models/classification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,10 @@ def self.sanitize_name(name)
name.downcase.tr('^a-z0-9_:', '_')[0, NAME_MAX_LENGTH]
end

def self.display_name(number = 1)
n_('Category', 'Categories', number)
end

private

def self.add_entries_from_hash(cat, entries)
Expand Down
4 changes: 4 additions & 0 deletions app/models/compliance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ def self.set_compliancy(compliant, target, event, details)
end
end
end

def self.display_name(number = 1)
n_('Compliance History', 'Compliance Histories', number)
end
end
4 changes: 4 additions & 0 deletions app/models/configuration_script_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ class ConfigurationScriptSource < ApplicationRecord
belongs_to :manager, :class_name => "ExtManagementSystem"

virtual_total :total_payloads, :configuration_script_payloads

def self.display_name(number = 1)
n_('Repository', 'Repositories', number)
end
end
3 changes: 3 additions & 0 deletions app/models/container_env_var.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
class ContainerEnvVar < ApplicationRecord
belongs_to :container
def self.display_name(number = 1)
n_('Container Environment Variable', 'Container Environment Variables', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@ def disconnect_inv
self.deleted_on = Time.now.utc
save
end

def self.display_name(number = 1)
n_('Pod', 'Pods', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_group_performance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ class ContainerGroupPerformance < MetricRollup
default_scope { where("resource_type = 'ContainerGroup' and resource_id IS NOT NULL") }

belongs_to :container_group, :foreign_key => :resource_id, :class_name => ContainerGroup.name

def self.display_name(number = 1)
n_('Pod Performance', 'Pod Performances', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_node_performance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ class ContainerNodePerformance < MetricRollup
default_scope { where("resource_type = 'ContainerNode' and resource_id IS NOT NULL") }

belongs_to :container_node, :foreign_key => :resource_id, :class_name => ContainerNode.name

def self.display_name(number = 1)
n_('Container Node Performance', 'Container Nodes Performances', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_performance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ class ContainerPerformance < MetricRollup
default_scope { where("resource_type = 'Container' and resource_id IS NOT NULL") }

belongs_to :container_node, :foreign_key => :resource_id, :class_name => Container.name

def self.display_name(number = 1)
n_('Performance - Container', 'Performance - Containers', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_project_performance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ class ContainerProjectPerformance < MetricRollup
default_scope { where("resource_type = 'ContainerProject' and resource_id IS NOT NULL") }

belongs_to :container_node, :foreign_key => :resource_id, :class_name => ContainerProject.name

def self.display_name(number = 1)
n_('Performance - Container Project', 'Performance - Container Projects', number)
end
end
4 changes: 4 additions & 0 deletions app/models/custom_button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,8 @@ def copy(options = {})
options[:guid] = SecureRandom.uuid
options.each_with_object(dup) { |(k, v), button| button.send("#{k}=", v) }.tap(&:save!)
end

def self.display_name(number = 1)
n_('Button', 'Buttons', number)
end
end
4 changes: 4 additions & 0 deletions app/models/custom_button_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,8 @@ def deep_copy(options)
custom_buttons.each { |cb| cbs.add_member(cb.copy(:applies_to => options[:owner])) }
end
end

def self.display_name(number = 1)
n_('Button Group', 'Button Groups', number)
end
end
4 changes: 4 additions & 0 deletions app/models/ems_cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,8 @@ def self.non_openstack_clusters_exists?
def openstack_cluster?
ext_management_system.class == ManageIQ::Providers::Openstack::InfraManager
end

def self.display_name(number = 1)
n_('Cluster / Deployment Role', 'Clusters / Deployment Roles', number)
end
end
4 changes: 4 additions & 0 deletions app/models/ems_cluster_performance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ class EmsClusterPerformance < MetricRollup
default_scope { where("resource_type = 'EmsCluster' and resource_id IS NOT NULL") }

belongs_to :ems_cluster, :foreign_key => :resource_id

def self.display_name(number = 1)
n_('Cluster Performance', 'Cluster Performances', number)
end
end
4 changes: 4 additions & 0 deletions app/models/ems_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ def manager_refresh_targets
ext_management_system.class::EventTargetParser.new(self).parse
end

def self.display_name(number = 1)
n_('Management Event', 'Management Events', number)
end

private

def self.event_allowed_ems_ref_keys
Expand Down
4 changes: 4 additions & 0 deletions app/models/ems_folder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ def self.child_folder_paths(folder, *args)
child_folder_paths_recursive(subtree, options)
end

def self.display_name(number = 1)
n_('Folder', 'Folders', number)
end

# Helper method for building the child folder paths given an arranged subtree.
def self.child_folder_paths_recursive(subtree, options = {})
options[:prefix] ||= ""
Expand Down
4 changes: 4 additions & 0 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,10 @@ def self.inventory_status
data
end

def self.display_name(number = 1)
n_('Manager', 'Managers', number)
end

private

def build_connection(options = {})
Expand Down
4 changes: 4 additions & 0 deletions app/models/ext_management_system_performance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ class ExtManagementSystemPerformance < MetricRollup
default_scope { where("resource_type = 'ExtManagementSystem' and resource_id IS NOT NULL") }

belongs_to :ext_management_system, :foreign_key => :resource_id

def self.display_name(number = 1)
n_('Performance - Provider', 'Performance - Providers', number)
end
end
4 changes: 4 additions & 0 deletions app/models/file_depot_ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ def file_exists?(file_or_directory)
false
end

def self.display_name(number = 1)
n_('FTP', 'FTPs', number)
end

private

def create_directory_structure(directory_path)
Expand Down
4 changes: 4 additions & 0 deletions app/models/file_depot_ftp_anonymous.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ class FileDepotFtpAnonymous < FileDepotFtp
def login_credentials
["anonymous", "anonymous"]
end

def self.display_name(number = 1)
n_('Anonymous FTP', 'Anonymous FTPs', number)
end
end
4 changes: 4 additions & 0 deletions app/models/file_depot_smb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ def self.validate_settings(settings)
def verify_credentials(_auth_type = nil, cred_hash = nil)
self.class.validate_settings(cred_hash.merge(:uri => uri))
end

def self.display_name(number = 1)
n_('Samba', 'Sambas', number)
end
end
4 changes: 4 additions & 0 deletions app/models/floating_ip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ def self.class_by_ems(ext_management_system)
# TODO: use a factory on ExtManagementSystem side to return correct class for each provider
ext_management_system && ext_management_system.class::FloatingIp
end

def self.display_name(number = 1)
n_('Floating IP', 'Floating IPs', number)
end
end
4 changes: 4 additions & 0 deletions app/models/generic_object_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ def generic_custom_buttons
CustomButton.buttons_for("GenericObject")
end

def self.display_name(number = 1)
n_('Generic Object Class', 'Generic Object Classes', number)
end

private

def get_objects_of_association(attr, values)
Expand Down
4 changes: 4 additions & 0 deletions app/models/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1778,4 +1778,8 @@ def normalized_state
def validate_destroy
{:available => true, :message => nil}
end

def self.display_name(number = 1)
n_('Host / Node', 'Hosts / Nodes', number)
end
end
4 changes: 4 additions & 0 deletions app/models/host_performance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ class HostPerformance < MetricRollup

belongs_to :ems_cluster, :foreign_key => :parent_ems_cluster_id
belongs_to :host, :foreign_key => :resource_id

def self.display_name(number = 1)
n_('Performance - Host', 'Performance - Hosts', number)
end
end
4 changes: 4 additions & 0 deletions app/models/iso_datastore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ def synchronize_advertised_images
_log.info("Synchronizing images on #{log_for}...Complete")
rescue ManageIQ::Providers::Redhat::InfraManager::OvirtServices::Error
end

def self.display_name(number = 1)
n_('ISO Datastore', 'ISO Datastores', number)
end
end
4 changes: 4 additions & 0 deletions app/models/iso_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ class IsoImage < ApplicationRecord
belongs_to :pxe_image_type

has_many :customization_templates, :through => :pxe_image_type

def self.display_name(number = 1)
n_('ISO Image', 'ISO Images', number)
end
end
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class ManageIQ::Providers::AutomationManager::Authentication < Authentication
def self.display_name(number = 1)
n_('Credential', 'Credentials', number)
end
end
4 changes: 4 additions & 0 deletions app/models/manageiq/providers/base_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ def self.options_description
{}
end
end

def self.display_name(number = 1)
n_('Manager', 'Managers', number)
end
end
4 changes: 4 additions & 0 deletions app/models/manageiq/providers/cloud_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,9 @@ def sync_root_tenant
def create_cloud_tenant(options)
CloudTenant.create_cloud_tenant(self, options)
end

def self.display_name(number = 1)
n_('Cloud Manager', 'Cloud Managers', number)
end
end
end
4 changes: 4 additions & 0 deletions app/models/manageiq/providers/cloud_manager/auth_key_pair.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ def delete_key_pair_queue(userid)
def delete_key_pair
raw_delete_key_pair
end

def self.display_name(number = 1)
n_('Key Pair', 'Key Pairs', number)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ def self.create_stack(orchestration_manager, stack_name, template, options = {})
def self.orchestration_stack_class_factory(orchestration_manager, template)
"#{orchestration_manager.class.name}::#{template.stack_type}".constantize
end

def self.display_name(number = 1)
n_('Orchestration Stack', 'Orchestration Stacks', number)
end
end
Loading

0 comments on commit 0bd16ab

Please sign in to comment.