diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml deleted file mode 100644 index 37b752e8c..000000000 --- a/.idea/dataSources.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - mysql - com.mysql.jdbc.Driver - jdbc:mysql://127.0.0.1/trustie - root - df9bdf98df99df9e - - - - mysql - com.mysql.jdbc.Driver - jdbc:mysql://127.0.0.1/trustie - root - dfc5dfd8dfcbdfc9dfc6dfcfdf9bdf9adfcd - - - - mysql - com.mysql.jdbc.Driver - jdbc:mysql://127.0.0.1/0623newblank - root - dfc5dfd8dfcbdfc9dfc6dfcfdf9bdf9adfcd - - - - mysql - com.mysql.jdbc.Driver - jdbc:mysql://127.0.0.1/trustie - root - dfcbdfc6dfcbdfc4dfc6dfc5dfc4dfcd - - - - mysql - com.mysql.jdbc.Driver - jdbc:mysql://127.0.0.1/trustie - root - dfcbdfc6dfcbdfc4dfc6dfc5dfc4dfcd - - - - mysql - com.mysql.jdbc.Driver - jdbc:mysql://127.0.0.1/trustie - root - dfcbdfc6dfcbdfc4dfc6dfc5dfc4dfcd - - - - - diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 6f838f5a5..61d2b13fb 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -581,7 +581,7 @@ class AccountController < ApplicationController def apply_trail apply_action = ApplyAction.where(:user_id => User.current.id, :container_type => "TrialAuthorization", :status => 0).first if apply_action.blank? - ApplyAction.create(:user_id => User.current.id, :status => 0, :container_type => "TrialAuthorization") + ApplyAction.create(:user_id => User.current.id, :status => 0, :container_type => "TrialAuthorization", :apply_reason => params[:apply_reason]) end respond_to do |format| format.js diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 835b779a4..df8b0697e 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -8,9 +8,17 @@ class ShixunsController < ApplicationController before_filter :shixun_view_allow, :only => [:show] before_filter :require_manager, :only => [ :settings, :add_script, :publish, :collaborators_delete, :shixun_members_added, :add_collaborators] before_filter :validation_email, :only => [:new] - #skip_before_filter :verify_authenticity_token, :only => :update_propaedeutics + skip_before_filter :verify_authenticity_token, :only => [:gitlab_hook] include ApplicationHelper + CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) + DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) + + # push代码的时候会触发gitlab hook + def ghook + shixun_modify_status_without_publish(@shixun, 1) + render :json => {status: "success"} + end def shixun_migrate unless User.current.admin? @@ -82,6 +90,7 @@ class ShixunsController < ApplicationController @rev = params[:rev] file_content = g.files(@shixun.gpid, @path, @rev).content @content = tran_base64_decode64(file_content) + respond_to do |format| format.js end @@ -446,7 +455,6 @@ class ShixunsController < ApplicationController end end - CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) def create identifier = generate_identifier @shixun = Shixun.new(params[:shixun]) @@ -476,6 +484,9 @@ class ShixunsController < ApplicationController s = Trustie::Gitlab::Sync.new gproject = s.create_shixun(@shixun, repository) raise "版本库创建失败" if @shixun.gpid.blank? # 若和gitlab没同步成功,则抛出异常 + g = Gitlab.client + hook_url = Setting.protocol + "://" + Setting.host_name + "/shixuns/#{@shixun.identifier}" + "/ghook" + g.add_project_hook(@shixun.gpid, hook_url) redirect_to shixun_path @shixun, notice: l(:notice_successful_create) rescue Exception => e respond_to do |format| @@ -493,14 +504,12 @@ class ShixunsController < ApplicationController end end - CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) def generate_identifier - code = CODES.sample(8).join + code = DCODES.sample(8).join return generate_identifier if Shixun.where(identifier: code).present? code end - DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) def down_generate_identifier type if type == "game" code = DCODES.sample(12).join diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4a6250c1e..805c95632 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -185,7 +185,7 @@ module ApplicationHelper # 实训语言的种类 def shixun_language - ["Java", "C", "C++", "Python2.7", "Python3.6", "MySQL/Java", "Html", "JFinal", "Docker", "Ethereum", "Dynamips"] + ["Java", "C", "C++", "Python2.7", "Python3.6", "MySQL/Java", "Html", "JFinal", "Docker", "Ethereum", "Dynamips", "MachineLearning"] end # 实训试用专业 diff --git a/app/helpers/challenges_helper.rb b/app/helpers/challenges_helper.rb index dd63cc007..3adece07d 100644 --- a/app/helpers/challenges_helper.rb +++ b/app/helpers/challenges_helper.rb @@ -18,7 +18,7 @@ module ChallengesHelper when 0 "".html_safe when 1 - "评测中" + "".html_safe when 2 "".html_safe when 3,nil diff --git a/app/models/apply_action.rb b/app/models/apply_action.rb index 2adb74869..508371521 100644 --- a/app/models/apply_action.rb +++ b/app/models/apply_action.rb @@ -1,7 +1,7 @@ # status:0 审核中 1 同意 2 拒绝 3 撤销 class ApplyAction < ActiveRecord::Base default_scope :order => 'updated_at desc' - attr_accessible :container_id, :container_type, :dealer_id, :reason, :user_id, :status + attr_accessible :container_id, :container_type, :dealer_id, :reason, :user_id, :status, :apply_reason belongs_to :user end diff --git a/app/views/challenges/_task_pass_form.html.erb b/app/views/challenges/_task_pass_form.html.erb index f4d13beff..db5b04874 100644 --- a/app/views/challenges/_task_pass_form.html.erb +++ b/app/views/challenges/_task_pass_form.html.erb @@ -1,5 +1,5 @@ <%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %> -<%= javascript_include_tag '/editormd/editormd.min.js','/editormd/examples/js/jquery.min.js' %> +<%= javascript_include_tag '/editormd/editormd','/editormd/examples/js/jquery.min.js' %>
  • - +
  • diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb index 9ede76d8d..ed7a9464d 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -64,7 +64,7 @@