Skip to content

Commit 953068e

Browse files
committed
fix: ensure staff before tutorial data
1 parent 4c4a1cb commit 953068e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

app/api/entities/unit_entity.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ def is_admin_staff?(my_role)
5050

5151
expose :learning_outcomes, using: LearningOutcomeEntity, as: :ilos, unless: :summary_only
5252
expose :tutorial_streams, using: TutorialStreamEntity, unless: :summary_only
53+
54+
# Expose staff before tutorials, so that their details are available
55+
expose :staff, using: UnitRoleEntity, unless: :summary_only
5356
expose :tutorials, using: TutorialEntity, unless: :summary_only
5457
# expose :tutorial_enrolments, using: TutorialEnrolmentEntity, unless: :summary_only, if: lambda { |unit, options| is_staff?(options[:my_role]) }
5558

5659
expose :task_definitions, using: TaskDefinitionEntity, unless: :summary_only
5760
expose :task_outcome_alignments, using: TaskOutcomeAlignmentEntity, unless: :summary_only
58-
expose :staff, using: UnitRoleEntity, unless: :summary_only
5961
expose :group_sets, using: GroupSetEntity, unless: :summary_only
6062
expose :groups, using: GroupEntity, unless: :summary_only
6163
# expose :group_memberships, using: GroupMembershipEntity, unless: :summary_only do |unit, options|

app/api/units_api.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class UnitsApi < Grape::API
3535

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

38-
present units, with: Entities::UnitEntity, user: current_user, summary_only: true
38+
present units, with: Entities::UnitEntity, user: current_user, summary_only: true, in_unit: true
3939
end
4040

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

253253
my_role = result.role_for(current_user)
254254

255-
present result, with: Entities::UnitEntity, my_role: my_role, user: current_user
255+
present result, with: Entities::UnitEntity, my_role: my_role, user: current_user, in_unit: true
256256
end
257257

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

0 commit comments

Comments
 (0)