You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/controllers/weapps/course_stickies_controller.rb

25 lines
734 B

5 years ago
class Weapps::CourseStickiesController < Weapps::BaseController
5 years ago
# before_action :require_wechat_login!
5 years ago
before_action :teacher_allowed
def create
5 years ago
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
5 years ago
end
def destroy
end
private
def current_course
@_current_course = Course.find params[:course_id]
end
5 years ago
def teacher_allowed
render_forbidden if current_user.course_identity(current_course) > Course::ASSISTANT_PROFESSOR
end
5 years ago
end