Merge branch 'dev_aliyun' into dev_daiao

dev_daiao
daiao 6 years ago
commit 88cc8d5610

@ -143,7 +143,7 @@ class Competitions::CompetitionsController < Competitions::BaseController
} }
end end
else else
@records = @records.includes(:team_members, competition_prize_users: :competition_prize, user: :user_extension).limit(@competition.awards_count) @records = @records.includes(:team_members, competition_prize_users: :competition_prize, user: :user_extension).limit(@competition.charts_count)
end end
end end

@ -633,6 +633,9 @@ class CoursesController < ApplicationController
teacher_member = course_members.where(role: %i[CREATOR]).take teacher_member = course_members.where(role: %i[CREATOR]).take
elsif (params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")) && !course_members.exists?(role: %i[PROFESSOR ASSISTANT_PROFESSOR]) elsif (params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")) && !course_members.exists?(role: %i[PROFESSOR ASSISTANT_PROFESSOR])
teacher_member = CourseMember.create!(course_id: @course.id, user_id: params[:user_id], role: params[:roles].include?("PROFESSOR") ? 2 : 3) teacher_member = CourseMember.create!(course_id: @course.id, user_id: params[:user_id], role: params[:roles].include?("PROFESSOR") ? 2 : 3)
# 如果有未审批的申请教师/助教的记录,则修改状态为已审批
apply_teacher = CourseMessage.where(course_id: @course.id, course_message_id: params[:user_id], status: 0).last
apply_teacher.update!(status: 1, apply_user_id: current_user.id)
elsif course_members.exists?(role: %i[PROFESSOR ASSISTANT_PROFESSOR]) elsif course_members.exists?(role: %i[PROFESSOR ASSISTANT_PROFESSOR])
teacher_member = course_members.where(role: %i[PROFESSOR ASSISTANT_PROFESSOR]).take teacher_member = course_members.where(role: %i[PROFESSOR ASSISTANT_PROFESSOR]).take
if params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR") if params[:roles].include?("PROFESSOR") || params[:roles].include?("ASSISTANT_PROFESSOR")
@ -796,18 +799,15 @@ class CoursesController < ApplicationController
if approval == 1 if approval == 1
course_message.pass! course_message.pass!
new_teacher = CourseMember.new(course_id: @course.id, user_id: applier_user.id)
content = course_message.content.to_i content = course_message.content.to_i
if content == 3 || content == 7 role = (content == 3 || content == 7) ? 3 : ((content == 2 || content == 9) ? 2 : nil)
tip_exception("已存在教师/助教身份") if CourseMember.where(course_id: @course.id, user_id: applier_user.id, role: 3).any? if role
new_teacher.ASSISTANT_PROFESSOR! tip_exception("已存在教师/助教身份") if CourseMember.where(course_id: @course.id, user_id: applier_user.id, role: [1, 2 ,3]).any?
elsif content == 2 || content == 9
tip_exception("已存在教师/助教身份") if CourseMember.where(course_id: @course.id, user_id: applier_user.id, role: 2).any?
new_teacher.PROFESSOR!
else else
tip_exception("申请角色错误") tip_exception("申请角色错误")
end end
new_teacher = CourseMember.new(course_id: @course.id, user_id: applier_user.id, role: role)
new_teacher.save! new_teacher.save!
# 课堂管理员才有分配权限且课堂分班数大于0 # 课堂管理员才有分配权限且课堂分班数大于0
@ -830,7 +830,7 @@ class CoursesController < ApplicationController
normal_status(0, "操作成功") normal_status(0, "操作成功")
rescue => e rescue => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("操作失败") tip_exception(e.message)
raise ActiveRecord::Rollback raise ActiveRecord::Rollback
end end
end end

@ -1,5 +1,5 @@
class Weapps::CoursesController < Weapps::BaseController class Weapps::CoursesController < Weapps::BaseController
# before_action :require_wechat_login! before_action :require_login
before_action :teacher_allowed, except: [:create, :show, :shixun_homework_category] before_action :teacher_allowed, except: [:create, :show, :shixun_homework_category]
def create def create

@ -1,5 +1,5 @@
class Weapps::HomesController < Weapps::BaseController class Weapps::HomesController < Weapps::BaseController
before_action :require_wechat_login! before_action :require_login
def show def show
# banner # banner

@ -149,9 +149,9 @@ class Competition < ApplicationRecord
competition_stages.map(&:max_end_time).max competition_stages.map(&:max_end_time).max
end end
# def awards_count def charts_count
# competition_awards.pluck(:num)&.sum > 0 ? competition_awards.pluck(:num)&.sum : 20 competition_prizes&.pluck(:num).sum.to_i > 0 ? competition_prizes&.pluck(:num).sum.to_i : awards_count
# end end
def manager?(user) def manager?(user)
user && competition_managers.exists?(user_id: user.id) user && competition_managers.exists?(user_id: user.id)

Loading…
Cancel
Save