diff --git a/app/controllers/trustie_hacks_controller.rb b/app/controllers/trustie_hacks_controller.rb index f427caf72..d66f5a215 100644 --- a/app/controllers/trustie_hacks_controller.rb +++ b/app/controllers/trustie_hacks_controller.rb @@ -2,7 +2,7 @@ class TrustieHacksController < ApplicationController before_action :require_admin, :except => [:index] before_action :require_login, :except => [:index] before_action :find_hackathon - before_action :find_hack, :except => [:create, :index] + before_action :find_hack, :except => [:create, :index, :edit_hackathon, :update_hackathon] def index ## 分页参数 @@ -16,7 +16,7 @@ class TrustieHacksController < ApplicationController end - def edit ;end + def edit;end def create @hackathon.trustie_hacks.create!(name: params[:name], description: params[:description]) @@ -25,12 +25,15 @@ class TrustieHacksController < ApplicationController def update @hack.update_attributes(name: params[:name], description: params[:description]) + render_ok end - def edit_hackathon ;end + def edit_hackathon + end def update_hackathon @hackathon.update_attributes(name: params[:name], description: params[:description]) + render_ok end @@ -38,7 +41,7 @@ class TrustieHacksController < ApplicationController def find_hackathon @hackathon = TrustieHackathon.first || - TrustieHackathon.create(name: params[:name], description: params[:description]) + TrustieHackathon.create!(name: params[:name], description: params[:description]) end def find_hack diff --git a/db/migrate/20191106034825_add_trustie_hackathon_id_for_trustie_hacks.rb b/db/migrate/20191106034825_add_trustie_hackathon_id_for_trustie_hacks.rb new file mode 100644 index 000000000..0c2619ec7 --- /dev/null +++ b/db/migrate/20191106034825_add_trustie_hackathon_id_for_trustie_hacks.rb @@ -0,0 +1,6 @@ +class AddTrustieHackathonIdForTrustieHacks < ActiveRecord::Migration[5.2] + def change + add_column :trustie_hacks, :trustie_hackathon_id, :integer + add_index :trustie_hacks, :trustie_hackathon_id + end +end diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js index ec77f7e97..ed129d8bd 100755 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js @@ -235,13 +235,16 @@ class CompetitionCommon extends Component{ this.props.showProfileCompleteDialog() return } + if(url===undefined){ let {data,signupdata}=this.state; - if(signupdata.enrolled===true){ - this.props.history.replace(`/courses/${data.course_id}`); - }else{ + // if(signupdata.enrolled===true){ + // this.props.history.replace(`/courses/${data.course_id}`); + // }else{ } + if (data.member_of_course === true) { - this.props.history.replace(`/courses/${data.course_id}`); + // this.props.history.replace(`/courses/${data.course_id}`); + window.open(`/courses/${data.course_id}`) } else { // 以学生身份调用加入课堂 进入课堂首页 let url = "/courses/apply_to_join_course.json" @@ -251,15 +254,18 @@ class CompetitionCommon extends Component{ } ).then((response) => { if (response.data.status === 0) { - this.props.history.replace(`/courses/${data.course_id}`); + // this.props.history.replace(); + this.Personalregistration(`/courses/${data.course_id}`) } }) + } - } + }else{ if (url === "personal") { - this.Personalregistration() + let urls = `/competitions/${this.props.match.params.identifier}/enroll`; + this.Personalregistration(urls) } else { this.props.history.replace(url); } @@ -268,10 +274,10 @@ class CompetitionCommon extends Component{ } - Personalregistration = () => { + Personalregistration = (urls) => { let {signupdata} = this.state; - let urls = `/competitions/${this.props.match.params.identifier}/enroll`; + if (signupdata.enroll_ended === true) { //已截止 this.props.showNotification(`报名已截止`); @@ -286,7 +292,8 @@ class CompetitionCommon extends Component{ if (response) { if (response.data) { this.props.showNotification(`报名成功,预祝您夺得桂冠!`); - this.props.history.replace(urls); + // this.props.history.replace(urls); + window.open(urls) } } }).catch((error) => {