Add context_name to calendar events api
flag=none refs: MBL-14399 Test plan: - Enroll a student in a course - Create and publish an assignment in the course and set its due date to some day this month - Create a calendar event on the user's calendar - As the student, query the calendar_events api for the assignment - Something like: /api/v1/calendar_events ?type=assignment &start_date=2020-05-01 &end_date=2020-05-30 &context_codes[]=course_1 - The context_name should be included - As the student, give the course a nickname - The context_name should be the nickname of the course - As the student, query the calendar_events api for the calendar event - Something like: /api/v1/calendar_events ?start_date=2020-05-01 &end_date=2020-05-30 - The context_name should be included Change-Id: Ie5336637824d3241d39b7fbb6dcb083e3ec25cdc Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/237393 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Ben Nelson <bnelson@instructure.com> Reviewed-by: Rob Orton <rob@instructure.com> QA-Review: Ben Nelson <bnelson@instructure.com> Product-Review: Ben Nelson <bnelson@instructure.com>
This commit is contained in:
parent
714e905073
commit
ea35376bfb
|
@ -71,6 +71,11 @@ require 'atom'
|
|||
# "description": "if specified, it indicates which calendar this event should be displayed on. for example, a section-level event would have the course's context code here, while the section's context code would be returned above)",
|
||||
# "type": "string"
|
||||
# },
|
||||
# "context_name": {
|
||||
# "description": "the context name of the calendar this event belongs to (course, user or group)",
|
||||
# "example": "Chemistry 101",
|
||||
# "type": "string"
|
||||
# },
|
||||
# "all_context_codes": {
|
||||
# "description": "a comma-separated list of all calendar contexts this event is part of",
|
||||
# "example": "course_123,course_456",
|
||||
|
|
|
@ -97,6 +97,7 @@ module Api::V1::CalendarEvent
|
|||
hash['all_context_codes'] = Context.context_code_for(event)
|
||||
end
|
||||
hash['context_code'] ||= Context.context_code_for(event)
|
||||
hash['context_name'] = context.try(:nickname_for, user)
|
||||
|
||||
hash['parent_event_id'] = event.parent_calendar_event_id
|
||||
# events are hidden when section-specific events override them
|
||||
|
@ -193,6 +194,7 @@ module Api::V1::CalendarEvent
|
|||
hash['html_url'] = hash['assignment']['html_url'] if hash['assignment'].include?('html_url')
|
||||
end
|
||||
hash['context_code'] = Context.context_code_for(assignment)
|
||||
hash['context_name'] = assignment.context.try(:nickname_for, user)
|
||||
hash['start_at'] = hash['end_at'] = assignment.due_at
|
||||
hash['url'] = api_v1_calendar_event_url("assignment_#{assignment.id}")
|
||||
if assignment.applied_overrides.present?
|
||||
|
|
|
@ -30,7 +30,7 @@ describe CalendarEventsApiController, type: :request do
|
|||
'all_context_codes', 'all_day', 'all_day_date', 'child_events', 'child_events_count', 'comments',
|
||||
'context_code', 'created_at', 'description', 'duplicates', 'end_at', 'hidden', 'html_url',
|
||||
'id', 'location_address', 'location_name', 'parent_event_id', 'start_at',
|
||||
'title', 'type', 'updated_at', 'url', 'workflow_state'
|
||||
'title', 'type', 'updated_at', 'url', 'workflow_state', 'context_name'
|
||||
]
|
||||
expected_slot_fields = (expected_fields + ['appointment_group_id', 'appointment_group_url', 'can_manage_appointment_group', 'available_slots', 'participants_per_appointment', 'reserve_url', 'participant_type', 'effective_context_code'])
|
||||
expected_reservation_event_fields = (expected_fields + ['appointment_group_id', 'appointment_group_url', 'can_manage_appointment_group', 'effective_context_code', 'participant_type'])
|
||||
|
@ -1458,7 +1458,7 @@ describe CalendarEventsApiController, type: :request do
|
|||
expected_fields = [
|
||||
'all_day', 'all_day_date', 'assignment', 'context_code', 'created_at',
|
||||
'description', 'end_at', 'html_url', 'id', 'start_at', 'title', 'type', 'updated_at',
|
||||
'url', 'workflow_state'
|
||||
'url', 'workflow_state', 'context_name'
|
||||
]
|
||||
|
||||
it 'should return assignments within the given date range' do
|
||||
|
|
Loading…
Reference in New Issue