Skip to content

Commit

Permalink
Migrate model display names from locale/en.yml to models
Browse files Browse the repository at this point in the history
  • Loading branch information
mzazrivec committed Jan 25, 2018
1 parent 1271f84 commit 66b808b
Show file tree
Hide file tree
Showing 152 changed files with 608 additions and 8 deletions.
4 changes: 4 additions & 0 deletions app/models/audit_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ def self.source(source)
/^([^:]+):[^`]+`([^']+).*$/ =~ source[0]
"#{File.basename($1, ".*").camelize}.#{$2}"
end

def self.display_name(number = 1)
n_('Audit Event', 'Audit Events', number)
end
end
4 changes: 4 additions & 0 deletions app/models/availability_zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def self.available
where(arel_table[:type].not_eq("ManageIQ::Providers::Openstack::CloudManager::AvailabilityZoneNull"))
end

def self.display_name(number = 1)
n_('Availability Zone', 'Availability Zones', number)
end

PERF_ROLLUP_CHILDREN = :vms

def perf_rollup_parents(interval_name = nil)
Expand Down
4 changes: 4 additions & 0 deletions app/models/bottleneck_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,8 @@ def self.remove_duplicate_find_results(recs)
a << r
end
end

def self.display_name(number = 1)
n_('Bottleneck Event', 'Bottleneck Events', 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)
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)
Expand Down
4 changes: 4 additions & 0 deletions app/models/chargeback_rate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def assigned_tags?
get_assigned_tos[:tags].present?
end

def self.display_name(number = 1)
n_('Chargeback Rate', 'Chargeback Rates', number)
end

###########################################################

private
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 @@ -183,6 +183,10 @@ def self.vms
end
end

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

private

def init_extra_fields(consumption)
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/cloud_network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def self.class_by_ems(ext_management_system, _external = false)
ext_management_system && ext_management_system.class::CloudNetwork
end

def self.display_name(number = 1)
n_('Cloud Network', 'Cloud Networks', number)
end

private

def extra_attributes_save(key, value)
Expand Down
4 changes: 4 additions & 0 deletions app/models/cloud_resource_quota.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ def method_missing(method, *args, &block)
# UI should interpret -1 as "Unknown"
method.to_s.end_with?("_quota_used") ? -1 : super
end

def self.display_name(number = 1)
n_('Cloud Resource Quota', 'Cloud Resource Quotas', number)
end
end
4 changes: 4 additions & 0 deletions app/models/cloud_subnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def raw_delete_cloud_subnet
raise NotImplementedError, _("raw_delete_cloud_subnet must be implemented in a subclass")
end

def self.display_name(number = 1)
n_('Cloud Subnet', 'Cloud Subnets', number)
end

private

def extra_attributes_save(key, value)
Expand Down
4 changes: 4 additions & 0 deletions app/models/cloud_tenant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,8 @@ def self.post_refresh_ems(ems_id, _)
def self.tenant_joins_clause(scope)
scope.includes(:source_tenant).includes(:ext_management_system)
end

def self.display_name(number = 1)
n_('Cloud Tenant', 'Cloud Tenants', number)
end
end
4 changes: 4 additions & 0 deletions app/models/cloud_volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,8 @@ def raw_delete_volume
def available_vms
raise NotImplementedError, _("available_vms must be implemented in a subclass")
end

def self.display_name(number = 1)
n_('Cloud Volume', 'Cloud Volumes', number)
end
end
4 changes: 4 additions & 0 deletions app/models/cloud_volume_backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ def delete
def raw_delete
raise NotImplementedError, _("raw_delete must be implemented in a subclass")
end

def self.display_name(number = 1)
n_('Cloud Volume Backup', 'Cloud Volume Backups', number)
end
end
4 changes: 4 additions & 0 deletions app/models/cloud_volume_snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ def delete_snapshot
def raw_delete_snapshot
raise NotImplementedError, _("raw_delete_snapshot must be implemented in a subclass")
end

def self.display_name(number = 1)
n_('Cloud Volume Snapshot', 'Cloud Volume Snapshots', number)
end
end
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
3 changes: 3 additions & 0 deletions app/models/condition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,7 @@ def self.import_from_hash(condition, options = {})
return c, status
end

def self.display_name(number = 1)
n_('Condition', 'Conditions', number)
end
end # class Condition
4 changes: 4 additions & 0 deletions app/models/configuration_script_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,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
4 changes: 4 additions & 0 deletions app/models/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ def disconnect_inv
self.deleted_on = Time.now.utc
save
end

def self.display_name(number = 1)
n_('Container', 'Containers', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ class ContainerBuild < ApplicationRecord
has_many :container_build_pods

acts_as_miq_taggable

def self.display_name(number = 1)
n_('Container Build', 'Container Builds', 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 @@ -95,4 +95,8 @@ def disconnect_inv
self.deleted_on = Time.now.utc
save
end

def self.display_name(number = 1)
n_('Container Pod', 'Container 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_('Performance - Pod', 'Performance - Pods', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,8 @@ def self.disconnect_inv(ids)
end

alias_method :perform_metadata_sync, :sync_stashed_metadata

def self.display_name(number = 1)
n_('Container Image', 'Container Images', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_image_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ class ContainerImageRegistry < ApplicationRecord
def full_name
port.present? ? "#{host}:#{port}" : host
end

def self.display_name(number = 1)
n_('Container Image Registry', 'Container Image Registries', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,8 @@ def disconnect_inv
self.deleted_on = Time.now.utc
save
end

def self.display_name(number = 1)
n_('Container Node', 'Container Nodes', 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_('Performance - Container Node', 'Performance - Container Nodes', 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.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ def disconnect_inv
self.deleted_on = Time.now.utc
save
end

def self.display_name(number = 1)
n_('Container Project', 'Container Projects', 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/container_quota.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ class ContainerQuota < ApplicationRecord

has_many :container_quota_scopes, :dependent => :destroy
has_many :container_quota_items, :dependent => :destroy

def self.display_name(number = 1)
n_('Container Quota', 'Container Quotas', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_replicator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ def event_where_clause(assoc = :ems_events)
def perf_rollup_parents(interval_name = nil)
[]
end

def self.display_name(number = 1)
n_('Container Replicator', 'Container Replicators', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ class ContainerRoute < ApplicationRecord
has_many :labels, -> { where(:section => "labels") }, :class_name => "CustomAttribute", :as => :resource, :dependent => :destroy

acts_as_miq_taggable

def self.display_name(number = 1)
n_('Container Route', 'Container Routes', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ def container_groups_count
def perf_rollup_parents(interval_name = nil)
[]
end

def self.display_name(number = 1)
n_('Container Service', 'Container Services', number)
end
end
4 changes: 4 additions & 0 deletions app/models/container_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ class ContainerTemplate < ApplicationRecord
serialize :object_labels, Hash

acts_as_miq_taggable

def self.display_name(number = 1)
n_('Container Template', 'Container Templates', 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 @@ -336,4 +336,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', 'Cluster / 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_('Performance - Cluster', 'Performance - Clusters', 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 @@ -222,6 +222,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.create_event(event)
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 @@ -674,6 +674,10 @@ def tenant_identity
User.super_admin.tap { |u| u.current_group = tenant.default_miq_group }
end

def self.display_name(number = 1)
n_('Provider', 'Providers', 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
Loading

0 comments on commit 66b808b

Please sign in to comment.