Merge pull request #2210 from ZeiP/bug/2032_api_filters

#2032: Use context and project filters in API also when not requestin…
This commit is contained in:
Matt Rogers 2019-05-12 13:52:19 -05:00 committed by GitHub
commit 8bf0627d41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,14 @@ class TodosController < ApplicationController
init_data_for_sidebar unless mobile?
@todos = current_user.todos.includes(Todo::DEFAULT_INCLUDES)
if params[:context_id]
context = current_user.contexts.find(params[:context_id])
@todos = @todos.where('context_id' => context.id)
end
if params[:project_id]
project = current_user.projects.find(params[:project_id])
@todos = @todos.where('project_id' => project.id)
end
@todos = @todos.limit(sanitize(params[:limit])) if params[:limit]
@not_done_todos = get_not_done_todos