list prank colors as fake on the homepage, unless pranks are funny today
This commit is contained in:
parent
e62d52bbd4
commit
8e93d603fa
4 changed files with 19 additions and 4 deletions
|
@ -41,8 +41,8 @@ class OutfitsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
unless localized_fragment_exist?(:action_suffix => 'start_from_scratch_form_content')
|
unless localized_fragment_exist?("outfits#new start_from_scratch_form pranks_funny=#{Color.pranks_funny?}")
|
||||||
@colors = Color.alphabetical
|
@colors = Color.funny.alphabetical
|
||||||
@species = Species.alphabetical
|
@species = Species.alphabetical
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ class Color < ActiveRecord::Base
|
||||||
scope :basic, where(:basic => true)
|
scope :basic, where(:basic => true)
|
||||||
scope :standard, where(:standard => true)
|
scope :standard, where(:standard => true)
|
||||||
scope :nonstandard, where(:standard => false)
|
scope :nonstandard, where(:standard => false)
|
||||||
|
scope :funny, lambda { order(:prank) unless pranks_funny? }
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
|
|
||||||
|
@ -13,10 +14,23 @@ class Color < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def human_name
|
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
|
if name
|
||||||
name.split(' ').map { |word| word.capitalize }.join(' ')
|
name.split(' ').map { |word| word.capitalize }.join(' ')
|
||||||
else
|
else
|
||||||
I18n.translate('colors.default_human_name')
|
I18n.translate('colors.default_human_name')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.pranks_funny?
|
||||||
|
today = Date.today
|
||||||
|
today.month == 4 && today.day == 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
%button{:type => "submit"}
|
%button{:type => "submit"}
|
||||||
= t '.load_pet.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
|
= form_tag wardrobe_path, method: 'GET', id: 'start-from-scratch', authenticity_token: false do
|
||||||
%fieldset
|
%fieldset
|
||||||
%legend= t '.start_from_scratch.legend'
|
%legend= t '.start_from_scratch.legend'
|
||||||
|
|
|
@ -219,6 +219,7 @@ en:
|
||||||
|
|
||||||
colors:
|
colors:
|
||||||
default_human_name: (a new color)
|
default_human_name: (a new color)
|
||||||
|
prank_suffix: (fake)
|
||||||
|
|
||||||
contributions:
|
contributions:
|
||||||
contributed_description:
|
contributed_description:
|
||||||
|
|
Loading…
Reference in a new issue