|
|
|
@ -1,11 +1,12 @@
|
|
|
|
|
class Weapps::CourseStickiesController < Weapps::BaseController
|
|
|
|
|
before_action :require_wechat_login!
|
|
|
|
|
# before_action :require_wechat_login!
|
|
|
|
|
before_action :teacher_allowed
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
if current_course.sticky
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
manage_course = current_user.manage_courses.order("sticky=1 desc, sticky_time desc, created_at desc").first
|
|
|
|
|
render_error("该课堂已置顶,请勿重复操作") if current_course.sticky && manage_course&.id.to_i == current_course.id
|
|
|
|
|
current_course.update_attributes!(sticky: 1, sticky_time: Time.now)
|
|
|
|
|
render_ok
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@ -17,4 +18,8 @@ class Weapps::CourseStickiesController < Weapps::BaseController
|
|
|
|
|
def current_course
|
|
|
|
|
@_current_course = Course.find params[:course_id]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def teacher_allowed
|
|
|
|
|
render_forbidden if current_user.course_identity(current_course) > Course::ASSISTANT_PROFESSOR
|
|
|
|
|
end
|
|
|
|
|
end
|