Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/api/tutorials_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class TutorialsApi < Grape::API
requires :meeting_location, type: String, desc: 'The tutorials location', allow_blank: false
requires :meeting_day, type: String, desc: 'Day of the tutorial', allow_blank: false
requires :meeting_time, type: String, desc: 'Time of the tutorial', allow_blank: false
optional :tutorial_stream_abbr, type: String, desc: 'Abbreviation of the associated tutorial stream', allow_blank: false
requires :tutorial_stream_abbr, type: String, desc: 'Abbreviation of the associated tutorial stream', allow_blank: false
end
end
post '/tutorials' do
Expand All @@ -83,6 +83,10 @@ class TutorialsApi < Grape::API
tutorial_stream_abbr = tut_params[:tutorial_stream_abbr]
tutorial_stream = unit.tutorial_streams.find_by!(abbreviation: tutorial_stream_abbr) unless tutorial_stream_abbr.nil?

unless tutorial_stream
error!({ error: 'Tutorial must belong to a tutorial stream' }, 403)
end

tutorial = unit.add_tutorial(tut_params[:meeting_day], tut_params[:meeting_time], tut_params[:meeting_location], tutor, campus, tut_params[:capacity], tut_params[:abbreviation], tutorial_stream)

present tutorial, with: Entities::TutorialEntity
Expand Down
Loading