Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

competitions
SylorHuang 5 years ago
commit 3b70e014b7

@ -1,5 +1,6 @@
class Competitions::CompetitionsController < Competitions::BaseController class Competitions::CompetitionsController < Competitions::BaseController
skip_before_action :require_login skip_before_action :require_login
before_action :allow_visit, except: [:index]
def index def index
# 已上架 或者 即将上架 # 已上架 或者 即将上架
@ -24,10 +25,10 @@ class Competitions::CompetitionsController < Competitions::BaseController
end end
def show def show
unless current_competition.published? || admin_or_business? end
render_forbidden
return def common_header
end
end end
private private
@ -35,4 +36,11 @@ class Competitions::CompetitionsController < Competitions::BaseController
def current_competition def current_competition
@_current_competition ||= Competition.find_by!(identifier: params[:id]) @_current_competition ||= Competition.find_by!(identifier: params[:id])
end end
def allow_visit
unless current_competition.published? || admin_or_business?
render_forbidden
return
end
end
end end

@ -583,6 +583,8 @@ class CoursesController < ApplicationController
# 学生身份的处理 # 学生身份的处理
student_member = course_members.where(role: %i[STUDENT]).take student_member = course_members.where(role: %i[STUDENT]).take
# 不存在则创建学生身份
if params[:roles].include?("STUDENT") && student_member.blank? if params[:roles].include?("STUDENT") && student_member.blank?
correspond_teacher_exist = CourseMember.exists?(user_id: params[:user_id], is_active: 1, course_id: @course.id, role: %i[CREATOR PROFESSOR ASSISTANT_PROFESSOR]) correspond_teacher_exist = CourseMember.exists?(user_id: params[:user_id], is_active: 1, course_id: @course.id, role: %i[CREATOR PROFESSOR ASSISTANT_PROFESSOR])
new_student = CourseMember.new(user_id: params[:user_id], course_id: @course.id, role: 4) new_student = CourseMember.new(user_id: params[:user_id], course_id: @course.id, role: 4)
@ -597,6 +599,9 @@ class CoursesController < ApplicationController
student_member.destroy! student_member.destroy!
CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, [params[:user_id]]) CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, [params[:user_id]])
# CourseDeleteStudentNotifyJob.perform_later(@course.id, [params[:user_id]], current_user.id) # CourseDeleteStudentNotifyJob.perform_later(@course.id, [params[:user_id]], current_user.id)
elsif params[:roles].include?("STUDENT") && student_member.present? && !params[:roles].include?("PROFESSOR") && !params[:roles].include?("ASSISTANT_PROFESSOR")
# 学生身份存在且学生没有教师身份时更新is_active
student_member.update_attributes!(is_active: 1)
end end
normal_status(0, "修改成功") normal_status(0, "修改成功")

@ -1,7 +1,7 @@
json.count @count json.count @count
json.competitions do json.competitions do
json.array! @competitions.each do |competition| json.array! @competitions.each do |competition|
json.extract! competition, :id, :identifier, :name, :sub_title json.extract! competition, :id, :identifier, :name, :sub_title, :bonus, :description
json.visits_count competition.visits json.visits_count competition.visits
member_count = @member_count_map&.fetch(competition.id, 0) || competition.team_members.count member_count = @member_count_map&.fetch(competition.id, 0) || competition.team_members.count

@ -13,6 +13,7 @@ rescue => ex
puts %Q{\033[33m [warning] wechat config or configuration.yml missing, puts %Q{\033[33m [warning] wechat config or configuration.yml missing,
please add it or execute 'cp config/configuration.yml.example config/configuration.yml' \033[0m} please add it or execute 'cp config/configuration.yml.example config/configuration.yml' \033[0m}
wechat_config = {} wechat_config = {}
weapp_config = {}
end end
# 网站应用 # 网站应用

@ -790,6 +790,10 @@ Rails.application.routes.draw do
end end
resources :teachers, only: [:index] resources :teachers, only: [:index]
resources :students, only: [:index] resources :students, only: [:index]
member do
get :common_header
end
end end
end end

@ -0,0 +1,6 @@
class AddDescriptionToCompetitions < ActiveRecord::Migration[5.2]
def change
add_column :competitions, :description, :text
add_column :competitions, :introduction, :text
end
end
Loading…
Cancel
Save