#2472: Fix fetching calendar ID on task update. Didn't figure out when this has been broken – could be c66ce02cb, but not sure how.

This commit is contained in:
Jyri-Petteri Paloposki 2020-09-06 14:06:57 +03:00
parent 27f7fca29e
commit abad8c77ee

View file

@ -423,6 +423,7 @@ class TodosController < ApplicationController
@todo = current_user.todos.find(params['id']) @todo = current_user.todos.find(params['id'])
@original_item = current_user.todos.build(@todo.attributes) # create a (unsaved) copy of the original todo @original_item = current_user.todos.build(@todo.attributes) # create a (unsaved) copy of the original todo
@original_item_due_id = get_due_id_for_calendar(@original_item.due)
update_tags update_tags
update_project update_project
@ -442,7 +443,6 @@ class TodosController < ApplicationController
@saved = false @saved = false
end end
provide_project_or_context_for_view provide_project_or_context_for_view
# this is set after save and cleared after reload, so save it here # this is set after save and cleared after reload, so save it here
@ -1138,18 +1138,18 @@ end
end end
def count_old_due_empty(id) def count_old_due_empty(id)
due_today_date = Time.zone.now
due_this_week_date = Time.zone.now.end_of_week
due_next_week_date = due_this_week_date + 7.days
due_this_month_date = Time.zone.now.end_of_month
case id case id
when "due_today" when "due_today"
due_today_date = Time.zone.now
return current_user.todos.not_completed.where('todos.due <= ?', due_today_date).count return current_user.todos.not_completed.where('todos.due <= ?', due_today_date).count
when "due_this_week" when "due_this_week"
due_this_week_date = Time.zone.now.end_of_week
return current_user.todos.not_completed.where('todos.due > ? AND todos.due <= ?', due_today_date, due_this_week_date).count return current_user.todos.not_completed.where('todos.due > ? AND todos.due <= ?', due_today_date, due_this_week_date).count
when "due_next_week" when "due_next_week"
due_next_week_date = due_this_week_date + 7.days
return current_user.todos.not_completed.where('todos.due > ? AND todos.due <= ?', due_this_week_date, due_next_week_date).count return current_user.todos.not_completed.where('todos.due > ? AND todos.due <= ?', due_this_week_date, due_next_week_date).count
when "due_this_month" when "due_this_month"
due_this_month_date = Time.zone.now.end_of_month
return current_user.todos.not_completed.where('todos.due > ? AND todos.due <= ?', due_next_week_date, due_this_month_date).count return current_user.todos.not_completed.where('todos.due > ? AND todos.due <= ?', due_next_week_date, due_this_month_date).count
when "due_after_this_month" when "due_after_this_month"
return current_user.todos.not_completed.where('todos.due > ?', due_this_month_date).count return current_user.todos.not_completed.where('todos.due > ?', due_this_month_date).count