Merge pull request #205 from mmozuras/refactor_negative_blanks_into_presents

Refactor negative blanks into presents
This commit is contained in:
Reinier Balt 2013-09-13 05:56:03 -07:00
commit 35d0afdfdf
6 changed files with 12 additions and 12 deletions

View file

@ -12,7 +12,7 @@ class PreferencesController < ApplicationController
user_updated = current_user.update_attributes(user_params) user_updated = current_user.update_attributes(user_params)
prefs_updated = current_user.preference.update_attributes(prefs_params) prefs_updated = current_user.preference.update_attributes(prefs_params)
if (user_updated && prefs_updated) if (user_updated && prefs_updated)
if !params['user']['password'].blank? # password updated? if params['user']['password'].present? # password updated?
logout_user t('preferences.password_changed') logout_user t('preferences.password_changed')
else else
preference_updated preference_updated

View file

@ -72,7 +72,7 @@ class RecurringTodosController < ApplicationController
end end
# update context # update context
if params['recurring_todo']['context_id'].blank? && !params['context_name'].blank? if params['recurring_todo']['context_id'].blank? && params['context_name'].present?
context = current_user.contexts.where(:name => params['context_name'].strip).first context = current_user.contexts.where(:name => params['context_name'].strip).first
unless context unless context
context = current_user.contexts.build context = current_user.contexts.build

View file

@ -89,7 +89,7 @@ module Todos
end end
def sequential? def sequential?
return !@params[:todos_sequential].blank? && @params[:todos_sequential]=='true' return @params[:todos_sequential].present? && @params[:todos_sequential]=='true'
end end
def specified_by_name?(group_type) def specified_by_name?(group_type)
@ -98,7 +98,7 @@ module Todos
def specified_by_id?(group_type) def specified_by_id?(group_type)
group_id = send("#{group_type}_id") group_id = send("#{group_type}_id")
!group_id.blank? group_id.present?
end end
def project_specified_by_name? def project_specified_by_name?

View file

@ -91,7 +91,7 @@ class TodosController < ApplicationController
if @todo.errors.empty? if @todo.errors.empty?
@todo.add_predecessor_list(p.predecessor_list) @todo.add_predecessor_list(p.predecessor_list)
@saved = @todo.save @saved = @todo.save
@todo.tag_with(tag_list) if @saved && !tag_list.blank? @todo.tag_with(tag_list) if @saved && tag_list.present?
@todo.update_state_from_project if @saved @todo.update_state_from_project if @saved
@todo.block! if @todo.should_be_blocked? @todo.block! if @todo.should_be_blocked?
else else
@ -174,8 +174,8 @@ class TodosController < ApplicationController
todo.add_predecessor(@predecessor) todo.add_predecessor(@predecessor)
todo.block! todo.block!
end end
todo.tag_with(tag_list) unless (@saved == false) || tag_list.blank? todo.tag_with(tag_list) if @saved && tag_list.present?
@todos << todo @todos << todo
@not_done_todos << todo if p.new_context_created || p.new_project_created @not_done_todos << todo if p.new_context_created || p.new_project_created
@ -1162,7 +1162,7 @@ end
def update_context def update_context
@context_changed = false @context_changed = false
if params['todo']['context_id'].blank? && !params['context_name'].blank? if params['todo']['context_id'].blank? && params['context_name'].present?
context = current_user.contexts.where(:name => params['context_name'].strip).first context = current_user.contexts.where(:name => params['context_name'].strip).first
unless context unless context
@new_context = current_user.contexts.build @new_context = current_user.contexts.build

View file

@ -97,7 +97,7 @@ class Todo < ActiveRecord::Base
end end
event :unhide do event :unhide do
transitions :to => :deferred, :from => [:project_hidden], :guard => Proc.new{|t| !t.show_from.blank? } transitions :to => :deferred, :from => [:project_hidden], :guard => Proc.new{|t| t.show_from.present? }
transitions :to => :pending, :from => [:project_hidden], :guard => :uncompleted_predecessors? transitions :to => :pending, :from => [:project_hidden], :guard => :uncompleted_predecessors?
transitions :to => :active, :from => [:project_hidden] transitions :to => :active, :from => [:project_hidden]
end end
@ -119,7 +119,7 @@ class Todo < ActiveRecord::Base
def check_show_from_in_future def check_show_from_in_future
if show_from_changed? # only check on change of show_from if show_from_changed? # only check on change of show_from
if !show_from.blank? && (show_from < user.date) if show_from.present? && (show_from < user.date)
errors.add("show_from", I18n.t('models.todo.error_date_must_be_future')) errors.add("show_from", I18n.t('models.todo.error_date_must_be_future'))
end end
end end
@ -270,7 +270,7 @@ class Todo < ActiveRecord::Base
# (see http://stackoverflow.com/questions/682920/persisting-the-state-column-on-transition-using-rubyist-aasm-acts-as-state-machi) # (see http://stackoverflow.com/questions/682920/persisting-the-state-column-on-transition-using-rubyist-aasm-acts-as-state-machi)
self[:show_from] = date self[:show_from] = date
defer if active? && !date.blank? && show_from > user.date defer if active? && date.present? && show_from > user.date
end end
end end

View file

@ -217,7 +217,7 @@ protected
end end
def password_required? def password_required?
auth_type == 'database' && crypted_password.blank? || !password.blank? auth_type == 'database' && crypted_password.blank? || password.present?
end end
end end