Skip to content

Commit

Permalink
Merge pull request #1138 from komidore64/library_no_i18n
Browse files Browse the repository at this point in the history
878341 - [ja_JP][SAM Web GUI] Default environment name 'Library'
  • Loading branch information
komidore64 committed Nov 28, 2012
2 parents b316cbe + 56de39b commit 8fef277
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/app/controllers/api/environments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def create
see "environments#create"
def update
if @environment.library?
raise HttpErrors::BadRequest, _("Can't update Library environment")
raise HttpErrors::BadRequest, _("Can't update the '%s' environment") % "Library"
else
@environment.update_attributes!(params[:environment])
render :json => @environment
Expand Down
8 changes: 4 additions & 4 deletions src/app/controllers/api/filters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def update

render :json => @filter.to_json
end

api :GET, "/organizations/:organization_id/filters/:id", "Show package filter details"
param :organization_id, :identifier, :desc => "oranization identifier", :required => true
param :id, :identifier, :desc => "filter identifier", :required => true
Expand All @@ -108,7 +108,7 @@ def list_product_filters
render :json => @product.filters.to_json
end

api :PUT, "/organizations/:organization_id/products/:product_id/filters", "Update package filters for product"
api :PUT, "/organizations/:organization_id/products/:product_id/filters", "Update package filters for product"
param :organization_id, :identifier, :desc => "oranization identifier", :required => true
param :product_id, :identifier, :desc => "product identifier", :required => true
param :filters, Array, :desc => "Updated list of filters", :required => true
Expand All @@ -130,7 +130,7 @@ def list_repository_filters

render :json => filters.uniq.to_json
end

api :PUT, "/repositories/:repository_id/filters", "Update package filters for repository"
param :repository_id, :identifier, :desc => "repository identifier", :required => true
param :filters, Array, :desc => "Updated list of filters", :required => true
Expand Down Expand Up @@ -162,7 +162,7 @@ def find_product
def find_repository
@repository = Repository.find(params[:repository_id])
raise HttpErrors::NotFound, _("Couldn't find repository '%s'") % params[:repository_id] if @repository.nil?
raise HttpErrors::BadRequest, _("Filters can be stored only in Library repositories.") if not @repository.environment.library?
raise HttpErrors::BadRequest, _("Filters can be stored only in the '%s' repositories.") % "Library" if not @repository.environment.library?
@repository
end

Expand Down
4 changes: 2 additions & 2 deletions src/app/controllers/api/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def destroy
#
# TODO: these should really be done as validations, but the orchestration engine currently converts them into OrchestrationExceptions
#
raise HttpErrors::BadRequest, _("Repositories can be deleted only in Library environment.") if not @repository.environment.library?
raise HttpErrors::BadRequest, _("Repositories can be deleted only in the '%s' environment.") % "Library" if not @repository.environment.library?
raise HttpErrors::BadRequest, _("Repository cannot be deleted since it has already been promoted. Using a changeset, please delete the repository from existing environments before deleting it.") if @repository.promoted?

@repository.destroy
Expand Down Expand Up @@ -181,7 +181,7 @@ def package_group_categories
param :id, :identifier, :required => true
def gpg_key_content
if @repository.gpg_key && @repository.gpg_key.content.present?
render(:text => @repository.gpg_key.content, :layout => false)
render(:text => @repository.gpg_key.content, :layout => false)
else
head(404)
end
Expand Down
2 changes: 1 addition & 1 deletion src/app/controllers/api/systems_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def find_organization

def find_only_environment
if !@environment && @organization && !params.has_key?(:environment_id)
raise HttpErrors::BadRequest, _("Organization %s has 'Library' environment only. Please create an environment for system registration.") % @organization.name if @organization.environments.empty?
raise HttpErrors::BadRequest, _("Organization %s has the '%s' environment only. Please create an environment for system registration.") % [@organization.name, "Library"] if @organization.environments.empty?

# Some subscription-managers will call /users/$user/owners to retrieve the orgs that a user belongs to.
# Then, If there is just one org, that will be passed to the POST /api/consumers as the owner. To handle
Expand Down
2 changes: 1 addition & 1 deletion src/app/controllers/api/templates_content_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def remove_repo
def find_template
@template = SystemTemplate.find(params[:template_id])
raise HttpErrors::NotFound, _("Couldn't find template '%s'") % params[:template_id] if @template.nil?
raise HttpErrors::BadRequest, _("Templates can be updated only in a Library environment") if not @template.environment.library?
raise HttpErrors::BadRequest, _("Templates can be updated only in the '%s' environment") % "Library" if not @template.environment.library?
@template
end

Expand Down
10 changes: 5 additions & 5 deletions src/app/controllers/api/templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def show
param :parent_id, :number, :desc => "parent template numeric identifier"
end
def create
raise HttpErrors::BadRequest, _("New templates can be created only in a Library environment") if not @environment.library?
raise HttpErrors::BadRequest, _("New templates can be created only in the '%s' environment") % "Library" if not @environment.library?

@template = SystemTemplate.new(params[:template])
@template.environment = @environment
Expand All @@ -91,7 +91,7 @@ def create
param :name, :identifier, :desc => "template new name"
end
def update
raise HttpErrors::BadRequest, _("Templates can be updated only in a Library environment") if not @template.environment.library?
raise HttpErrors::BadRequest, _("Templates can be updated only in the '%s' environment") % "Library" if not @template.environment.library?

