Will make students managing calendar able to reserve app

fixes COMMS-1857

Test Plan
1. Enable the permission "Course Calendar -
add/edit/delete events" for the student role
2. As the teacher, create an appointment group in your course
3. As a student, try to reserve a time slot, notice that the
 "reserve" button and comment box are now rendered

Change-Id: I1f67b7ee30562ef7346e18c8c819a39f339f1f5f
Reviewed-on: https://gerrit.instructure.com/179586
Tested-by: Jenkins
QA-Review: Steven Burnett <sburnett@instructure.com>
Product-Review: Steven Burnett <sburnett@instructure.com>
Reviewed-by: Landon Gilbert-Bland <lbland@instructure.com>
Reviewed-by: James Williams <jamesw@instructure.com>
This commit is contained in:
Aaron Hsu 2019-01-28 14:13:24 -07:00 committed by Steven Burnett
parent 8a71527884
commit c3edb3d3ec
3 changed files with 12 additions and 3 deletions

View File

@ -246,9 +246,9 @@ export default class ShowEventDetailsDialog {
const params = $.extend(true, {}, this.event, {
can_reserve: this.event.object && this.event.object.reserve_url
})
// For now, assume that if someone has the ability to create appointment groups
// in a course, they shouldn't also be able to sign up for them.
if (this.event.contextInfo.can_create_appointment_groups) {
// For now used to eliminate the ability of teachers and tas seeing the excess reserveration link
if (!this.event.contextInfo.can_make_reservation) {
params.can_reserve = false
}

View File

@ -68,6 +68,7 @@ class CalendarsController < ApplicationController
:can_create_assignments => context.respond_to?("assignments") && Assignment.new.tap{|a| a.context = context}.grants_right?(@current_user, session, :create),
:assignment_groups => context.respond_to?("assignments") ? context.assignment_groups.active.pluck(:id, :name).map {|id, name| { :id => id, :name => name } } : [],
:can_create_appointment_groups => ag_permission,
:can_make_reservation => context.grants_right?(@current_user, :participate_as_student),
:can_update_todo_date => context.grants_right?(@current_user, session, :manage),
:can_update_discussion_topic => context.grants_right?(@current_user, session, :moderate_forum),
:can_update_wiki_page => context.grants_right?(@current_user, session, :manage_wiki),

View File

@ -43,6 +43,14 @@ describe CalendarsController do
expect(assigns[:contexts][1]).to eql(@course)
end
it "only enrolled students can make reservations" do
course_event
get 'show', params: {:user_id => @user.id}
expect(response).to be_successful
expect(assigns[:contexts_json][0][:can_make_reservation]).to eql(false)
expect(assigns[:contexts_json][1][:can_make_reservation]).to eql(true)
end
it "js_env DUE_DATE_REQUIRED_FOR_ACCOUNT is true when AssignmentUtil.due_date_required_for_account? == true" do
allow(AssignmentUtil).to receive(:due_date_required_for_account?).and_return(true)
get 'show', params: {:user_id => @user.id}