mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-04 23:11:47 +01:00
small refactorings
fix passing params in use of _collection
This commit is contained in:
parent
f891ee86fe
commit
5cfa115cdc
8 changed files with 54 additions and 30 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue