Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/api/entities/minimal/minimal_unit_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class MinimalUnitEntity < Grape::Entity
end

expose :active
expose :task_definitions, if: :include_task_definitions
end
end
end
2 changes: 1 addition & 1 deletion app/api/entities/project_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ProjectEntity < Grape::Entity

expose :task_stats, as: :stats, unless: :for_student

expose :tasks, using: TaskEntity, unless: :summary_only do |project, options|
expose :tasks, using: TaskEntity, if: ->(project, options) { !options[:summary_only] || options[:include_task_definitions] } do |project, options|
project.task_details_for_shallow_serializer(options[:user])
end

Expand Down
5 changes: 4 additions & 1 deletion app/api/projects_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ class ProjectsApi < Grape::API
desc "Fetches all of the current user's projects"
params do
optional :include_inactive, type: Boolean, desc: 'Include projects for units that are no longer active?'
optional :include_task_definitions, type: Boolean, desc: 'Include all task definitions with tasks for each project?'
end
get '/projects' do
include_inactive = params[:include_inactive] || false
include_task_definitions = params[:include_task_definitions] || false

projects = Project.eager_load(:unit, :user).for_user current_user, include_inactive
present projects, with: Entities::ProjectEntity, for_student: true, summary_only: true, user: current_user

present projects, with: Entities::ProjectEntity, for_student: true, summary_only: true, include_task_definitions: include_task_definitions, user: current_user
end

desc 'Get project'
Expand Down
Loading