list prank colors as fake on the homepage, unless pranks are funny today

This commit is contained in:
Emi Matchu 2014-03-27 22:44:18 -05:00
parent e62d52bbd4
commit 8e93d603fa
4 changed files with 19 additions and 4 deletions

View file

@ -41,8 +41,8 @@ class OutfitsController < ApplicationController
end
def new
unless localized_fragment_exist?(:action_suffix => 'start_from_scratch_form_content')
@colors = Color.alphabetical
unless localized_fragment_exist?("outfits#new start_from_scratch_form pranks_funny=#{Color.pranks_funny?}")
@colors = Color.funny.alphabetical
@species = Species.alphabetical
end

View file

@ -5,18 +5,32 @@ class Color < ActiveRecord::Base
scope :basic, where(:basic => true)
scope :standard, where(:standard => true)
scope :nonstandard, where(:standard => false)
scope :funny, lambda { order(:prank) unless pranks_funny? }
validates :name, presence: true
def as_json(options={})
{:id => id, :name => human_name}
end
def human_name
if prank? && !Color.pranks_funny?
unfunny_human_name + ' ' + I18n.translate('colors.prank_suffix')
else
unfunny_human_name
end
end
def unfunny_human_name
if name
name.split(' ').map { |word| word.capitalize }.join(' ')
else
I18n.translate('colors.default_human_name')
end
end
def self.pranks_funny?
today = Date.today
today.month == 4 && today.day == 1
end
end

View file

@ -20,7 +20,7 @@
%button{:type => "submit"}
= t '.load_pet.submit'
- localized_cache action_suffix: 'outfits#new start_from_scratch_form' do
- localized_cache "outfits#new start_from_scratch_form pranks_funny=#{Color.pranks_funny?}" do
= form_tag wardrobe_path, method: 'GET', id: 'start-from-scratch', authenticity_token: false do
%fieldset
%legend= t '.start_from_scratch.legend'

View file

@ -219,6 +219,7 @@ en:
colors:
default_human_name: (a new color)
prank_suffix: (fake)
contributions:
contributed_description: