From 9fee0222ba9dd330efcb35942ff450e71259f39a Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 18 Mar 2019 09:43:22 +0800 Subject: [PATCH 1/6] ecloud auth --- app/controllers/ecloud_controller.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 89a240c4..a391bcf4 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -17,7 +17,7 @@ require 'digest' class EcloudController < ApplicationController skip_before_filter :verify_authenticity_token - before_filter :check_sign, only: [:ps_new, :ps_update, :bs_new, :bs_update] + # before_filter :check_sign, only: [:ps_new, :ps_update, :bs_new, :bs_update] before_filter :save_para before_filter :user_setup @@ -105,6 +105,8 @@ class EcloudController < ApplicationController des_services = params['services'].select{|s| s['opttype'] == 1} if des_services.present? des_services.each do |ds| + + logger.info("666666#{ecloud.try(:id)}, 55555555#{ds['code']}") esd = EcloudService.where(ecloud_id: ecloud.try(:id), code: ds['code']).first esd.update_attributes!(opttype: ds['opttype'], begintime: ds['begintime'], endtime: ds['endtime']) end @@ -144,10 +146,10 @@ class EcloudController < ApplicationController # end render :json => {result: true, errmsg: ""} - rescue Exception => e - logger.error(e.message) - render :json => {code: 500, msg: "#{e.message}"} - raise ActiveRecord::Rollback + # rescue Exception => e + # logger.error(e.message) + # render :json => {code: 500, msg: "#{e.message}"} + # raise ActiveRecord::Rollback end end end From cfcfc9c58072158ed11b1316821c022fef75b733 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 29 Mar 2019 15:59:44 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0329070441_migrate_homework_common_end_times.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 db/migrate/20190329070441_migrate_homework_common_end_times.rb diff --git a/db/migrate/20190329070441_migrate_homework_common_end_times.rb b/db/migrate/20190329070441_migrate_homework_common_end_times.rb new file mode 100644 index 00000000..0fa7b6cb --- /dev/null +++ b/db/migrate/20190329070441_migrate_homework_common_end_times.rb @@ -0,0 +1,14 @@ +class MigrateHomeworkCommonEndTimes < ActiveRecord::Migration + def up + homework_commons = HomeworkCommon.where("id < 21549") + homework_commons.find_each do |homework| + sql = "update homework_commons set end_time = (select max(end_time) from + homework_seconds where id = #{homework.id}) where id = #{homework.id}" + + ActiveRecord::Base.connection.execute(sql) + end + end + + def down + end +end From e621a54f06ded6fe0b558ab3b6bd282d47520b9b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 29 Mar 2019 16:28:46 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=AE=9E=E8=AE=AD=E8=A2=AB=E2=80=9C=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E2=80=9D=E5=90=8E=EF=BC=8C=E8=AF=B7=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E2=80=9C=E6=9A=82=E6=9C=AA=E5=85=AC=E5=BC=80?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/subjects_helper.rb | 58 ++++++++++--------- app/views/subjects/_paths_list.html.erb | 2 +- ...80718_migrate_homework_common_end_time2.rb | 13 +++++ 3 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 db/migrate/20190329080718_migrate_homework_common_end_time2.rb diff --git a/app/helpers/subjects_helper.rb b/app/helpers/subjects_helper.rb index c81d560b..0a8d659f 100644 --- a/app/helpers/subjects_helper.rb +++ b/app/helpers/subjects_helper.rb @@ -6,32 +6,36 @@ module SubjectsHelper end # 实训路径详情列表,右侧状态显示栏 - def shixun_show_in_subject subject_status, shixun_status - content = if subject_status < 2 - case shixun_status - when 0, 1 - '暂未公开' - when 2 - '已发布' - when 3 - '已关闭' - else - "" - end - else - if shixun_status != 2 - case shixun_status - when 0, 1 - '暂未公开' - when 3 - '已关闭' - else - "" - end - else - "" - end - end + def shixun_show_in_subject subject_status, shixun_status, shixun_hidden + content = if shixun_hidden + '暂未公开' + else + if subject_status < 2 + case shixun_status + when 0, 1 + '暂未公开' + when 2 + '已发布' + when 3 + '已关闭' + else + "" + end + else + if shixun_status != 2 + case shixun_status + when 0, 1 + '暂未公开' + when 3 + '已关闭' + else + "" + end + else + "" + end + end + end return content.html_safe end @@ -39,7 +43,7 @@ module SubjectsHelper def start_shixun_in_subject subject, shixun, myshixun is_modify = ShixunModify.where(:myshixun_id => myshixun.try(:id), :shixun_id => shixun.try(:id), :status => 1).first content_before = '' - content = if shixun.status == 2 || User.current.manager_of_shixun?(shixun) + content = if (shixun.status == 2 && !shixun.hidden) || User.current.manager_of_shixun?(shixun) content_before = "查看详情" if User.current.try(:mail).blank? %Q{开始实战} diff --git a/app/views/subjects/_paths_list.html.erb b/app/views/subjects/_paths_list.html.erb index 615eaa18..fdd5e262 100644 --- a/app/views/subjects/_paths_list.html.erb +++ b/app/views/subjects/_paths_list.html.erb @@ -61,7 +61,7 @@ "><%= s_index + 1 %>-<%= index + 1 %>  <%= shixun.name %>
  • - <%= shixun_show_in_subject @subject.status, shixun.status %> + <%= shixun_show_in_subject @subject.status, shixun.status, shixun.hidden %> <%= start_shixun_in_subject @subject, shixun, myshixun %>
  • diff --git a/db/migrate/20190329080718_migrate_homework_common_end_time2.rb b/db/migrate/20190329080718_migrate_homework_common_end_time2.rb new file mode 100644 index 00000000..65d4670a --- /dev/null +++ b/db/migrate/20190329080718_migrate_homework_common_end_time2.rb @@ -0,0 +1,13 @@ +class MigrateHomeworkCommonEndTime2 < ActiveRecord::Migration + def up + homework_commons = HomeworkCommon.where("id >= 21549") + homework_commons.each do |homework| + if homework.publish_time.nil? + homework.update_column('end_time', nil) + end + end + end + + def down + end +end From ee630954d5059b5a970ab395026b344053a131b4 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 30 Mar 2019 21:07:39 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 8f3a2b53..61ea8dc9 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -1125,8 +1125,8 @@ class AccountController < ApplicationController def bind_email_or_phone @user = User.current - begin - ActiveRecord::Base.transaction do + #begin + #ActiveRecord::Base.transaction do if params[:type] == "phone" @user.update_attributes!(:phone => params[:value]) reward_grade(@user, @user.id, 'Phone', 500) @@ -1135,10 +1135,10 @@ class AccountController < ApplicationController Gitlab.client.edit_user_email(@user.gid, :email => @user.mail) if @user.gid reward_grade(@user, @user.id, 'Mail', 500) end - end - rescue - raise ActiveRecord::Rollback - end + #end + #rescue + # raise ActiveRecord::Rollback + #end redirect_to my_account_path end From f7b95af92f581a76451f7a3120d15dfe7593ca1b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 30 Mar 2019 21:11:36 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 61ea8dc9..60f9362a 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -1126,7 +1126,7 @@ class AccountController < ApplicationController def bind_email_or_phone @user = User.current #begin - #ActiveRecord::Base.transaction do + ActiveRecord::Base.transaction do if params[:type] == "phone" @user.update_attributes!(:phone => params[:value]) reward_grade(@user, @user.id, 'Phone', 500) @@ -1135,7 +1135,7 @@ class AccountController < ApplicationController Gitlab.client.edit_user_email(@user.gid, :email => @user.mail) if @user.gid reward_grade(@user, @user.id, 'Mail', 500) end - #end + end #rescue # raise ActiveRecord::Rollback #end From 03c3729ea30f91b5b1d9cc42df14d2c348b117ca Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 30 Mar 2019 21:41:54 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 60f9362a..0b4a5841 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -1125,20 +1125,20 @@ class AccountController < ApplicationController def bind_email_or_phone @user = User.current - #begin + begin ActiveRecord::Base.transaction do if params[:type] == "phone" @user.update_attributes!(:phone => params[:value]) reward_grade(@user, @user.id, 'Phone', 500) else @user.update_attributes!(:mail => params[:value]) - Gitlab.client.edit_user_email(@user.gid, :email => @user.mail) if @user.gid + # Gitlab.client.edit_user_email(@user.gid, :email => @user.mail) if @user.gid reward_grade(@user, @user.id, 'Mail', 500) end end - #rescue - # raise ActiveRecord::Rollback - #end + rescue + raise ActiveRecord::Rollback + end redirect_to my_account_path end