Skip to content

Commit 59fd8a7

Browse files
authored
Merge pull request #1877 from openstax/fe_roles
Include period_id with roles
2 parents 33051ad + f858327 commit 59fd8a7

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

app/models/entity/role.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Role < IndestructibleRecord
1111
belongs_to :profile, subsystem: :user, inverse_of: :roles
1212

1313
delegate :username, :first_name, :last_name, :full_name, :name, to: :profile, allow_nil: true
14-
delegate :course, :course_profile_course_id, to: :course_member, allow_nil: true
14+
delegate :course, :period, :course_profile_course_id, to: :course_member, allow_nil: true
1515

1616
unique_token :research_identifier, mode: :hex, length: 4, prefix: 'r'
1717

app/representers/api/v1/role_representer.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ class RoleRepresenter < Roar::Decorator
1010
writeable: false,
1111
schema_info: { required: true }
1212

13+
property :period_id,
14+
getter: ->(*) { teacher? ? nil : course_member.course_membership_period_id },
15+
type: String,
16+
readable: true,
17+
writeable: false,
18+
schema_info: { required: true }
19+
1320
property :role_type,
1421
as: :type,
1522
type: String,
@@ -36,5 +43,6 @@ class RoleRepresenter < Roar::Decorator
3643
getter: ->(*) { DateTimeUtilities.to_api_s(latest_enrollment_at) },
3744
schema_info: { required: true }
3845

46+
3947
end
4048
end

spec/controllers/api/v1/courses_controller_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
id: student_role.id.to_s,
8484
research_identifier: student_role.research_identifier,
8585
type: 'student',
86+
period_id: @period.id.to_s,
8687
joined_at: DateTimeUtilities.to_api_s(student_role.created_at),
8788
latest_enrollment_at: DateTimeUtilities.to_api_s(student_role.latest_enrollment_at)
8889
),
@@ -102,6 +103,7 @@
102103
{
103104
id: student_role.id.to_s,
104105
type: 'student',
106+
period_id: @period.id.to_s,
105107
research_identifier: student_role.research_identifier,
106108
joined_at: DateTimeUtilities.to_api_s(student_role.created_at),
107109
latest_enrollment_at: DateTimeUtilities.to_api_s(student_role.latest_enrollment_at)
@@ -344,6 +346,7 @@
344346
roles: a_collection_containing_exactly(
345347
id: student_role.id.to_s,
346348
type: 'student',
349+
period_id: @period.id.to_s,
347350
research_identifier: student_role.research_identifier,
348351
joined_at: DateTimeUtilities.to_api_s(student_role.created_at),
349352
latest_enrollment_at: DateTimeUtilities.to_api_s(student_role.latest_enrollment_at)
@@ -364,6 +367,7 @@
364367
{
365368
id: student_role.id.to_s,
366369
type: 'student',
370+
period_id: @period.id.to_s,
367371
research_identifier: student_role.research_identifier,
368372
joined_at: DateTimeUtilities.to_api_s(student_role.created_at),
369373
latest_enrollment_at: DateTimeUtilities.to_api_s(student_role.latest_enrollment_at)

spec/representers/api/v1/bootstrap_data_representer_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
base_url: a_string_starting_with('http'),
4242
product_uuid: secrets.openstax[:payments][:product_uuid]
4343
},
44-
feature_flags: { is_payments_enabled: Settings::Payments.payments_enabled },
44+
feature_flags: {
45+
is_payments_enabled: Settings::Payments.payments_enabled,
46+
teacher_student_enabled: Settings::Db[:teacher_student_enabled]
47+
},
4548
ui_settings: {},
4649
flash: { alert: 'Nothing!' }
4750
}.deep_stringify_keys

0 commit comments

Comments
 (0)