Merge pull request #206 from mmozuras/refactor_unless_blanks_into_presents

Refactor unless blanks into presents
This commit is contained in:
Reinier Balt 2013-09-13 06:08:16 -07:00
commit e2eb31cfcc
15 changed files with 25 additions and 25 deletions

View file

@ -334,7 +334,7 @@ class ProjectsController < ApplicationController
default_context_name = p['default_context_name']
p.delete('default_context_name')
unless default_context_name.blank?
if default_context_name.present?
default_context = current_user.contexts.where(:name => default_context_name).first_or_create
p['default_context_id'] = default_context.id
end

View file

@ -129,7 +129,7 @@ class RecurringTodosController < ApplicationController
end
@saved = @recurring_todo.save
unless (@saved == false) || p.tag_list.blank?
if @saved && p.tag_list.present?
@recurring_todo.tag_with(p.tag_list)
@recurring_todo.tags.reload
end
@ -255,14 +255,14 @@ class RecurringTodosController < ApplicationController
end
def project_specified_by_name?
return false unless @attributes['project_id'].blank?
return false if @attributes['project_id'].present?
return false if project_name.blank?
return false if project_name == 'None'
true
end
def context_specified_by_name?
return false unless @attributes['context_id'].blank?
return false if @attributes['context_id'].present?
return false if context_name.blank?
true
end

View file

@ -102,14 +102,14 @@ module Todos
end
def project_specified_by_name?
return false unless @attributes['project_id'].blank?
return false if @attributes['project_id'].present?
return false if project_name.blank?
return false if project_name == 'None'
true
end
def context_specified_by_name?
return false unless @attributes['context_id'].blank?
return false if @attributes['context_id'].present?
return false if context_name.blank?
true
end

View file

@ -73,7 +73,7 @@ class TodosController < ApplicationController
def create
@source_view = params['_source_view'] || 'todo'
@default_context = current_user.contexts.where(:name => params['default_context_name']).first
@default_project = current_user.projects.where(:name => params['default_project_name']).first unless params['default_project_name'].blank?
@default_project = current_user.projects.where(:name => params['default_project_name']).first if params['default_project_name'].present?
@tag_name = params['_tag_name']
@ -156,7 +156,7 @@ class TodosController < ApplicationController
# first build all todos and check if they would validate on save
params[:todo][:multiple_todos].split("\n").map do |line|
unless line.blank? #ignore blank lines
if line.present? #ignore blank lines
@todo = current_user.todos.build({:description => line, :context_id => p.context_id, :project_id => p.project_id})
validates &&= @todo.valid?
@ -202,7 +202,7 @@ class TodosController < ApplicationController
else
@multiple_error = @todos.size > 0 ? "" : t('todos.next_action_needed')
@saved = false
@default_tags = current_user.projects.where(:name => @initial_project_name).default_tags unless @initial_project_name.blank?
@default_tags = current_user.projects.where(:name => @initial_project_name).default_tags if @initial_project_name.present?
end
@status_message = @todos.size > 1 ? t('todos.added_new_next_action_plural') : t('todos.added_new_next_action_singular')