mirror of
https://github.com/TracksApp/tracks.git
synced 2025-09-22 05:50:47 +02:00
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:
commit
8bf0627d41
1 changed files with 8 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue