Skip to content

Commit

Permalink
fix: ensure staff before tutorial data
Browse files Browse the repository at this point in the history
  • Loading branch information
macite committed Nov 30, 2023
1 parent 7088999 commit e190cf7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/api/entities/unit_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ def is_admin_staff?(my_role)

expose :learning_outcomes, using: LearningOutcomeEntity, as: :ilos, unless: :summary_only
expose :tutorial_streams, using: TutorialStreamEntity, unless: :summary_only

# Expose staff before tutorials, so that their details are available
expose :staff, using: UnitRoleEntity, unless: :summary_only
expose :tutorials, using: TutorialEntity, unless: :summary_only
# expose :tutorial_enrolments, using: TutorialEnrolmentEntity, unless: :summary_only, if: lambda { |unit, options| is_staff?(options[:my_role]) }

expose :task_definitions, using: TaskDefinitionEntity, unless: :summary_only
expose :task_outcome_alignments, using: TaskOutcomeAlignmentEntity, unless: :summary_only
expose :staff, using: UnitRoleEntity, unless: :summary_only
expose :group_sets, using: GroupSetEntity, unless: :summary_only
expose :groups, using: GroupEntity, unless: :summary_only
# expose :group_memberships, using: GroupMembershipEntity, unless: :summary_only do |unit, options|
Expand Down
4 changes: 2 additions & 2 deletions app/api/units_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class UnitsApi < Grape::API

units = units.where('active = true') unless params[:include_in_active]

present units, with: Entities::UnitEntity, user: current_user, summary_only: true
present units, with: Entities::UnitEntity, user: current_user, summary_only: true, in_unit: true
end

desc "Get a unit's details"
Expand Down Expand Up @@ -252,7 +252,7 @@ class UnitsApi < Grape::API

my_role = result.role_for(current_user)

present result, with: Entities::UnitEntity, my_role: my_role, user: current_user
present result, with: Entities::UnitEntity, my_role: my_role, user: current_user, in_unit: true
end

desc 'Download the tasks that are awaiting feedback for a unit'
Expand Down

0 comments on commit e190cf7

Please sign in to comment.