small refactorings

fix passing params in use of _collection
This commit is contained in:
Reinier Balt 2013-05-03 21:54:03 +02:00
parent f891ee86fe
commit 5cfa115cdc
8 changed files with 54 additions and 30 deletions

View file

@ -527,19 +527,15 @@ class RecurringTodo < ActiveRecord::Base
end
end
# check if there are any days left this week for the next todo
start.wday().upto 6 do |i|
return start + (i-start.wday()).days unless self.every_day[i,1] == ' '
end
day = find_first_day_in_this_week(start)
return day unless day == -1
# we did not find anything this week, so check the nth next, starting from
# sunday
start = start + self.every_other1.week - (start.wday()).days
# check if there are any days left this week for the next todo
start.wday().upto 6 do |i|
return start + (i-start.wday()).days unless self.every_day[i,1] == ' '
end
start = find_first_day_in_this_week(start)
return start unless start == -1
raise Exception.new, "unable to find next weekly date (#{self.every_day})"
end
@ -729,4 +725,12 @@ class RecurringTodo < ActiveRecord::Base
return start
end
def find_first_day_in_this_week(start)
# check if there are any days left this week for the next todo
start.wday().upto 6 do |i|
return start + (i-start.wday()).days unless self.every_day[i,1] == ' '
end
return -1
end
end

View file

@ -367,6 +367,10 @@ class Todo < ActiveRecord::Base
end
end
def has_project?
return ! (project_id.nil? || project.is_a?(NullProject))
end
# used by the REST API. <tags> will also work, this is renamed to add_tags in TodosController::TodoCreateParamsHelper::initialize
def add_tags=(params)
unless params[:tag].nil?