From 1c0b5c743e8da810d8457407f782d076922025db Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 15 Feb 2013 23:57:06 -0600 Subject: [PATCH] better handle new colors and species --- app/models/color.rb | 6 +++- app/models/pet_type.rb | 19 ++++++++--- app/models/species.rb | 6 +++- config/locales/en.yml | 9 ++++++ public/stylesheets/compiled/print.css | 28 ++++++++-------- public/stylesheets/compiled/screen.css | 44 +++++++++++++------------- 6 files changed, 69 insertions(+), 43 deletions(-) diff --git a/app/models/color.rb b/app/models/color.rb index c73cd9b5..37f09e7b 100644 --- a/app/models/color.rb +++ b/app/models/color.rb @@ -11,6 +11,10 @@ class Color < ActiveRecord::Base end def human_name - name.split(' ').map { |word| word.capitalize }.join(' ') + if name + name.split(' ').map { |word| word.capitalize }.join(' ') + else + I18n.translate('colors.default_human_name') + end end end diff --git a/app/models/pet_type.rb b/app/models/pet_type.rb index 01c29c00..89edd9f5 100644 --- a/app/models/pet_type.rb +++ b/app/models/pet_type.rb @@ -66,17 +66,26 @@ class PetType < ActiveRecord::Base # Probably should move the basic hashes into the database someday. # Until then, access the hash using the English color/species names. - unless BasicHashes[species.name] && BasicHashes[species.name][color.name] - # TODO: use rainbow pool? some external service? + if species && color && BasicHashes[species.name] && BasicHashes[species.name][color.name] + BasicHashes[species.name][color.name] + else return 'deadbeef' end - - BasicHashes[species.name][color.name] end end + def possibly_new_color + self.color || Color.new(id: self.color_id) + end + + def possibly_new_species + self.species || Species.new(id: self.species_id) + end + def human_name - self.color.human_name + ' ' + self.species.human_name + I18n.translate('pet_types.human_name', + color_human_name: possibly_new_color.human_name, + species_human_name: possibly_new_species.human_name) end def needed_items diff --git a/app/models/species.rb b/app/models/species.rb index 71922dc7..79f6d994 100644 --- a/app/models/species.rb +++ b/app/models/species.rb @@ -8,6 +8,10 @@ class Species < ActiveRecord::Base end def human_name - name.capitalize + if name + name.capitalize + else + I18n.translate('species.default_human_name') + end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 662f7e68..b78a5e51 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -214,6 +214,9 @@ en: unlisted_name: Not in a list + colors: + default_human_name: (a new color) + contributions: contributed_description: parents: @@ -725,6 +728,12 @@ en: unconverted: Unconverted unlabeled: Unlabeled + pet_types: + human_name: "%{color_human_name} %{species_human_name}" + + species: + default_human_name: (a new species) + pets: bulk: needed_items: diff --git a/public/stylesheets/compiled/print.css b/public/stylesheets/compiled/print.css index 3f77533a..acbc7749 100644 --- a/public/stylesheets/compiled/print.css +++ b/public/stylesheets/compiled/print.css @@ -1,4 +1,4 @@ -/* line 29, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 29, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ body { line-height: 1.5; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif; @@ -7,12 +7,12 @@ body { font-size: 10pt; } -/* line 52, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 52, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ .container { background: none; } -/* line 54, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 54, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ hr { background: #cccccc; color: #cccccc; @@ -22,40 +22,40 @@ hr { padding: 0; border: none; } -/* line 62, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 62, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ hr.space { background: white; color: white; } -/* line 65, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 65, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ h1, h2, h3, h4, h5, h6 { font-family: "Helvetica Neue", Arial, Helvetica, sans-serif; } -/* line 67, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 67, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ code { font-size: 0.9em; font-family: "andale mono", "lucida console", monospace; } -/* line 72, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 72, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ a img { border: none; } -/* line 75, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 75, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ a:link, a:visited { background: transparent; font-weight: 700; text-decoration: underline; } -/* line 79, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 79, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ p img.top { margin-top: 0; } -/* line 81, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 81, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ blockquote { margin: 1.5em; padding: 1em; @@ -63,22 +63,22 @@ blockquote { font-size: 0.9em; } -/* line 86, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 86, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ .small { font-size: 0.9em; } -/* line 88, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 88, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ .large { font-size: 1.1em; } -/* line 90, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 90, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ .quiet { color: #999999; } -/* line 92, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ +/* line 92, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/blueprint/stylesheets/blueprint/_print.scss */ .hide { display: none; } diff --git a/public/stylesheets/compiled/screen.css b/public/stylesheets/compiled/screen.css index 4afed214..f9512f8a 100644 --- a/public/stylesheets/compiled/screen.css +++ b/public/stylesheets/compiled/screen.css @@ -651,7 +651,7 @@ body.closet_hangers-index #closet-hangers-contact a, body.closet_hangers-index # height: 100%; padding-left: 20px; } -/* line 4, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/utilities/links/_hover-link.scss */ +/* line 4, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/utilities/links/_hover-link.scss */ body.closet_hangers-index #closet-hangers-contact a:hover, body.closet_hangers-index #closet-hangers-contact > span:hover { text-decoration: underline; } @@ -1338,7 +1338,7 @@ body.closet_hangers-petpage #petpage-closet-lists h4 { *vertical-align: auto; vertical-align: middle; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.closet_hangers-petpage #petpage-closet-lists h4 { *display: inline; } @@ -1363,7 +1363,7 @@ body.closet_hangers-petpage #petpage-closet-lists ul li { margin: 0.25em 0.5em; padding: 1px; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.closet_hangers-petpage #petpage-closet-lists ul li { *display: inline; } @@ -1775,7 +1775,7 @@ body.items-show #item-header div, body.items-show #item-header img { vertical-align: middle; *vertical-align: auto; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.items-show #item-header div, body.items-show #item-header img { *display: inline; } @@ -1829,7 +1829,7 @@ body.items-show #item-preview-species a { vertical-align: middle; *vertical-align: auto; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.items-show #item-preview-species a { *display: inline; } @@ -1951,17 +1951,17 @@ body.items-show #item-contributors footer { body.items-show #item-contributors ul { list-style-type: none; } -/* line 5, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/utilities/lists/_inline-list.scss */ +/* line 5, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/utilities/lists/_inline-list.scss */ body.items-show #item-contributors ul, body.items-show #item-contributors ul li { margin: 0px; padding: 0px; display: inline; } -/* line 24, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/utilities/lists/_inline-list.scss */ +/* line 24, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/utilities/lists/_inline-list.scss */ body.items-show #item-contributors ul li:after { content: ", "; } -/* line 26, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/utilities/lists/_inline-list.scss */ +/* line 26, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/utilities/lists/_inline-list.scss */ body.items-show #item-contributors ul li:last-child:after, body.items-show #item-contributors ul li.last:after { content: ""; } @@ -1981,7 +1981,7 @@ body.items-show #item-preview-header h3, body.items-show #item-preview-header a vertical-align: middle; *vertical-align: auto; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.items-show #item-preview-header h3, body.items-show #item-preview-header a { *display: inline; } @@ -2077,7 +2077,7 @@ body.outfits-edit #preview-toolbar form { *vertical-align: auto; margin-right: 2em; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.outfits-edit #preview-toolbar form { *display: inline; } @@ -2400,7 +2400,7 @@ body.outfits-edit #preview-search-form h2 { *vertical-align: auto; margin: 0 1em 0 0; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.outfits-edit #preview-search-form h2 { *display: inline; } @@ -2412,7 +2412,7 @@ body.outfits-edit #preview-search-form input { vertical-align: middle; *vertical-align: auto; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.outfits-edit #preview-search-form input { *display: inline; } @@ -2434,7 +2434,7 @@ body.outfits-edit #preview-search-form-pagination { vertical-align: middle; *vertical-align: auto; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.outfits-edit #preview-search-form-pagination { *display: inline; } @@ -2531,7 +2531,7 @@ body.outfits-edit.fullscreen #preview-search-form-help div { *vertical-align: auto; width: 48%; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.outfits-edit.fullscreen #preview-search-form-help div { *display: inline; } @@ -2727,7 +2727,7 @@ body.outfits-edit #preview-outfits > ul > li { position: relative; font-size: 14px; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.outfits-edit #preview-outfits > ul > li { *display: inline; } @@ -3060,7 +3060,7 @@ body.outfits-edit #preview-sharing #preview-sharing-url-formats li { font-size: 12px; padding: 0 2em; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.outfits-edit #preview-sharing #preview-sharing-url-formats li { *display: inline; } @@ -3350,7 +3350,7 @@ body.outfits-edit form#save-outfit-form .outfit-star, body.outfits-edit form#sav float: none; vertical-align: top; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.outfits-edit form#save-outfit-form .outfit-star, body.outfits-edit form#save-outfit-form input, body.outfits-edit form#save-outfit-form button { *display: inline; } @@ -3401,7 +3401,7 @@ body.outfits-edit.user-signed-in .preview-search-form-your-items { vertical-align: middle; *vertical-align: auto; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.outfits-edit.user-signed-in .preview-search-form-your-items { *display: inline; } @@ -3442,7 +3442,7 @@ body.outfits-index #outfits > li { position: relative; font-size: 14px; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.outfits-index #outfits > li { *display: inline; } @@ -4077,7 +4077,7 @@ body.pets-bulk #needed-items-form #needed-items-pet #needed-items-reload { margin-left: 1em; vertical-align: middle; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.pets-bulk #needed-items-form #needed-items-pet #needed-items-reload { *display: inline; } @@ -4151,7 +4151,7 @@ body.pets-bulk #bulk-pets-form textarea { overflow: hidden; resize: none; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.pets-bulk #bulk-pets-form textarea { *display: inline; } @@ -4172,7 +4172,7 @@ body.pets-bulk #bulk-pets-form ul li { min-width: 25%; text-align: left; } -/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p362/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ +/* line 7, ../../../../../../.rvm/gems/ruby-1.9.3-p385/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ body.pets-bulk #bulk-pets-form ul li { *display: inline; }