clones = @template.get_clones
@template.attributes = params[:template].slice(:name, :parent_id, :description)
Expand Down Expand Up @@ -122,7 +122,7 @@ def destroy
param :parent_id, :number, :desc => "parent template numeric identifier"
end
def import
raise HttpErrors::BadRequest, _("New templates can be imported only into a Library environment") if not @environment.library?
raise HttpErrors::BadRequest, _("New templates can be imported only into the '%s' environment") % "Library" if not @environment.library?

begin
temp_file = File.new(File.join("#{Rails.root}/tmp", "template_#{SecureRandom.hex(10)}.json"), 'w+', 0600)
Expand All @@ -142,7 +142,7 @@ def import
api :GET, "/templates/:id/validate", "Validate a template TDL"
param :id, :number, :desc => "template numeric identifier", :required => true
def validate
raise HttpErrors::BadRequest, _("Cannot validate templates for the Library environment.") if @template.environment.library?
raise HttpErrors::BadRequest, _("Cannot validate templates for the '%s' environment.") % "Library" if @template.environment.library?

respond_to do |format|
format.tdl { @template.validate_tdl; render :text => 'OK' and return }
Expand All @@ -153,7 +153,7 @@ def validate
api :GET, "/templates/:id/export", "Export template as TDL or JSON"
param :id, :number, :desc => "template numeric identifier", :required => true
def export
raise HttpErrors::BadRequest, _("Cannot export templates for the Library environment.") if @template.environment.library?
raise HttpErrors::BadRequest, _("Cannot export templates for the '%s' environment.") % "Library" if @template.environment.library?

respond_to do |format|
format.tdl { render(:text => @template.export_as_tdl, :content_type => Mime::TDL) and return }
Expand Down
3 changes: 1 addition & 2 deletions src/app/controllers/environments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def edit
# the edit view
prior_envs = envs_no_successors - [@environment] - @environment.path
env_labels = Hash[ *prior_envs.collect { |p| [ p.id, p.display_name ] }.flatten]
#env_labels[''] = _("Library")
@env_labels_json = ActiveSupport::JSON.encode(env_labels)

@selected = @environment.prior.nil? ? env_labels[""] : env_labels[@environment.prior.id]
Expand Down Expand Up @@ -100,7 +99,7 @@ def update
@environment.save!

if priorUpdated
result = @environment.prior.nil? ? _("Library") : @environment.prior.name
result = @environment.prior.nil? ? "Library" : @environment.prior.name
else
result = params[:kt_environment].values.first
end
Expand Down
2 changes: 1 addition & 1 deletion src/app/models/activation_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def environment_exists
end

def environment_not_library
errors.add(:base, _("Cannot create activation keys in Library environment ")) if environment and environment.library?
errors.add(:base, _("Cannot create activation keys in the '%s' environment") % "Library") if environment and environment.library?
end

def environment_key_conflict
Expand Down
4 changes: 2 additions & 2 deletions src/app/models/changeset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class NotInLibraryValidator < ActiveModel::Validator
def validate(record)
record.errors[:environment] << _("Library environment cannot contain a changeset!") if record.environment.library?
record.errors[:environment] << _("The '%s' environment cannot contain a changeset!") % "Library" if record.environment.library?
end
end

Expand Down Expand Up @@ -239,7 +239,7 @@ def as_json(options = nil)
)
end

protected
protected

def validate_content! elements
elements.each { |e| raise ActiveRecord::RecordInvalid.new(e) if not e.valid? }
Expand Down
1 change: 0 additions & 1 deletion src/app/models/kt_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def successor
end

def display_name
return _("Library") if self.library?
self.name
end

Expand Down
2 changes: 1 addition & 1 deletion src/app/models/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class LibraryPresenceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << N_("must contain 'Library'") if value.select {|e| e.library}.empty?
record.errors[attribute] << N_("must contain '%s'") % "Library" if value.select {|e| e.library}.empty?
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/app/models/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class NonLibraryEnvironmentValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return unless value
record.errors[attribute] << N_("Cannot register a system with 'Library' environment ") if record.environment != nil && record.environment.library?
record.errors[attribute] << N_("Cannot register a system to the '%s' environment") % "Library" if record.environment != nil && record.environment.library?
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/app/views/organizations/_edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
.jbreadcrumb.grid_9
%ul
%li
=link_to _('Library'), "#", :class => "crumb-nohover"
=link_to 'Library', "#", :class => "crumb-nohover"
- for env in path
%li
%a.subpanel_element{"data-url"=>edit_organization_environment_path(@organization.label, env.id)}
Expand Down
6 changes: 3 additions & 3 deletions src/app/views/promotions/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@



//Div for dep. content
//Div for dep. content
#dialog_content{:style => "word-wrap: break-word;", :title=>"#{_('Package Dependencies')}"}

= help_tip_button
Expand All @@ -124,7 +124,7 @@
'a changeset, click the "Review" button to place the changeset in a ' + |
'locked state for review and when ready click the "Delete" button to ' + |
'apply it to the current environment. Note: deletion of content from ' + |
'Library is not allowed using a deletion changeset.<BR/><BR/>')) |
'%s is not allowed using a deletion changeset.<BR/><BR/>') % "Library") |

.grid_16
= environment_selector(:url_proc=>breadcrumb_url_proc, :accessible_envs=>accessible_envs)
Expand Down Expand Up @@ -205,7 +205,7 @@
= render :partial=>"common/tupane"
#content_tree.left.sliding_tree
- if show_new_button?(manage_promotion_changesets, manage_deletion_changesets)
- next_env = @next_environment.nil? ? "" : "&next_env_id=" + @next_environment.id.to_s
Expand Down

0 comments on commit 8fef277

Please sign in to comment.