Commit 024d804a4a3518fa40fa46ea6cc60ff53f8da08b

Authored by Larissa Reis
1 parent 82ba86f1

Adds a label string to SEARCHABLE_FIELDS

  To make presentation easier, adds a label to SEARCHABLE_FIELDS as part
  of a hash.
app/controllers/public/invite_controller.rb
... ... @@ -8,12 +8,7 @@ class InviteController < PublicController
8 8 @import_from = params[:import_from] || "manual"
9 9 @mail_template = params[:mail_template] || environment.invitation_mail_template(profile)
10 10  
11   - extra_labels = Profile::SEARCHABLE_FIELDS.keys - [:name, :identifier, :nickname]
12   - labels = [
13   - _('Name'),
14   - _('Username'),
15   - _('Email'),
16   - ] + extra_labels.map { |label| Profile.human_attribute_name(label) }
  11 + labels = Profile::SEARCHABLE_FIELDS.except(:nickname).merge(User::SEARCHABLE_FIELDS).map { |name,info| info[:label] }
17 12 last = labels.pop
18 13 label = labels.join(', ')
19 14 @search_friend_fields = "#{label} #{_('or')} #{last}"
... ...
app/models/article.rb
... ... @@ -5,11 +5,11 @@ class Article < ActiveRecord::Base
5 5 acts_as_having_image
6 6  
7 7 SEARCHABLE_FIELDS = {
8   - :name => 10,
9   - :abstract => 3,
10   - :body => 2,
11   - :slug => 1,
12   - :filename => 1,
  8 + :name => {:label => _('Name'), :weight => 10},
  9 + :abstract => {:label => _('Abstract'), :weight => 3},
  10 + :body => {:label => _('Content'), :weight => 2},
  11 + :slug => {:label => _('Slug'), :weight => 1},
  12 + :filename => {:label => _('Filename'), :weight => 1},
13 13 }
14 14  
15 15 SEARCH_FILTERS = %w[
... ...
app/models/category.rb
1 1 class Category < ActiveRecord::Base
2 2  
3 3 SEARCHABLE_FIELDS = {
4   - :name => 10,
5   - :acronym => 5,
6   - :abbreviation => 5,
7   - :slug => 1,
  4 + :name => {:label => _('Name'), :weight => 10},
  5 + :acronym => {:label => _('Acronym'), :weight => 5},
  6 + :abbreviation => {:label => _('Abbreviation'), :weight => 5},
  7 + :slug => {:label => _('Slug'), :weight => 1},
8 8 }
9 9  
10 10 validates_exclusion_of :slug, :in => [ 'index' ], :message => N_('{fn} cannot be like that.').fix_i18n
... ...
app/models/certifier.rb
1 1 class Certifier < ActiveRecord::Base
2 2  
3 3 SEARCHABLE_FIELDS = {
4   - :name => 10,
5   - :description => 3,
6   - :link => 1,
  4 + :name => {:label => _('Name'), :weight => 10},
  5 + :description => {:label => _('Description'), :weight => 3},
  6 + :link => {:label => _('Link'), :weight => 1},
7 7 }
8 8  
9 9 belongs_to :environment
... ...
app/models/comment.rb
1 1 class Comment < ActiveRecord::Base
2 2  
3 3 SEARCHABLE_FIELDS = {
4   - :title => 10,
5   - :name => 4,
6   - :body => 2,
  4 + :title => {:label => _('Title'), :weight => 10},
  5 + :name => {:label => _('Name'), :weight => 4},
  6 + :body => {:label => _('Content'), :weight => 2},
7 7 }
8 8  
9 9 validates_presence_of :body
... ...
app/models/license.rb
1 1 class License < ActiveRecord::Base
2 2  
3 3 SEARCHABLE_FIELDS = {
4   - :name => 10,
5   - :url => 5,
  4 + :name => {:label => _('Name'), :weight => 10},
  5 + :url => {:label => _('URL'), :weight => 5},
6 6 }
7 7  
8 8 belongs_to :environment
... ...
app/models/national_region.rb
1 1 class NationalRegion < ActiveRecord::Base
2 2  
3 3 SEARCHABLE_FIELDS = {
4   - :name => 1,
5   - :national_region_code => 1,
  4 + :name => {:label => _('Name'), :weight => 1},
  5 + :national_region_code => {:label => _('Region Code'), :weight => 1},
6 6 }
7 7  
8 8 def self.search_city(city_name, like = false, state = nil)
... ...
app/models/product.rb
1 1 class Product < ActiveRecord::Base
2 2  
3 3 SEARCHABLE_FIELDS = {
4   - :name => 10,
5   - :description => 1,
  4 + :name => {:label => _('Name'), :weight => 10},
  5 + :description => {:label => _('Description'), :weight => 1},
6 6 }
7 7  
8 8 SEARCH_FILTERS = %w[
... ...
app/models/profile.rb
... ... @@ -4,9 +4,9 @@
4 4 class Profile < ActiveRecord::Base
5 5  
6 6 SEARCHABLE_FIELDS = {
7   - :name => 10,
8   - :identifier => 5,
9   - :nickname => 2,
  7 + :name => {:label => _('Name'), :weight => 10},
  8 + :identifier => {:label => _('Username'), :weight => 5},
  9 + :nickname => {:label => _('Nickname'), :weight => 2},
10 10 }
11 11  
12 12 SEARCH_FILTERS = %w[
... ...
app/models/qualifier.rb
1 1 class Qualifier < ActiveRecord::Base
2 2  
3 3 SEARCHABLE_FIELDS = {
4   - :name => 1,
  4 + :name => {:label => _('Name'), :weight => 1},
5 5 }
6 6  
7 7 belongs_to :environment
... ...
app/models/scrap.rb
1 1 class Scrap < ActiveRecord::Base
2 2 SEARCHABLE_FIELDS = {
3   - :content => 1,
  3 + :content => {:label => _('Content'), :weight => 1},
4 4 }
5 5 validates_presence_of :content
6 6 validates_presence_of :sender_id, :receiver_id
... ...
app/models/user.rb
... ... @@ -9,7 +9,7 @@ class User &lt; ActiveRecord::Base
9 9 N_('Terms accepted')
10 10  
11 11 SEARCHABLE_FIELDS = {
12   - :email => 5,
  12 + :email => {:label => _('Email'), :weight => 5},
13 13 }
14 14  
15 15 def self.[](login)
... ...
plugins/stoa/lib/ext/person.rb
1 1 require_dependency 'person'
2 2  
3 3 class Person
4   - SEARCHABLE_FIELDS[:usp_id] = 5
  4 + SEARCHABLE_FIELDS[:usp_id] = {:label => _('USP Number'), :weight => 5}
5 5  
6 6 validates_uniqueness_of :usp_id, :allow_nil => true
7 7 settings_items :invitation_code
... ...