From 707e6102a1b66d979d22b035eb77f75393e0cdcd Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Thu, 21 Nov 2019 16:33:24 +0800
Subject: [PATCH 1/7] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=AF=BC=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/admins/shixun_settings_controller.rb | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/controllers/admins/shixun_settings_controller.rb b/app/controllers/admins/shixun_settings_controller.rb
index d635ae8df..96d373459 100644
--- a/app/controllers/admins/shixun_settings_controller.rb
+++ b/app/controllers/admins/shixun_settings_controller.rb
@@ -65,19 +65,19 @@ class Admins::ShixunSettingsController < Admins::BaseController
sheet1.row(0).default_format = blue
sheet1.row(0).concat(["实训ID","实训名称","技术平台", "Fork源", "实践任务","选择题任务","挑战人数", "通关人数", "状态","创建者", "单位", "职业", "关卡序号","关卡名称","技能标签"])
count_row = 1
- shixuns.find_each do |shixun|
+ shixuns.includes(:challenges, :user, :myshixuns).find_each do |shixun|
sheet1[count_row, 0] = shixun.identifier
sheet1[count_row, 1] = shixun.name
sheet1[count_row, 2] = shixun.shixun_main_name
sheet1[count_row, 3] = shixun.fork_identifier
sheet1[count_row, 4] = shixun.challenges.practice_type.count
sheet1[count_row, 5] = shixun.challenges.choose_type.count
- sheet1[count_row, 6] = shixun.myshixuns.count
- sheet1[count_row, 7] = shixun.myshixuns.finished.count
+ sheet1[count_row, 6] = shixun.myshixuns_count
+ sheet1[count_row, 7] = shixun.myshixuns.map{|m| m.status = 1}.size
sheet1[count_row, 8] = shixun.shixun_status
- sheet1[count_row, 9] = shixun.owner.show_real_name
- sheet1[count_row, 10] = shixun.owner.school_name
- sheet1[count_row, 11] = shixun.owner.identity
+ sheet1[count_row, 9] = shixun.user.show_real_name
+ sheet1[count_row, 10] = shixun.user.school_name
+ sheet1[count_row, 11] = shixun.user.identity
shixun.challenges.each do |challenge|
sheet1[count_row, 12] = "第#{challenge.position}关"
sheet1[count_row, 13] = challenge.subject
From 50550eae9099c85b3fc4436f35ed1e4ef02d9bc0 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Thu, 21 Nov 2019 16:37:59 +0800
Subject: [PATCH 2/7] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=AE=9E=E8=AE=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/admins/shixun_settings_controller.rb | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/controllers/admins/shixun_settings_controller.rb b/app/controllers/admins/shixun_settings_controller.rb
index 96d373459..749ce34bf 100644
--- a/app/controllers/admins/shixun_settings_controller.rb
+++ b/app/controllers/admins/shixun_settings_controller.rb
@@ -65,15 +65,15 @@ class Admins::ShixunSettingsController < Admins::BaseController
sheet1.row(0).default_format = blue
sheet1.row(0).concat(["实训ID","实训名称","技术平台", "Fork源", "实践任务","选择题任务","挑战人数", "通关人数", "状态","创建者", "单位", "职业", "关卡序号","关卡名称","技能标签"])
count_row = 1
- shixuns.includes(:challenges, :user, :myshixuns).find_each do |shixun|
+ shixuns.includes(:challenges, :user, :myshixuns, :mirror_repositories).find_each do |shixun|
sheet1[count_row, 0] = shixun.identifier
sheet1[count_row, 1] = shixun.name
- sheet1[count_row, 2] = shixun.shixun_main_name
+ sheet1[count_row, 2] = shixun.mirror_repositories.map{|mr| mr.main_type == 1}.first&.type_name
sheet1[count_row, 3] = shixun.fork_identifier
- sheet1[count_row, 4] = shixun.challenges.practice_type.count
- sheet1[count_row, 5] = shixun.challenges.choose_type.count
+ sheet1[count_row, 4] = shixun.challenges.map{|c| c.st == 0}.size
+ sheet1[count_row, 5] = shixun.challenges.map{|c| c.st == 1}.size
sheet1[count_row, 6] = shixun.myshixuns_count
- sheet1[count_row, 7] = shixun.myshixuns.map{|m| m.status = 1}.size
+ sheet1[count_row, 7] = shixun.myshixuns.map{|m| m.status == 1}.size
sheet1[count_row, 8] = shixun.shixun_status
sheet1[count_row, 9] = shixun.user.show_real_name
sheet1[count_row, 10] = shixun.user.school_name
From 9c7c21a513c937f324cb58eda2cee8145aabe875 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Thu, 21 Nov 2019 16:45:09 +0800
Subject: [PATCH 3/7] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/helpers/weapps/courses_helper.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/helpers/weapps/courses_helper.rb b/app/helpers/weapps/courses_helper.rb
index a58127c4c..94769fc2e 100644
--- a/app/helpers/weapps/courses_helper.rb
+++ b/app/helpers/weapps/courses_helper.rb
@@ -23,6 +23,7 @@ module Weapps::CoursesHelper
data = data.sort do |a, b|
[a[:letter]] <=> [b[:letter]]
end
+ data.push(data.shift) if data.select{|a|a[:letter]=='#'}.first.present? # '#'排在最后
return data
end
@@ -49,6 +50,7 @@ module Weapps::CoursesHelper
data = data.sort do |a, b|
[a[:letter]] <=> [b[:letter]]
end
+ data.push(data.shift) if data.select{|a|a[:letter]=='#'}.first.present? # '#'排在最后
return data
end
From 6442b1e3ab9a63c78b7a2cab593e2efb0dc91db7 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Thu, 21 Nov 2019 16:48:43 +0800
Subject: [PATCH 4/7] 1
---
app/controllers/admins/shixun_settings_controller.rb | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/app/controllers/admins/shixun_settings_controller.rb b/app/controllers/admins/shixun_settings_controller.rb
index 749ce34bf..822bc2bdf 100644
--- a/app/controllers/admins/shixun_settings_controller.rb
+++ b/app/controllers/admins/shixun_settings_controller.rb
@@ -68,12 +68,13 @@ class Admins::ShixunSettingsController < Admins::BaseController
shixuns.includes(:challenges, :user, :myshixuns, :mirror_repositories).find_each do |shixun|
sheet1[count_row, 0] = shixun.identifier
sheet1[count_row, 1] = shixun.name
- sheet1[count_row, 2] = shixun.mirror_repositories.map{|mr| mr.main_type == 1}.first&.type_name
+ sheet1[count_row, 2] = shixun.mirror_repositories.select{|mr| mr.main_type == "1"}.first&.type_name
+
sheet1[count_row, 3] = shixun.fork_identifier
- sheet1[count_row, 4] = shixun.challenges.map{|c| c.st == 0}.size
- sheet1[count_row, 5] = shixun.challenges.map{|c| c.st == 1}.size
+ sheet1[count_row, 4] = shixun.challenges.select{|c| c.st == 0}.size
+ sheet1[count_row, 5] = shixun.challenges.select{|c| c.st == 1}.size
sheet1[count_row, 6] = shixun.myshixuns_count
- sheet1[count_row, 7] = shixun.myshixuns.map{|m| m.status == 1}.size
+ sheet1[count_row, 7] = shixun.myshixuns.select{|m| m.status == 1}.size
sheet1[count_row, 8] = shixun.shixun_status
sheet1[count_row, 9] = shixun.user.show_real_name
sheet1[count_row, 10] = shixun.user.school_name
From 75ab3578fdc7243eaade117675bf4c39f950310e Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Thu, 21 Nov 2019 16:54:20 +0800
Subject: [PATCH 5/7] =?UTF-8?q?=E5=AE=9E=E5=90=8D/=E8=81=8C=E4=B8=9A?=
=?UTF-8?q?=E8=AE=A4=E8=AF=81=E9=87=8D=E6=96=B0=E8=AE=A4=E8=AF=81=E6=97=B6?=
=?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=B7=B2=E7=94=B3=E8=AF=B7=E7=9A=84=E5=88=A4?=
=?UTF-8?q?=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/services/users/apply_authentication_service.rb | 4 +++-
app/services/users/apply_professional_auth_service.rb | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/app/services/users/apply_authentication_service.rb b/app/services/users/apply_authentication_service.rb
index b4aa8f496..a6b02f431 100644
--- a/app/services/users/apply_authentication_service.rb
+++ b/app/services/users/apply_authentication_service.rb
@@ -10,7 +10,7 @@ class Users::ApplyAuthenticationService < ApplicationService
raise Error, '请先完善基本信息' unless user.profile_completed?
Users::ApplyAuthenticationForm.new(params).validate!
- raise Error, '您已经申请过实名认证了' if ApplyUserAuthentication.real_name_auth.processing.exists?(user_id: user.id)
+ # raise Error, '您已经申请过实名认证了' if ApplyUserAuthentication.real_name_auth.processing.exists?(user_id: user.id)
user.lastname = params[:name].to_s.strip
user.firstname = ''
@@ -18,6 +18,8 @@ class Users::ApplyAuthenticationService < ApplicationService
user.show_realname = params[:show_realname].to_s == 'true' if params[:show_realname].to_s.present?
ActiveRecord::Base.transaction do
+ ApplyUserAuthentication.real_name_auth.processing.where(user_id: user.id).destroy_all
+
user.authentication = true
user.save!
diff --git a/app/services/users/apply_professional_auth_service.rb b/app/services/users/apply_professional_auth_service.rb
index 074f1cee7..c64c07cdd 100644
--- a/app/services/users/apply_professional_auth_service.rb
+++ b/app/services/users/apply_professional_auth_service.rb
@@ -12,7 +12,7 @@ class Users::ApplyProfessionalAuthService < ApplicationService
raise Error, '请先完善基本信息' unless user.profile_completed?
Users::ApplyProfessionalAuthForm.new(params).validate!
- raise Error, '您已经申请过职业认证了' if ApplyUserAuthentication.professional_auth.processing.exists?(user_id: user.id)
+ # raise Error, '您已经申请过职业认证了' if ApplyUserAuthentication.professional_auth.processing.exists?(user_id: user.id)
extension = user.user_extension
extension.school_id = params[:school_id]
@@ -31,6 +31,7 @@ class Users::ApplyProfessionalAuthService < ApplicationService
end
ActiveRecord::Base.transaction do
+ ApplyUserAuthentication.professional_auth.processing.where(user_id: user.id).destroy_all
user.save!
extension.save!
From 15f695d26b5329765aabe2d6632136a7c65d7b5f Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Thu, 21 Nov 2019 17:10:12 +0800
Subject: [PATCH 6/7] =?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/services/users/apply_professional_auth_service.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/services/users/apply_professional_auth_service.rb b/app/services/users/apply_professional_auth_service.rb
index c64c07cdd..c94481890 100644
--- a/app/services/users/apply_professional_auth_service.rb
+++ b/app/services/users/apply_professional_auth_service.rb
@@ -19,7 +19,7 @@ class Users::ApplyProfessionalAuthService < ApplicationService
extension.department_id = params[:department_id]
extension.identity = params[:identity]
- user.professional_certification = extension.identity != 0
+ user.professional_certification = params[:identity] != "teacher"
extra = params[:extra].to_s.strip.presence
if extension.identity.to_s == 'student'
From 3dbca5555790c4b338a9659f8dbe4c9032d8abfd Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Thu, 21 Nov 2019 17:13:42 +0800
Subject: [PATCH 7/7] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=AE=9E=E8=AE=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/admins/shixun_settings_controller.rb | 2 +-
app/models/shixun.rb | 5 +++--
app/views/admins/shixun_settings/shared/_td.html.erb | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/app/controllers/admins/shixun_settings_controller.rb b/app/controllers/admins/shixun_settings_controller.rb
index 822bc2bdf..216c9d909 100644
--- a/app/controllers/admins/shixun_settings_controller.rb
+++ b/app/controllers/admins/shixun_settings_controller.rb
@@ -65,7 +65,7 @@ class Admins::ShixunSettingsController < Admins::BaseController
sheet1.row(0).default_format = blue
sheet1.row(0).concat(["实训ID","实训名称","技术平台", "Fork源", "实践任务","选择题任务","挑战人数", "通关人数", "状态","创建者", "单位", "职业", "关卡序号","关卡名称","技能标签"])
count_row = 1
- shixuns.includes(:challenges, :user, :myshixuns, :mirror_repositories).find_each do |shixun|
+ shixuns.includes(:fork_shixuns, :myshixuns, :mirror_repositories, challenges: [:challenge_tags], user: [user_extension: :school]).find_each do |shixun|
sheet1[count_row, 0] = shixun.identifier
sheet1[count_row, 1] = shixun.name
sheet1[count_row, 2] = shixun.mirror_repositories.select{|mr| mr.main_type == "1"}.first&.type_name
diff --git a/app/models/shixun.rb b/app/models/shixun.rb
index a0f88260b..e8aa1b186 100644
--- a/app/models/shixun.rb
+++ b/app/models/shixun.rb
@@ -28,6 +28,7 @@ class Shixun < ApplicationRecord
has_one :first_tag_repertoire, through: :first_shixun_tag_repertoire, source: :tag_repertoire
has_many :homework_commons_shixuns, class_name: 'HomeworkCommonsShixun'
+ has_many :fork_shixuns, foreign_key: "fork_from", class_name: 'Shixun'
#实训的关卡
has_many :exercise_shixun_challenges, :dependent => :destroy
@@ -97,7 +98,7 @@ class Shixun < ApplicationRecord
end
def fork_identifier
- self.fork_from.nil? ? "--" : Shixun.where(id: self.fork_from).first.try(:identifier)
+ self.fork_from.nil? ? "--" : fork_shixuns.first&.identifier
end
def shixun_status
@@ -171,7 +172,7 @@ class Shixun < ApplicationRecord
end
def owner
- User.find(self.user_id)
+ User.find_by_id(self.user_id)
end
def shixun_main_name
diff --git a/app/views/admins/shixun_settings/shared/_td.html.erb b/app/views/admins/shixun_settings/shared/_td.html.erb
index ddbbdff02..f4a05f178 100644
--- a/app/views/admins/shixun_settings/shared/_td.html.erb
+++ b/app/views/admins/shixun_settings/shared/_td.html.erb
@@ -27,7 +27,7 @@
<%= raw '
' if weappImageExists %>
<%= javascript_void_link weappImageExists ? '重新上传' : '上传图片', class: 'action upload-shixun-weapp-image-action', data: { source_id: shixun.id, source_type: 'Shixun', suffix: '_weapp', toggle: 'modal', target: '.admin-upload-file-modal' } %>
-