jam-cloud/web/app/controllers/api_lesson_sessions_control...

36 lines
846 B
Ruby

class ApiLessonSessionsController < ApiController
before_filter :api_signed_in_user
before_filter :lookup_lesson, except: [:index]
before_filter :is_teacher, only: [:accept]
before_filter :is_student, only: []
respond_to :json
def index
data = LessonSession.index(current_user, params)
@lesson_sessions = data[:query]
@next = data[:next_page]
render "api_lesson_sessions/index", :layout => nil
end
private
def lookup_lesson
@lesson_session = LessonSession.find(params[:id])
end
def is_teacher
if @lesson_session.teacher != current_user
raise JamPermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR
end
end
def is_student
if @lesson_session.teacher != current_user
raise JamPermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR
end
end
end