主办方
-
+
+
+
From 11df2d33362c24d0be218c083990647f941c7a75 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Fri, 25 Oct 2019 09:55:18 +0800
Subject: [PATCH 04/11] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/competitions/competitions/common_header.json.jbuilder | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/views/competitions/competitions/common_header.json.jbuilder b/app/views/competitions/competitions/common_header.json.jbuilder
index 0ecf6cfd5..2a1e0a92d 100644
--- a/app/views/competitions/competitions/common_header.json.jbuilder
+++ b/app/views/competitions/competitions/common_header.json.jbuilder
@@ -21,6 +21,7 @@ json.stages
if @competition.mode == 2
json.course_id @competition.competition_mode_setting&.course_id
+ json.invite_code @competition.competition_mode_setting&.course&.invite_code
json.member_of_course @user.member_of_course?(@competition.competition_mode_setting&.course)
end
From 380f2a62d7ebb0108ad1459a53270d87ede1fab8 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Fri, 25 Oct 2019 09:58:26 +0800
Subject: [PATCH 05/11] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/competition_module.rb | 2 +-
app/views/competitions/competition_modules/show.json.jbuilder | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/models/competition_module.rb b/app/models/competition_module.rb
index 3fdab6b37..3b1bfddda 100644
--- a/app/models/competition_module.rb
+++ b/app/models/competition_module.rb
@@ -3,7 +3,7 @@ class CompetitionModule < ApplicationRecord
belongs_to :competition
- has_one :competition_module_md_content, dependent: :destroy
+ has_many :competition_module_md_contents, dependent: :destroy
def module_url
result_url = url.present? ? url : case module_type
diff --git a/app/views/competitions/competition_modules/show.json.jbuilder b/app/views/competitions/competition_modules/show.json.jbuilder
index 116934ee8..14c3c0f57 100644
--- a/app/views/competitions/competition_modules/show.json.jbuilder
+++ b/app/views/competitions/competition_modules/show.json.jbuilder
@@ -1,6 +1,6 @@
json.extract! @module, :id, :name, :position, :url
-md = @module.competition_module_md_content
+md = @module.competition_module_md_contents.take
if md.present?
json.md_id md.id
json.md_name md.name
From 86c1c370be4ab05d8bf36cbc17830318c7df5106 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Fri, 25 Oct 2019 10:01:19 +0800
Subject: [PATCH 06/11] =?UTF-8?q?=E5=A4=B4=E9=83=A8=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Competitioncommon/CompetitionCommon.js | 64 +++++++++++++++++--
.../CompetitionContentsMd.js | 1 -
2 files changed, 58 insertions(+), 7 deletions(-)
diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js
index a83f799fb..40bf83f5e 100644
--- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js
+++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js
@@ -60,6 +60,22 @@ class CompetitionCommon extends Component{
}).catch((error) => {
console.log(error)
})
+
+ // console.log("调用了GetenrollmentAPI");
+ const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`;
+ axios.get((zul)).then((result) => {
+ if (result) {
+ if (result.data) {
+
+ this.setState({
+ signupdata:result.data
+ })
+
+ }
+ }
+ }).catch((error) => {
+ //// //////console.log(error);
+ })
}
getrightdatas=(e)=>{
@@ -80,7 +96,7 @@ class CompetitionCommon extends Component{
})
}
getrightdata=(id,typeid,module_url,has_url)=>{
- console.log(id,typeid,module_url,has_url)
+
this.setState({
module_id:id,
module_type:typeid
@@ -122,10 +138,47 @@ class CompetitionCommon extends Component{
}
+ gotocourse=(url)=>{
+ if(this.props.checkIfLogin()===false){
+ this.props.showLoginDialog()
+ return
+ }
+ if(this.props.checkIfProfileCompleted()===false){
+ 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(data.member_of_course===true){
+ this.props.history.replace(`/courses/${data.course_id}`);
+ }else{
+ // 以学生身份调用加入课堂 进入课堂首页
+ let url="/courses/apply_to_join_course.json"
+ axios.post(url, {
+ invite_code:data.invite_code,
+ student:1
+ }
+ ).then((response) => {
+ if(response.data.status===0){
+ this.props.history.replace(`/courses/${data.course_id}`);
+ }
+ })
+ }
+
+ }
+ }else{
+ this.props.history.replace(url);
+ }
+
+ }
render() {
let {data,bannerdata,module_type,Competitionedittype,mdContentdata}=this.state;
- console.log(module_type)
+
return (
data===undefined?"":
@@ -204,10 +257,9 @@ class CompetitionCommon extends Component{
:
-
}
+ data.competition_status==="progressing"?
:""}
{data&&data.enroll_end_time===null?"":`报名截止时间:${data&&data.enroll_end_time}`}
diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsMd.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsMd.js
index f5043f187..8a1bd9fd6 100644
--- a/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsMd.js
+++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsMd.js
@@ -100,7 +100,6 @@ class CompetitionContentsMd extends Component{
md_content_id:this.props.mdContentdata.md_id,
competition_module_id:this.props.mdContentdata.id,
content:mdContnet,
- name:"编辑",
attachment_ids:attachment_ids
}
).then((response) => {
From 3542fbc875b7f880183da6a848c85a7da9b3ef72 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Fri, 25 Oct 2019 10:02:41 +0800
Subject: [PATCH 07/11] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E8=AF=A6=E6=83=85?=
=?UTF-8?q?=E5=A4=B4=E9=83=A8=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../modules/competitions/Competitioncommon/CompetitionCommon.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js
index 40bf83f5e..2fcdfb524 100644
--- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js
+++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js
@@ -227,7 +227,7 @@ class CompetitionCommon extends Component{
{data.competition_status==="nearly_published"?"--":data&&data.visits_count}
-
{data.competition_status==="nearly_published"?"--":data&&data.member_count}
+
this.gotocourse(`/newcompetitions/${this.props.match.params.identifier}/enroll`)}>{data.competition_status==="nearly_published"?"--":data&&data.member_count}
From 625c7fd7b592e7befd178ec842e1eb88a40e6231 Mon Sep 17 00:00:00 2001
From: p31729568
Date: Fri, 25 Oct 2019 10:16:57 +0800
Subject: [PATCH 08/11] weapp: add register code api && competition: add
membets count result
---
.../competition_teams_controller.rb | 1 +
.../weapps/register_codes_controller.rb | 24 +++++++++++++++++++
.../competition_teams/index.json.jbuilder | 1 +
config/routes.rb | 1 +
4 files changed, 27 insertions(+)
create mode 100644 app/controllers/weapps/register_codes_controller.rb
diff --git a/app/controllers/competitions/competition_teams_controller.rb b/app/controllers/competitions/competition_teams_controller.rb
index f20c87b0d..8b69f1872 100644
--- a/app/controllers/competitions/competition_teams_controller.rb
+++ b/app/controllers/competitions/competition_teams_controller.rb
@@ -121,6 +121,7 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController
@all_count = teams.count
@all_teams = paginate(teams.includes(:user, users: { user_extension: :school }))
+ @all_member_count = current_competition.team_members.count
end
def user_competition_teams
diff --git a/app/controllers/weapps/register_codes_controller.rb b/app/controllers/weapps/register_codes_controller.rb
new file mode 100644
index 000000000..ff29101d2
--- /dev/null
+++ b/app/controllers/weapps/register_codes_controller.rb
@@ -0,0 +1,24 @@
+class Weapps::RegisterCodesController < Weapps::BaseController
+ before_action :require_wechat_login!
+
+ def create
+ login = params[:login].to_s.strip
+ if login =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
+ user = User.find_by(mail: login)
+ return render_error('该邮箱已注册') if user.present?
+ elsif login =~ /^1\d{10}$/
+ user = User.find_by(phone: params[:login])
+ return render_error('该手机号已注册') if user.present?
+ else
+ return render_error('请输入正确的邮箱或手机号')
+ end
+
+ code = %W(0 1 2 3 4 5 6 7 8 9)
+ verification_code = code.sample(6).join
+ send_type = login =~ /^1\d{10}$/ ? 1 : 8
+ # 记录验证码
+ check_verification_code(verification_code, send_type, login)
+
+ render_ok
+ end
+end
\ No newline at end of file
diff --git a/app/views/competitions/competition_teams/index.json.jbuilder b/app/views/competitions/competition_teams/index.json.jbuilder
index 3e5dc4d16..f1f01b76a 100644
--- a/app/views/competitions/competition_teams/index.json.jbuilder
+++ b/app/views/competitions/competition_teams/index.json.jbuilder
@@ -1,4 +1,5 @@
json.count @all_count
+json.members_count @all_member_count
json.personal @personal
json.competition_name @competition.name
json.competition_teams do
diff --git a/config/routes.rb b/config/routes.rb
index 8bad9a889..d71f9a4fa 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -852,6 +852,7 @@ Rails.application.routes.draw do
resource :home, only: [:show]
resource :session, only: [:create]
resource :register, only: [:create]
+ resource :register_code, only: [:create]
resource :code_session, only: [:create]
resource :verify, only: [:create]
resource :check_account, only: [:create]
From e9e9ba9d69367842759bd4eafb309efda0d2c78b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Fri, 25 Oct 2019 10:30:26 +0800
Subject: [PATCH 09/11] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E8=AF=A6=E6=83=85?=
=?UTF-8?q?=E5=A4=B4=E9=83=A8=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Competitioncommon/CompetitionCommon.js | 33 ++++++++++---------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js
index 2fcdfb524..3991277fb 100644
--- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js
+++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js
@@ -60,22 +60,23 @@ class CompetitionCommon extends Component{
}).catch((error) => {
console.log(error)
})
+ //console.log(this.props)
+ if(this.props.user&&this.props.user.login!= ""){
+
+ const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`;
+ axios.get((zul)).then((result) => {
+ if (result) {
+ if (result.data) {
+ this.setState({
+ signupdata:result.data
+ })
+ }
+ }
+ }).catch((error) => {
+ //console.log(error);
+ })
+ }
- // console.log("调用了GetenrollmentAPI");
- const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`;
- axios.get((zul)).then((result) => {
- if (result) {
- if (result.data) {
-
- this.setState({
- signupdata:result.data
- })
-
- }
- }
- }).catch((error) => {
- //// //////console.log(error);
- })
}
getrightdatas=(e)=>{
@@ -258,7 +259,7 @@ class CompetitionCommon extends Component{
已结束
:
data.competition_status==="progressing"?:""}
{data&&data.enroll_end_time===null?"":`报名截止时间:${data&&data.enroll_end_time}`}
From 146001a0703a86dc8f581e1a89ebf065f2f2b822 Mon Sep 17 00:00:00 2001
From: p31729568
Date: Fri, 25 Oct 2019 10:31:45 +0800
Subject: [PATCH 10/11] weapp: verification code api
---
.../weapps/register_codes_controller.rb | 24 ---------
.../weapps/verification_codes_controller.rb | 52 +++++++++++++++++++
config/routes.rb | 2 +-
3 files changed, 53 insertions(+), 25 deletions(-)
delete mode 100644 app/controllers/weapps/register_codes_controller.rb
create mode 100644 app/controllers/weapps/verification_codes_controller.rb
diff --git a/app/controllers/weapps/register_codes_controller.rb b/app/controllers/weapps/register_codes_controller.rb
deleted file mode 100644
index ff29101d2..000000000
--- a/app/controllers/weapps/register_codes_controller.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-class Weapps::RegisterCodesController < Weapps::BaseController
- before_action :require_wechat_login!
-
- def create
- login = params[:login].to_s.strip
- if login =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
- user = User.find_by(mail: login)
- return render_error('该邮箱已注册') if user.present?
- elsif login =~ /^1\d{10}$/
- user = User.find_by(phone: params[:login])
- return render_error('该手机号已注册') if user.present?
- else
- return render_error('请输入正确的邮箱或手机号')
- end
-
- code = %W(0 1 2 3 4 5 6 7 8 9)
- verification_code = code.sample(6).join
- send_type = login =~ /^1\d{10}$/ ? 1 : 8
- # 记录验证码
- check_verification_code(verification_code, send_type, login)
-
- render_ok
- end
-end
\ No newline at end of file
diff --git a/app/controllers/weapps/verification_codes_controller.rb b/app/controllers/weapps/verification_codes_controller.rb
new file mode 100644
index 000000000..f23474b43
--- /dev/null
+++ b/app/controllers/weapps/verification_codes_controller.rb
@@ -0,0 +1,52 @@
+class Weapps::VerificationCodesController < Weapps::BaseController
+ before_action :require_wechat_login!
+
+ def create
+ params[:type] == 'register' ? check_can_register : check_can_reset_password
+ end
+
+ private
+
+ def check_can_register
+ login = params[:login].to_s.strip
+ if login =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
+ user = User.find_by(mail: login)
+ return render_error('该邮箱已注册') if user.present?
+ elsif login =~ /^1\d{10}$/
+ user = User.find_by(phone: params[:login])
+ return render_error('该手机号已注册') if user.present?
+ else
+ return render_error('请输入正确的邮箱或手机号')
+ end
+
+ code = %W(0 1 2 3 4 5 6 7 8 9)
+ verification_code = code.sample(6).join
+ send_type = login =~ /^1\d{10}$/ ? 1 : 8
+ # 记录验证码
+ check_verification_code(verification_code, send_type, login)
+
+ render_ok
+ end
+
+ def check_can_reset_password
+ login = params[:login].to_s.strip
+ if login =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
+ user = User.find_by(mail: login)
+ return render_error('该邮箱尚未注册') if user.blank?
+ elsif login =~ /^1\d{10}$/
+ user = User.find_by(phone: login)
+ return render_error('该手机号尚未注册') if user.blank?
+ else
+ user = User.find_by(login: login)
+ return render_error('该账号尚未注册') if user.blank?
+ end
+
+ code = %W(0 1 2 3 4 5 6 7 8 9)
+ verification_code = code.sample(6).join
+ send_type = login =~ /^1\d{10}$/ ? 2 : 3
+ # 记录验证码
+ check_verification_code(verification_code, send_type, login)
+
+ render_ok
+ end
+end
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index d71f9a4fa..10bcb0f74 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -852,7 +852,7 @@ Rails.application.routes.draw do
resource :home, only: [:show]
resource :session, only: [:create]
resource :register, only: [:create]
- resource :register_code, only: [:create]
+ resource :verification_code, only: [:create]
resource :code_session, only: [:create]
resource :verify, only: [:create]
resource :check_account, only: [:create]
From ba393a97aa724314b9ea143355d8ad4409b5e019 Mon Sep 17 00:00:00 2001
From: p31729568
Date: Fri, 25 Oct 2019 10:34:35 +0800
Subject: [PATCH 11/11] weapp: fix
---
app/controllers/weapps/verification_codes_controller.rb | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/app/controllers/weapps/verification_codes_controller.rb b/app/controllers/weapps/verification_codes_controller.rb
index f23474b43..7590c49f7 100644
--- a/app/controllers/weapps/verification_codes_controller.rb
+++ b/app/controllers/weapps/verification_codes_controller.rb
@@ -37,8 +37,7 @@ class Weapps::VerificationCodesController < Weapps::BaseController
user = User.find_by(phone: login)
return render_error('该手机号尚未注册') if user.blank?
else
- user = User.find_by(login: login)
- return render_error('该账号尚未注册') if user.blank?
+ return render_error('请输入正确的邮箱或手机号')
end
code = %W(0 1 2 3 4 5 6 7 8 9)