From 5c83414828b06b0ec25479a91836d612e668519c Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 30 Jun 2016 10:17:53 +0800 Subject: [PATCH 01/18] update --- app/controllers/quality_analysis_controller.rb | 8 ++++++++ app/views/quality_analysis/_result_list.html.erb | 2 ++ config/routes.rb | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index a9b93269a..15fdcef61 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -85,6 +85,14 @@ class QualityAnalysisController < ApplicationController end end + def edit + @quality_analysis = QualityAnalysis.where(:id => params[:id]) + end + + def update + @quality_analysis = QualityAnalysis.where(:id => params[:id]) + end + # resource_id: login + @repository.id def index begin diff --git a/app/views/quality_analysis/_result_list.html.erb b/app/views/quality_analysis/_result_list.html.erb index 6124812c8..b4a40de0d 100644 --- a/app/views/quality_analysis/_result_list.html.erb +++ b/app/views/quality_analysis/_result_list.html.erb @@ -7,6 +7,7 @@
  • 分支
  • 语言
  • 路径
  • +
  • bianji
  • <% if @quality_analyses.count >0 %> @@ -17,6 +18,7 @@
  • <%= qa.branch %>
  • <%= qa.language %>
  • <%= qa.path %>
  • +
  • <%=link_to "bianji", edit_project__quality_analysis_path(@quality_analysis) %>
  • <% end %> diff --git a/config/routes.rb b/config/routes.rb index 5dc509abd..5404e4ecf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -786,7 +786,7 @@ RedmineApp::Application.routes.draw do end end - resources :quality_analysis, :only => [:index, :new, :create] do + resources :quality_analysis, :only => [:index, :create, :edit, :update] do collection do end member do From 24f1375a4e2bc0d1a08d7a360a8048861654dbbf Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 30 Jun 2016 17:36:33 +0800 Subject: [PATCH 02/18] modified job --- app/views/quality_analysis/_edit.html.erb | 23 +++++++++++++++++++++++ app/views/quality_analysis/edit.js.erb | 0 2 files changed, 23 insertions(+) create mode 100644 app/views/quality_analysis/_edit.html.erb create mode 100644 app/views/quality_analysis/edit.js.erb diff --git a/app/views/quality_analysis/_edit.html.erb b/app/views/quality_analysis/_edit.html.erb new file mode 100644 index 000000000..d5cd49d0c --- /dev/null +++ b/app/views/quality_analysis/_edit.html.erb @@ -0,0 +1,23 @@ +
    代码质量分析
    +
    + <%= form_tag( url_for(:controller => 'quality_analysis', :action => 'create', :project_id => @project.id, :user_id => User.current.id, :identifier => @repository.identifier, :rep_id => @repository.id), :remote => true, :id => 'quality_analyses_form') do %> +
    +
    + +
    +
    +
    + <%= select_tag :branch, options_for_select(["#{@gitlab_default_branch}"]+ @branch_names, @rev), :id => 'branch', :class => "analysis-option-box" %> +
    +
    +
    +
    + <%= select_tag :language, options_for_select(["java","python","ruby","c++","c#","c"]), :id => 'branch', :class => "analysis-option-box" %> +
    +
    + + +
    +
    + <% end %> +
    diff --git a/app/views/quality_analysis/edit.js.erb b/app/views/quality_analysis/edit.js.erb new file mode 100644 index 000000000..e69de29bb From db1ad932c61409bdc2327bbb4a60c86cec457784 Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 1 Jul 2016 09:31:05 +0800 Subject: [PATCH 03/18] Function : update jenkins job --- .../quality_analysis_controller.rb | 62 ++- app/views/quality_analysis/_edit.html.erb | 8 +- .../quality_analysis/_result_list.html.erb | 19 +- app/views/quality_analysis/edit.js.erb | 8 + config/routes.rb | 3 +- db/schema.rb | 402 +----------------- 6 files changed, 86 insertions(+), 416 deletions(-) diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 15fdcef61..1f5695605 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -1,7 +1,8 @@ class QualityAnalysisController < ApplicationController before_filter :find_project_by_project_id#, :except => [:getattachtype] + before_filter :find_quality_analysis, :only => [:edit, :update_jenkins_job] before_filter :authorize - before_filter :connect_jenkins, :only => [:create] + before_filter :connect_jenkins, :only => [:create, :edit, :update_jenkins_job] layout "base_projects" include ApplicationHelper require 'jenkins_api_client' @@ -54,7 +55,7 @@ class QualityAnalysisController < ApplicationController # return '201' if build successed code = @client.job.build("#{job_name}") logger.error("build result ==> #{code}") - d = @client.delete("#{job_name}") if jenkins_job == '200' && code != '201' + d = @client.job.delete("#{job_name}") if jenkins_job == '200' && code != '201' logger.error("delete result ==> #{code}") if qa.blank? && code == '201' QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier, @@ -86,11 +87,54 @@ class QualityAnalysisController < ApplicationController end def edit - @quality_analysis = QualityAnalysis.where(:id => params[:id]) + @g = Gitlab.client + gitlab_branches = @g.branches(@project.gpid) + @branch_names = gitlab_branches.map{|b| b.name} + @gitlab_default_branch = @g.project(@project.gpid).default_branch end - def update - @quality_analysis = QualityAnalysis.where(:id => params[:id]) + def update_jenkins_job + begin + rep_id = Repository.where(:project_id => @project.id).first.try(:id) + logger.error("#############################===>666") + sonar_name = @quality_analysis.sonar_name + job_name = "#{@quality_analysis.author_login}-#{rep_id}" + version = @quality_analysis.sonar_version + path = params[:path].blank? ? "./" : params[:path] + language = swith_language_type(params[:language]) + branch = params[:branch] + identifier = @quality_analysis.rep_identifier + properties = "sonar.projectKey=#{sonar_name} + sonar.projectName=#{sonar_name} + sonar.projectVersion=#{version} + sonar.sources=#{path} + sonar.language=#{language.downcase} + sonar.sourceEncoding=utf-8" + git_url = @gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier + "."+"git" + + # modify config.yml + @doc = Nokogiri::XML(File.open(File.join(Rails.root, 'tmp', 'config.xml'))) + @doc.at_xpath("//hudson.plugins.git.UserRemoteConfig/url").content = git_url + @doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}" + @doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties + + # return '200' if successed + jenkins_job = @client.job.update("#{job_name}", @doc.to_xml) + logger.error("Failed to update job: ==> #{jenkins_job}") unless jenkins_job == '200' + if jenkins_job == '200' + logger.info("quality_ananlysis will be updated: ==> #{jenkins_job}") + @quality_analysis.path = path + @quality_analysis.language = language + @quality_analysis.branch = branch + @quality_analysis.save + end + rescue Exception => e + logger.error("Update jenkins job: #{e}") + end + respond_to do |format| + format.html{redirect_to project_quality_analysis_path(:project_id => @project.id)} + format.js + end end # resource_id: login + @repository.id @@ -123,6 +167,14 @@ class QualityAnalysisController < ApplicationController render_404 end + def find_quality_analysis + begin + @quality_analysis = QualityAnalysis.find(params[:id]) + rescue + render_404 + end + end + # Authorize the user for the requested action def authorize(ctrl = params[:controller], action = params[:action], global = false) unless @project.archived? && @project.gpid.nil? diff --git a/app/views/quality_analysis/_edit.html.erb b/app/views/quality_analysis/_edit.html.erb index d5cd49d0c..f508ee5de 100644 --- a/app/views/quality_analysis/_edit.html.erb +++ b/app/views/quality_analysis/_edit.html.erb @@ -1,21 +1,21 @@
    代码质量分析
    - <%= form_tag( url_for(:controller => 'quality_analysis', :action => 'create', :project_id => @project.id, :user_id => User.current.id, :identifier => @repository.identifier, :rep_id => @repository.id), :remote => true, :id => 'quality_analyses_form') do %> + <%= form_tag( url_for(:controller => 'quality_analysis', :action => 'update_jenkins_job', :project_id => @project.id), :id => 'quality_analyses_edit_form') do %>
    - <%= select_tag :branch, options_for_select(["#{@gitlab_default_branch}"]+ @branch_names, @rev), :id => 'branch', :class => "analysis-option-box" %> + <%= select_tag :branch, options_for_select(["#{@gitlab_default_branch}"]+ @branch_names, @quality_analysis.branch), :value => 77, :id => 'branch', :class => "analysis-option-box" %>
    - <%= select_tag :language, options_for_select(["java","python","ruby","c++","c#","c"]), :id => 'branch', :class => "analysis-option-box" %> + <%= select_tag :language, options_for_select(["java","python","ruby","c++","c#","c"], "#{@quality_analysis.language}"), :id => 'branch', :class => "analysis-option-box" %>
    - +
    diff --git a/app/views/quality_analysis/_result_list.html.erb b/app/views/quality_analysis/_result_list.html.erb index b4a40de0d..c47d51f1f 100644 --- a/app/views/quality_analysis/_result_list.html.erb +++ b/app/views/quality_analysis/_result_list.html.erb @@ -3,22 +3,21 @@
    • 名称
    • -
    • 版本
    • -
    • 分支
    • -
    • 语言
    • -
    • 路径
    • -
    • bianji
    • +
    • 分支
    • +
    • 语言
    • +
    • 路径
    • +
    • 编辑
    • +
    <% if @quality_analyses.count >0 %> <% @quality_analyses.each do |qa| %>
    • <%=link_to "#{qa.author_login}:#{qa.rep_identifier}", project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2" %>
    • -
    • 1.0
    • -
    • <%= qa.branch %>
    • -
    • <%= qa.language %>
    • -
    • <%= qa.path %>
    • -
    • <%=link_to "bianji", edit_project__quality_analysis_path(@quality_analysis) %>
    • +
    • <%= qa.branch %>
    • +
    • <%= qa.language %>
    • +
    • <%= qa.path %>
    • +
    • <%=link_to "编辑", edit_project_quality_analysi_path(qa, :project_id => @project.id), :remote => true %>
    <% end %> diff --git a/app/views/quality_analysis/edit.js.erb b/app/views/quality_analysis/edit.js.erb index e69de29bb..4277ae28e 100644 --- a/app/views/quality_analysis/edit.js.erb +++ b/app/views/quality_analysis/edit.js.erb @@ -0,0 +1,8 @@ +$('#ajax-modal').html('<%= escape_javascript( render :partial => 'quality_analysis/edit', :locals => {}) %>'); +showModal('ajax-modal', '615px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","20%").css("left","32%").css("border","3px solid #269ac9"); +$('#ajax-modal').parent().addClass("popbox_polls"); + + diff --git a/config/routes.rb b/config/routes.rb index 5404e4ecf..075aff6e1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -790,7 +790,8 @@ RedmineApp::Application.routes.draw do collection do end member do - + match 'update_jenkins_job' + match 'edit' end end # resources :files, :only => [:index, :new, :create] do diff --git a/db/schema.rb b/db/schema.rb index 16f39f6a1..3258f89c1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -52,28 +52,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" - create_table "application_settings", :force => true do |t| - t.integer "default_projects_limit" - t.boolean "signup_enabled" - t.boolean "signin_enabled" - t.boolean "gravatar_enabled" - t.text "sign_in_text" - t.datetime "created_at" - t.datetime "updated_at" - t.string "home_page_url" - t.integer "default_branch_protection", :default => 2 - t.boolean "twitter_sharing_enabled", :default => true - t.text "restricted_visibility_levels" - t.boolean "version_check_enabled", :default => true - t.integer "max_attachment_size", :default => 10, :null => false - t.integer "default_project_visibility" - t.integer "default_snippet_visibility" - t.text "restricted_signup_domains" - t.boolean "user_oauth_applications", :default => true - t.string "after_sign_out_path" - t.integer "session_expire_delay", :default => 10080, :null => false - end - create_table "applied_projects", :force => true do |t| t.integer "project_id", :null => false t.integer "user_id", :null => false @@ -178,20 +156,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.string "typeName", :limit => 50 end - create_table "audit_events", :force => true do |t| - t.integer "author_id", :null => false - t.string "type", :null => false - t.integer "entity_id", :null => false - t.string "entity_type", :null => false - t.text "details" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "audit_events", ["author_id"], :name => "index_audit_events_on_author_id" - add_index "audit_events", ["entity_id", "entity_type"], :name => "index_audit_events_on_entity_id_and_entity_type" - add_index "audit_events", ["type"], :name => "index_audit_events_on_type" - create_table "auth_sources", :force => true do |t| t.string "type", :limit => 30, :default => "", :null => false t.string "name", :limit => 60, :default => "", :null => false @@ -289,17 +253,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" add_index "boards", ["project_id"], :name => "boards_project_id" - create_table "broadcast_messages", :force => true do |t| - t.text "message", :null => false - t.datetime "starts_at" - t.datetime "ends_at" - t.integer "alert_type" - t.datetime "created_at" - t.datetime "updated_at" - t.string "color" - t.string "font" - end - create_table "bug_to_osps", :force => true do |t| t.integer "osp_id" t.integer "relative_memo_id" @@ -598,8 +551,11 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.integer "is_copy", :default => 0 t.integer "visits", :default => 0 t.integer "syllabus_id" + t.string "invite_code" + t.string "qrcode" end + add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true add_index "courses", ["syllabus_id"], :name => "index_courses_on_syllabus_id" create_table "custom_fields", :force => true do |t| @@ -663,15 +619,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - create_table "deploy_keys_projects", :force => true do |t| - t.integer "deploy_key_id", :null => false - t.integer "project_id", :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "deploy_keys_projects", ["project_id"], :name => "index_deploy_keys_projects_on_project_id" - create_table "discuss_demos", :force => true do |t| t.string "title" t.text "body" @@ -721,16 +668,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.datetime "created_at" end - create_table "emails", :force => true do |t| - t.integer "user_id", :null => false - t.string "email", :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "emails", ["email"], :name => "index_emails_on_email", :unique => true - add_index "emails", ["user_id"], :name => "index_emails_on_user_id" - create_table "enabled_modules", :force => true do |t| t.integer "project_id" t.string "name", :null => false @@ -753,25 +690,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" - create_table "events", :force => true do |t| - t.string "target_type" - t.integer "target_id" - t.string "title" - t.text "data" - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "action" - t.integer "author_id" - end - - add_index "events", ["action"], :name => "index_events_on_action" - add_index "events", ["author_id"], :name => "index_events_on_author_id" - add_index "events", ["created_at"], :name => "index_events_on_created_at" - add_index "events", ["project_id"], :name => "index_events_on_project_id" - add_index "events", ["target_id"], :name => "index_events_on_target_id" - add_index "events", ["target_type"], :name => "index_events_on_target_type" - create_table "exercise_answers", :force => true do |t| t.integer "user_id" t.integer "exercise_question_id" @@ -874,15 +792,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do add_index "forge_messages", ["forge_message_id", "forge_message_type"], :name => "index_forge_messages_on_forge_message_id_and_forge_message_type" add_index "forge_messages", ["user_id", "project_id", "created_at"], :name => "index_forge_messages_on_user_id_and_project_id_and_created_at" - create_table "forked_project_links", :force => true do |t| - t.integer "forked_to_project_id", :null => false - t.integer "forked_from_project_id", :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "forked_project_links", ["forked_to_project_id"], :name => "index_forked_project_links_on_forked_to_project_id", :unique => true - create_table "forums", :force => true do |t| t.string "name", :null => false t.text "description" @@ -1012,17 +921,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.datetime "updated_at", :null => false end - create_table "identities", :force => true do |t| - t.string "extern_uid" - t.string "provider" - t.integer "user_id" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "identities", ["created_at", "id"], :name => "index_identities_on_created_at_and_id" - add_index "identities", ["user_id"], :name => "index_identities_on_user_id" - create_table "invite_lists", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -1166,20 +1064,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.integer "private", :default => 0 end - create_table "keys", :force => true do |t| - t.integer "user_id" - t.datetime "created_at" - t.datetime "updated_at" - t.text "key" - t.string "title" - t.string "type" - t.string "fingerprint" - t.boolean "public", :default => false, :null => false - end - - add_index "keys", ["created_at", "id"], :name => "index_keys_on_created_at_and_id" - add_index "keys", ["user_id"], :name => "index_keys_on_user_id" - create_table "kindeditor_assets", :force => true do |t| t.string "asset" t.integer "file_size" @@ -1191,27 +1075,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.integer "owner_type", :default => 0 end - create_table "label_links", :force => true do |t| - t.integer "label_id" - t.integer "target_id" - t.string "target_type" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "label_links", ["label_id"], :name => "index_label_links_on_label_id" - add_index "label_links", ["target_id", "target_type"], :name => "index_label_links_on_target_id_and_target_type" - - create_table "labels", :force => true do |t| - t.string "title" - t.string "color" - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "labels", ["project_id"], :name => "index_labels_on_project_id" - create_table "member_roles", :force => true do |t| t.integer "member_id", :null => false t.integer "role_id", :null => false @@ -1262,47 +1125,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.integer "viewed_count", :default => 0 end - create_table "merge_request_diffs", :force => true do |t| - t.string "state" - t.text "st_commits", :limit => 2147483647 - t.text "st_diffs", :limit => 2147483647 - t.integer "merge_request_id", :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "merge_request_diffs", ["merge_request_id"], :name => "index_merge_request_diffs_on_merge_request_id", :unique => true - - create_table "merge_requests", :force => true do |t| - t.string "target_branch", :null => false - t.string "source_branch", :null => false - t.integer "source_project_id", :null => false - t.integer "author_id" - t.integer "assignee_id" - t.string "title" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "milestone_id" - t.string "state" - t.string "merge_status" - t.integer "target_project_id", :null => false - t.integer "iid" - t.text "description" - t.integer "position", :default => 0 - t.datetime "locked_at" - end - - add_index "merge_requests", ["assignee_id"], :name => "index_merge_requests_on_assignee_id" - add_index "merge_requests", ["author_id"], :name => "index_merge_requests_on_author_id" - add_index "merge_requests", ["created_at", "id"], :name => "index_merge_requests_on_created_at_and_id" - add_index "merge_requests", ["created_at"], :name => "index_merge_requests_on_created_at" - add_index "merge_requests", ["milestone_id"], :name => "index_merge_requests_on_milestone_id" - add_index "merge_requests", ["source_branch"], :name => "index_merge_requests_on_source_branch" - add_index "merge_requests", ["source_project_id"], :name => "index_merge_requests_on_source_project_id" - add_index "merge_requests", ["target_branch"], :name => "index_merge_requests_on_target_branch" - add_index "merge_requests", ["target_project_id", "iid"], :name => "index_merge_requests_on_target_project_id_and_iid", :unique => true - add_index "merge_requests", ["title"], :name => "index_merge_requests_on_title" - create_table "message_alls", :force => true do |t| t.integer "user_id" t.integer "message_id" @@ -1337,39 +1159,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" add_index "messages", ["parent_id"], :name => "messages_parent_id" - create_table "milestones", :force => true do |t| - t.string "title", :null => false - t.integer "project_id", :null => false - t.text "description" - t.date "due_date" - t.datetime "created_at" - t.datetime "updated_at" - t.string "state" - t.integer "iid" - end - - add_index "milestones", ["created_at", "id"], :name => "index_milestones_on_created_at_and_id" - add_index "milestones", ["due_date"], :name => "index_milestones_on_due_date" - add_index "milestones", ["project_id", "iid"], :name => "index_milestones_on_project_id_and_iid", :unique => true - add_index "milestones", ["project_id"], :name => "index_milestones_on_project_id" - - create_table "namespaces", :force => true do |t| - t.string "name", :null => false - t.string "path", :null => false - t.integer "owner_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "type" - t.string "description", :default => "", :null => false - t.string "avatar" - end - - add_index "namespaces", ["created_at", "id"], :name => "index_namespaces_on_created_at_and_id" - add_index "namespaces", ["name"], :name => "index_namespaces_on_name", :unique => true - add_index "namespaces", ["owner_id"], :name => "index_namespaces_on_owner_id" - add_index "namespaces", ["path"], :name => "index_namespaces_on_path", :unique => true - add_index "namespaces", ["type"], :name => "index_namespaces_on_type" - create_table "news", :force => true do |t| t.integer "project_id" t.string "title", :limit => 60, :default => "", :null => false @@ -1395,31 +1184,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.datetime "updated_at", :null => false end - create_table "notes", :force => true do |t| - t.text "note" - t.string "noteable_type" - t.integer "author_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "project_id" - t.string "attachment" - t.string "line_code" - t.string "commit_id" - t.integer "noteable_id" - t.boolean "system", :default => false, :null => false - t.text "st_diff", :limit => 2147483647 - end - - add_index "notes", ["author_id"], :name => "index_notes_on_author_id" - add_index "notes", ["commit_id"], :name => "index_notes_on_commit_id" - add_index "notes", ["created_at", "id"], :name => "index_notes_on_created_at_and_id" - add_index "notes", ["created_at"], :name => "index_notes_on_created_at" - add_index "notes", ["noteable_id", "noteable_type"], :name => "index_notes_on_noteable_id_and_noteable_type" - add_index "notes", ["noteable_type"], :name => "index_notes_on_noteable_type" - add_index "notes", ["project_id", "noteable_type"], :name => "index_notes_on_project_id_and_noteable_type" - add_index "notes", ["project_id"], :name => "index_notes_on_project_id" - add_index "notes", ["updated_at"], :name => "index_notes_on_updated_at" - create_table "notificationcomments", :force => true do |t| t.string "notificationcommented_type" t.integer "notificationcommented_id" @@ -1429,49 +1193,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.datetime "updated_at", :null => false end - create_table "oauth_access_grants", :force => true do |t| - t.integer "resource_owner_id", :null => false - t.integer "application_id", :null => false - t.string "token", :null => false - t.integer "expires_in", :null => false - t.text "redirect_uri", :null => false - t.datetime "created_at", :null => false - t.datetime "revoked_at" - t.string "scopes" - end - - add_index "oauth_access_grants", ["token"], :name => "index_oauth_access_grants_on_token", :unique => true - - create_table "oauth_access_tokens", :force => true do |t| - t.integer "resource_owner_id" - t.integer "application_id" - t.string "token", :null => false - t.string "refresh_token" - t.integer "expires_in" - t.datetime "revoked_at" - t.datetime "created_at", :null => false - t.string "scopes" - end - - add_index "oauth_access_tokens", ["refresh_token"], :name => "index_oauth_access_tokens_on_refresh_token", :unique => true - add_index "oauth_access_tokens", ["resource_owner_id"], :name => "index_oauth_access_tokens_on_resource_owner_id" - add_index "oauth_access_tokens", ["token"], :name => "index_oauth_access_tokens_on_token", :unique => true - - create_table "oauth_applications", :force => true do |t| - t.string "name", :null => false - t.string "uid", :null => false - t.string "secret", :null => false - t.text "redirect_uri", :null => false - t.string "scopes", :default => "", :null => false - t.datetime "created_at" - t.datetime "updated_at" - t.integer "owner_id" - t.string "owner_type" - end - - add_index "oauth_applications", ["owner_id", "owner_type"], :name => "index_oauth_applications_on_owner_id_and_owner_type" - add_index "oauth_applications", ["uid"], :name => "index_oauth_applications_on_uid", :unique => true - create_table "onclick_times", :force => true do |t| t.integer "user_id" t.datetime "onclick_time" @@ -1629,23 +1350,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.integer "allow_teacher", :default => 0 end - create_table "permissions", :force => true do |t| - t.string "controller", :limit => 30, :default => "", :null => false - t.string "action", :limit => 30, :default => "", :null => false - t.string "description", :limit => 60, :default => "", :null => false - t.boolean "is_public", :default => false, :null => false - t.integer "sort", :default => 0, :null => false - t.boolean "mail_option", :default => false, :null => false - t.boolean "mail_enabled", :default => false, :null => false - end - - create_table "permissions_roles", :id => false, :force => true do |t| - t.integer "permission_id", :default => 0, :null => false - t.integer "role_id", :default => 0, :null => false - end - - add_index "permissions_roles", ["role_id"], :name => "permissions_roles_role_id" - create_table "phone_app_versions", :force => true do |t| t.string "version" t.text "description" @@ -1728,11 +1432,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.datetime "updated_at", :null => false end - create_table "project_import_data", :force => true do |t| - t.integer "project_id" - t.text "data" - end - create_table "project_infos", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -1823,24 +1522,13 @@ ActiveRecord::Schema.define(:version => 20160627090316) do add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" - create_table "protected_branches", :force => true do |t| - t.integer "project_id", :null => false - t.string "name", :null => false - t.datetime "created_at" - t.datetime "updated_at" - t.boolean "developers_can_push", :default => false, :null => false - end - - add_index "protected_branches", ["project_id"], :name => "index_protected_branches_on_project_id" - create_table "quality_analyses", :force => true do |t| t.integer "project_id" t.string "author_login" t.string "rep_identifier" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "version", :default => 0.0 - t.integer "sonar_version", :default => 1 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sonar_version", :default => 0 t.string "path" t.string "branch" t.string "language" @@ -1981,25 +1669,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.integer "is_teacher_score", :default => 0 end - create_table "services", :force => true do |t| - t.string "type" - t.string "title" - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.boolean "active", :default => false, :null => false - t.text "properties" - t.boolean "template", :default => false - t.boolean "push_events", :default => true - t.boolean "issues_events", :default => true - t.boolean "merge_requests_events", :default => true - t.boolean "tag_push_events", :default => true - t.boolean "note_events", :default => true, :null => false - end - - add_index "services", ["created_at", "id"], :name => "index_services_on_created_at_and_id" - add_index "services", ["project_id"], :name => "index_services_on_project_id" - create_table "settings", :force => true do |t| t.string "name", :default => "", :null => false t.text "value" @@ -2038,26 +1707,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.datetime "updated_at", :null => false end - create_table "snippets", :force => true do |t| - t.string "title" - t.text "content", :limit => 2147483647 - t.integer "author_id", :null => false - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "file_name" - t.datetime "expires_at" - t.string "type" - t.integer "visibility_level", :default => 0, :null => false - end - - add_index "snippets", ["author_id"], :name => "index_snippets_on_author_id" - add_index "snippets", ["created_at", "id"], :name => "index_snippets_on_created_at_and_id" - add_index "snippets", ["created_at"], :name => "index_snippets_on_created_at" - add_index "snippets", ["expires_at"], :name => "index_snippets_on_expires_at" - add_index "snippets", ["project_id"], :name => "index_snippets_on_project_id" - add_index "snippets", ["visibility_level"], :name => "index_snippets_on_visibility_level" - create_table "softapplications", :force => true do |t| t.string "name" t.text "description" @@ -2196,17 +1845,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.datetime "updated_at", :null => false end - create_table "subscriptions", :force => true do |t| - t.integer "user_id" - t.integer "subscribable_id" - t.string "subscribable_type" - t.boolean "subscribed" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "subscriptions", ["subscribable_id", "subscribable_type", "user_id"], :name => "subscriptions_user_id_and_ref_fields", :unique => true - create_table "syllabuses", :force => true do |t| t.string "title" t.text "description" @@ -2457,17 +2095,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" add_index "users", ["type"], :name => "index_users_on_type" - create_table "users_star_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "users_star_projects", ["project_id"], :name => "index_users_star_projects_on_project_id" - add_index "users_star_projects", ["user_id", "project_id"], :name => "index_users_star_projects_on_user_id_and_project_id", :unique => true - add_index "users_star_projects", ["user_id"], :name => "index_users_star_projects_on_user_id" - create_table "versions", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.string "name", :default => "", :null => false @@ -2519,23 +2146,6 @@ ActiveRecord::Schema.define(:version => 20160627090316) do t.datetime "updated_at", :null => false end - create_table "web_hooks", :force => true do |t| - t.string "url" - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "type", :default => "ProjectHook" - t.integer "service_id" - t.boolean "push_events", :default => true, :null => false - t.boolean "issues_events", :default => false, :null => false - t.boolean "merge_requests_events", :default => false, :null => false - t.boolean "tag_push_events", :default => false - t.boolean "note_events", :default => false, :null => false - end - - add_index "web_hooks", ["created_at", "id"], :name => "index_web_hooks_on_created_at_and_id" - add_index "web_hooks", ["project_id"], :name => "index_web_hooks_on_project_id" - create_table "wechat_logs", :force => true do |t| t.string "openid", :null => false t.text "request_raw" From 1fbb65b9064297e9a4ce0ea4170262f23f47c30f Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 1 Jul 2016 14:39:40 +0800 Subject: [PATCH 04/18] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=BB=93=E6=9E=9Cajax?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../quality_analysis_controller.rb | 49 ++++++++++++++----- .../quality_analysis/_result_list.html.erb | 4 ++ app/views/quality_analysis/_show.html.erb | 2 +- app/views/quality_analysis/create.js.erb | 11 +++++ app/views/quality_analysis/index.html.erb | 6 ++- .../repositories/_quality_analysis.html.erb | 4 +- app/views/repositories/show.html.erb | 4 +- 7 files changed, 62 insertions(+), 18 deletions(-) create mode 100644 app/views/quality_analysis/create.js.erb diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 1f5695605..75499c985 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -5,6 +5,7 @@ class QualityAnalysisController < ApplicationController before_filter :connect_jenkins, :only => [:create, :edit, :update_jenkins_job] layout "base_projects" include ApplicationHelper + include QualityAnalysisHelper require 'jenkins_api_client' require 'nokogiri' require 'json' @@ -14,12 +15,14 @@ class QualityAnalysisController < ApplicationController end + # params 说明:{identifier:版本库名} def create begin user_name = User.find(params[:user_id]).try(:login) identifier = params[:identifier] rep_id = params[:rep_id] - # REDO + + # job_name and sonar_name 前者为job名字,后者为jenkins配置名 job_name = "#{user_name}-#{rep_id}" sonar_name = "#{user_name}:#{rep_id}" @@ -39,22 +42,40 @@ class QualityAnalysisController < ApplicationController sonar.sourceEncoding=utf-8" git_url = @gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier + "."+"git" - # modify config.yml + # 替换配置文件 @doc = Nokogiri::XML(File.open(File.join(Rails.root, 'tmp', 'config.xml'))) @doc.at_xpath("//hudson.plugins.git.UserRemoteConfig/url").content = git_url @doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}" @doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties - # return '200' if successed + # jenkins job创建 jenkins_job = @client.job.create("#{job_name}", @doc.to_xml) + logger.info("Jenkins status of create ==> #{jenkins_job}") - # replace gitlab hook + # 将地址作为hook值添加到gitlab @g.add_project_hook(@project.gpid, @jenkins_address + "/project/#{job_name}") - # build job - logger.error("Jenkins status of create ==> #{jenkins_job}") - # return '201' if build successed + # job创建完成后自动运行job,如果运行成功则返回‘200’ code = @client.job.build("#{job_name}") logger.error("build result ==> #{code}") + + # 判断调用sonar分析是否成功 + # 等待启动时间处理, 最长时间为30分钟 + for i in 0..60 do + sleep(60) + @current_build_status = @client.job.get_current_build_status("#{job_name}") + if (@current_build_status != "not_run" || @current_build_status != "running") + break + if i == 60 + @build_console_result = false + break + end + end + end + + @console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text') + logger.info("@current_build_status is ==> #{@current_build_status}") + logger.info("@console_build is ==> #{@console_build}") + d = @client.job.delete("#{job_name}") if jenkins_job == '200' && code != '201' logger.error("delete result ==> #{code}") if qa.blank? && code == '201' @@ -67,10 +88,10 @@ class QualityAnalysisController < ApplicationController rescue => e puts e end - # respond_to do |format| - # #format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch)} - # format.js - # end + respond_to do |format| + format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch)} + # format.js{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch)} + end end # get language type @@ -93,6 +114,7 @@ class QualityAnalysisController < ApplicationController @gitlab_default_branch = @g.project(@project.gpid).default_branch end + # 更新Jenkins job,主要包括相关配置文件参数的更新,Trustie平台数据的更新 def update_jenkins_job begin rep_id = Repository.where(:project_id => @project.id).first.try(:id) @@ -118,9 +140,12 @@ class QualityAnalysisController < ApplicationController @doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}" @doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties - # return '200' if successed + # update成功则返回 ‘200’ jenkins_job = @client.job.update("#{job_name}", @doc.to_xml) + get_current_build_status = @client.job.get_current_build_status("Hjqreturn-1280") logger.error("Failed to update job: ==> #{jenkins_job}") unless jenkins_job == '200' + + # 数据更新到Trustie数据库 if jenkins_job == '200' logger.info("quality_ananlysis will be updated: ==> #{jenkins_job}") @quality_analysis.path = path diff --git a/app/views/quality_analysis/_result_list.html.erb b/app/views/quality_analysis/_result_list.html.erb index c47d51f1f..51d91c04f 100644 --- a/app/views/quality_analysis/_result_list.html.erb +++ b/app/views/quality_analysis/_result_list.html.erb @@ -1,3 +1,7 @@ +

    分析结果

    diff --git a/app/views/quality_analysis/_show.html.erb b/app/views/quality_analysis/_show.html.erb index e55e65bcd..ca8ee225f 100644 --- a/app/views/quality_analysis/_show.html.erb +++ b/app/views/quality_analysis/_show.html.erb @@ -9,7 +9,7 @@ <% if @complexity["msr"].count > 3 %> <%= render :partial => "hightchars" %>
    -
    +

    质量等级

    diff --git a/app/views/quality_analysis/create.js.erb b/app/views/quality_analysis/create.js.erb new file mode 100644 index 000000000..abe8c4a6e --- /dev/null +++ b/app/views/quality_analysis/create.js.erb @@ -0,0 +1,11 @@ +$("#ajax-indicator").hide(); +<% if @current_build_status == "success" %> + <%= escape_javascript( render :partial => 'quality_analysis/show', :locals => {:branch => branch}) %> +<% elsif @current_build_status == "failure" %> + <%=h @console_build.html_safe %> +<% elsif @current_build_status == "not_run" %> + alert('任务启动失败'); +<% else %> + alert('你已经创建类一个同名job'); +<% end %> + diff --git a/app/views/quality_analysis/index.html.erb b/app/views/quality_analysis/index.html.erb index 9b06e6483..ead8aae48 100644 --- a/app/views/quality_analysis/index.html.erb +++ b/app/views/quality_analysis/index.html.erb @@ -1,6 +1,10 @@ <% if @name_flag %> <%= render :partial => "result_list" %> <% else %> - <%= render "show" %> + <% if @build_console_result %> + 运行结果超时 + <% else %> + <%= render :partial => "show", :locals => {:branch => params[:branch]} %> + <% end %> <% end %> diff --git a/app/views/repositories/_quality_analysis.html.erb b/app/views/repositories/_quality_analysis.html.erb index d583f54c6..0053849a3 100644 --- a/app/views/repositories/_quality_analysis.html.erb +++ b/app/views/repositories/_quality_analysis.html.erb @@ -1,6 +1,6 @@
    代码质量分析
    - <%= form_tag( url_for(:controller => 'quality_analysis', :action => 'create', :project_id => @project.id, :user_id => User.current.id, :identifier => @repository.identifier, :rep_id => @repository.id), :remote => true, :id => 'quality_analyses_form') do %> + <%= form_tag( url_for(:controller => 'quality_analysis', :action => 'create', :project_id => @project.id, :user_id => User.current.id, :identifier => @repository.identifier, :rep_id => @repository.id), :id => 'quality_analyses_form') do %>
    @@ -15,7 +15,7 @@ <%= select_tag :language, options_for_select(["java","python","ruby","c++","c#","c"]), :id => 'branch', :class => "analysis-option-box" %>
    - +
    diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 067056983..0a9b49470 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -5,9 +5,9 @@ ZIP下载 <%# if is_project_manager?(User.current, @project.id) && QualityAnalysis.where(:project_id => @project.id).first.nil? %> <%# if User.current.member_of?(@project) %> - <% if quality_analysis(User.current.try(:login), @repository.id).nil? && is_project_manager?(User.current.id, @project.id) %> + <%# if quality_analysis(User.current.try(:login), @repository.id).nil? && is_project_manager?(User.current.id, @project.id) %> <%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch ), :remote => true, :class => "btn_zipdown fr" %> - <% end %> + <%# end %> <%# end %> <%# else %> <%#= link_to "质量分析", project_quality_analysis_path(:project_id => @project.id, :resource_id => @proje), :class => "btn_zipdown fr" %> From 21be94cbe14684327e98f932d6163710cf32b6b6 Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 1 Jul 2016 15:05:01 +0800 Subject: [PATCH 05/18] add some links --- app/views/quality_analysis/_show.html.erb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/views/quality_analysis/_show.html.erb b/app/views/quality_analysis/_show.html.erb index ca8ee225f..1a7869fd0 100644 --- a/app/views/quality_analysis/_show.html.erb +++ b/app/views/quality_analysis/_show.html.erb @@ -43,25 +43,26 @@
    质量等级<%=@complexity["msr"][9].nil? ? 0 : score_sqale_rating(@complexity["msr"][9]["val"].to_i) %>/5分 可定性评价为:质量<%=@complexity["msr"][9].nil? ? "很好" : sqale_rating_status(@complexity["msr"][9]["val"])[0] %>
    -
    技术债务<%=@complexity["msr"][8].nil? ? 0 : @complexity["msr"][8]["frmt_val"] %> - 查看详情
    +
    技术债务<%=@complexity["msr"][8].nil? ? 0 : @complexity["msr"][8]["frmt_val"] %> + 查看详情
    + <%=@sonar_issues["msr"][0].nil? ? 0 : @sonar_issues["msr"][0]["frmt_val"] %> 问题分类如下:
    阻断 - <%= @sonar_issues["msr"][1].nil? ? 0 : @sonar_issues["msr"][1]["frmt_val"] %> + <%= @sonar_issues["msr"][1].nil? ? 0 : @sonar_issues["msr"][1]["frmt_val"] %> %;">
    严重 - <%= @sonar_issues["msr"][2].nil? ? 0 : @sonar_issues["msr"][2]["frmt_val"] %> + <%= @sonar_issues["msr"][2].nil? ? 0 : @sonar_issues["msr"][2]["frmt_val"] %> %;">
    主要 - <%= @sonar_issues["msr"][3].nil? ? 0 : @sonar_issues["msr"][3]["frmt_val"] %> + <%= @sonar_issues["msr"][3].nil? ? 0 : @sonar_issues["msr"][3]["frmt_val"] %> %;">
    次要 - <%=@sonar_issues["msr"][4].nil? ? 0 : @sonar_issues["msr"][4]["frmt_val"] %> + <%=@sonar_issues["msr"][4].nil? ? 0 : @sonar_issues["msr"][4]["frmt_val"] %> %;">
    信息 - <%=@sonar_issues["msr"][5].nil? ? 0 : @sonar_issues["msr"][5]["frmt_val"] %>%;">
    + <%=@sonar_issues["msr"][5].nil? ? 0 : @sonar_issues["msr"][5]["frmt_val"] %> + %;">
    代码规模可定性评价为:<%=@complexity["msr"][0].nil? ? 0 : lines_scale(@complexity["msr"][0]["frmt_val"].to_i) %>
    From 7178c50b1d0207ce286769874a1c24dd9fab9ee1 Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 1 Jul 2016 15:37:39 +0800 Subject: [PATCH 06/18] branch's total commits --- app/controllers/repositories_controller.rb | 7 +------ app/helpers/application_helper.rb | 18 +++++++++--------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 7c3acb2cc..d0904ddf5 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -360,11 +360,6 @@ update end def show - # sonar_address = Redmine::Configuration['sonar_address'] - # projects_date = open(sonar_address + "/api/projects/index").read - # arr = JSON.parse(projects_date).map {|m| m["nm"]} - # arr.map - ## TODO: the below will move to filter, done. if !User.current.member_of?(@project) && @project.hidden_repo render_403 @@ -379,7 +374,7 @@ update @changesets = g.commits(@project.gpid, :ref_name => @rev) g_project = g.project(@project.gpid) # 总的提交数 - @changesets_all_count = @project.gpid.nil? ? 0 : g_project.commit_count + @changesets_all_count = @project.gpid.nil? ? 0 : commit_count(@project, @rev) @g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch # 访问该页面的是会后则刷新 if @project.project_score.nil? diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ee2e2d74a..1d1322d98 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -803,22 +803,22 @@ module ApplicationHelper end # 获取Gitlab版本库提交总数 - def commit_count(project) + def commit_count(project, branch) g = Gitlab.client #add by hx - if g.commits(project.gpid , :page=>200).count > 0 + if g.commits(project.gpid, :ref_name => @rev , :page=>200).count > 0 count = 4020 - elsif g.commits(project.gpid , :page=>25).count==0 + elsif g.commits(project.gpid , :page=>25, :ref_name => branch).count==0 count = count_commits(project.gpid , 0 , 25) - elsif g.commits(project.gpid , :page=>50).count ==0 + elsif g.commits(project.gpid , :page=>50, :ref_name => branch).count ==0 count = count_commits(project.gpid , 25 , 50)+ 25 * 20 - elsif g.commits(project.gpid , :page=>75).count ==0 + elsif g.commits(project.gpid , :page=>75, :ref_name => branch).count ==0 count = count_commits(project.gpid , 50 , 75)+ 50 * 20 - elsif g.commits(project.gpid , :page=>100).count== 0 + elsif g.commits(project.gpid , :page=>100, :ref_name => branch).count== 0 count = count_commits(project.gpid , 75 , 100) + 75 * 20 - elsif g.commits(project.gpid , :page=>125).count==0 + elsif g.commits(project.gpid , :page=>125, :ref_name => branch).count==0 count = count_commits(project.gpid , 100 , 125) + 100 * 20 - elsif g.commits(project.gpid , :page=>150).count==0 + elsif g.commits(project.gpid , :page=>150, :ref_name => branch).count==0 count = count_commits(project.gpid , 125 , 150) + 125 * 20 else count = count_commits(project.gpid , 150 ,200) + 150 * 20 @@ -832,7 +832,7 @@ module ApplicationHelper if $g.commits(project_id,:page => page).count == 0 break else - count = count + $g.commits(project_id,:page => page).count + count = count + $g.commits(project_id, :ref_name => @rev, :page => page).count end end return count From 8db5852a61b05c1bc90fb2fccf5a79e23b7db0f1 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 1 Jul 2016 15:49:25 +0800 Subject: [PATCH 07/18] =?UTF-8?q?=E6=BF=80=E6=B4=BB=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA=E9=82=AE=E7=AE=B1=EF=BC=8C?= =?UTF-8?q?=E6=BF=80=E6=B4=BB=E9=82=AE=E7=AE=B1=E7=95=8C=E9=9D=A2=E7=95=99?= =?UTF-8?q?=E8=A8=80=E5=A4=AA=E9=95=BF=E4=B8=8D=E8=83=BD=E7=95=99=E8=A8=80?= =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 7 ++-- app/views/account/email_activation.html.erb | 34 +++++++++++-------- .../projects/invite_members_by_mail.html.erb | 2 +- config/routes.rb | 2 +- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 62b076754..8187055be 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -239,17 +239,18 @@ class AccountController < ApplicationController end def resendmail - status = 1 + result = {:status=>1, :email=>""} user = User.find(params[:user]) if params[:user] + result[:email] = user.mail token = Token.new(:user => user, :action => "register") if token.save # Mailer.run.register(token) Mailer.register(token).deliver else yield if block_given? - status = 0 + result[:status] = 0 end - render :json => status + render :json => result end def email_activation diff --git a/app/views/account/email_activation.html.erb b/app/views/account/email_activation.html.erb index d625e7fc9..9655efcf4 100644 --- a/app/views/account/email_activation.html.erb +++ b/app/views/account/email_activation.html.erb @@ -23,9 +23,15 @@ url, {user: id }, function (data) { - console.log("1111111111"); - console.log(data); - $(".email_verify_btn").replaceWith(""); + //邮箱@之前用a**b格式显示 + var mail = data.email; + var pos = mail.indexOf("@"); + var restr = mail.substring(1,pos-1); + if( mail.split("@")[0].length > 2 ){ + mail = mail.replace(restr,"***"); + } + + $(".email_verify_btn").replaceWith(""); } ); } @@ -37,16 +43,16 @@ pop_up_box(htmlvalue,580,30,50); return; } - $.get( - url, - {user:user,text:$(".email_prompt_mes").val() }, - function (data) { - console.log("2222222"); - console.log(data); - var htmlvalue = "" - pop_up_box(htmlvalue,580,30,50); - $(".email_prompt_mes").val(""); - } - ); + + $.ajax({ + url: url, + data: {user: user, text: $(".email_prompt_mes").val() }, + type: "POST", + success: function (data) { + var htmlvalue = "" + pop_up_box(htmlvalue, 580, 30, 45); + $(".email_prompt_mes").val(""); + } + }); } diff --git a/app/views/projects/invite_members_by_mail.html.erb b/app/views/projects/invite_members_by_mail.html.erb index bced1e936..d0f46611e 100644 --- a/app/views/projects/invite_members_by_mail.html.erb +++ b/app/views/projects/invite_members_by_mail.html.erb @@ -48,7 +48,7 @@ var last_name = $.trim($('#last_name').val()); if(last_name.length > 30) { - $("#valid_email").text("用户姓氏过长,最长为30个字符"); + $("#valid_email").text("用户姓名过长,最长为30个字符"); return false; } else diff --git a/config/routes.rb b/config/routes.rb index d56f75ced..0741b2a10 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -496,7 +496,7 @@ RedmineApp::Application.routes.draw do match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post] #激活邮箱反馈问题 - match 'users/:id/leave_email_activation_message', :to => 'words#leave_email_activation_message', :via => :get, :as => "leave_email_activation_message" + match 'users/:id/leave_email_activation_message', :to => 'words#leave_email_activation_message', :via => :post, :as => "leave_email_activation_message" # boards match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message' From 89e42ac77668ffaaa0beceeaba8e5b365b248ce9 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 1 Jul 2016 16:10:48 +0800 Subject: [PATCH 08/18] =?UTF-8?q?=E5=B0=86=E5=A7=93=E6=B0=8F=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=A7=93=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/my/zh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/my/zh.yml b/config/locales/my/zh.yml index 39c7c3167..85ba156ef 100644 --- a/config/locales/my/zh.yml +++ b/config/locales/my/zh.yml @@ -37,7 +37,7 @@ zh: field_firstname: 名字或组织名 firstname_empty: 名字不能为空 field_firstname_eg: '(例:张三丰,请填写[三丰])' - field_lastname: 姓氏 + field_lastname: 姓名 lastname_empty: 姓氏不能为空 enterprise_empty: 企业名不能为空 field_lastname_eg: '(例:张三丰,请填写[张])' From 547d5409bb8c260708b4b7b19438c8196901b197 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 1 Jul 2016 17:43:38 +0800 Subject: [PATCH 09/18] =?UTF-8?q?=E7=BB=84=E7=BB=87=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=AD=97=E6=A0=B7=E6=94=B9=E4=B8=BA=E7=8F=AD?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/organizations_helper.rb | 2 +- app/views/organizations/_join_course_menu.html.erb | 6 +++--- app/views/organizations/_org_custom_left2.html.erb | 2 +- app/views/organizations/_org_left_subfield_list.html.erb | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index cb06bd688..48b5f068b 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -23,7 +23,7 @@ module OrganizationsHelper when 'activity' then return '动态' when 'course' then - return '课程' + return '班级' when 'project' then return '项目' end diff --git a/app/views/organizations/_join_course_menu.html.erb b/app/views/organizations/_join_course_menu.html.erb index b15dce2c6..9ca522e97 100644 --- a/app/views/organizations/_join_course_menu.html.erb +++ b/app/views/organizations/_join_course_menu.html.erb @@ -24,12 +24,12 @@
    -
    请选择关联到组织的课程
    -
    您的私有课程不能被关联到组织
    +
    请选择关联到组织的班级
    +
    您的私有班级不能被关联到组织
    <%=form_tag url_for(:controller => 'organizations', :action => 'join_courses', :organization_id => organization_id),:method => 'post', :id => 'join_courses_form', :remote => true,:class=>"resourcesSearchBox" do %> - +
    关联 diff --git a/app/views/organizations/_org_custom_left2.html.erb b/app/views/organizations/_org_custom_left2.html.erb index 2c389766f..feedf2a44 100644 --- a/app/views/organizations/_org_custom_left2.html.erb +++ b/app/views/organizations/_org_custom_left2.html.erb @@ -2,7 +2,7 @@ <% if is_default_field?(field) %> <% case field.name %> <% when 'course' %> -

    课程动态

    +

    班级动态

    <% if @course_acts.blank? %>

    该模块暂时没有相关内容

    <% else %> diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index ddc504640..9d043fbb5 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -63,9 +63,9 @@ <% when 'course' %>
    - 课程 + 班级 <% if User.current.logged? and User.current.admin_of_org?(organization) %> - <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> + <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联班级"%> <% end %>
    From 25e77497e7a4af6f50f7fa05175e4eb419abbb12 Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 1 Jul 2016 17:50:08 +0800 Subject: [PATCH 10/18] consloe pring --- app/controllers/quality_analysis_controller.rb | 11 ++++++++--- app/views/quality_analysis/_console_output.html.erb | 8 ++++++++ app/views/quality_analysis/create.html.erb | 9 +++++++++ app/views/quality_analysis/index.html.erb | 10 +++++++--- app/views/repositories/show.html.erb | 4 ++-- config/routes.rb | 1 + 6 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 app/views/quality_analysis/_console_output.html.erb create mode 100644 app/views/quality_analysis/create.html.erb diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 75499c985..2c55f780c 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -2,7 +2,7 @@ class QualityAnalysisController < ApplicationController before_filter :find_project_by_project_id#, :except => [:getattachtype] before_filter :find_quality_analysis, :only => [:edit, :update_jenkins_job] before_filter :authorize - before_filter :connect_jenkins, :only => [:create, :edit, :update_jenkins_job] + before_filter :connect_jenkins, :only => [:create, :edit, :update_jenkins_job, :index] layout "base_projects" include ApplicationHelper include QualityAnalysisHelper @@ -78,7 +78,7 @@ class QualityAnalysisController < ApplicationController d = @client.job.delete("#{job_name}") if jenkins_job == '200' && code != '201' logger.error("delete result ==> #{code}") - if qa.blank? && code == '201' + if qa.blank? && @current_build_status == "success" QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier, :sonar_version => version, :path => path, :branch => branch, :language => language, :sonar_name => "#{user_name}:#{rep_id}") else @@ -89,7 +89,7 @@ class QualityAnalysisController < ApplicationController puts e end respond_to do |format| - format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch)} + format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch, :current_build_status => @current_build_status, :job_name => job_name)} # format.js{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch)} end end @@ -167,6 +167,7 @@ class QualityAnalysisController < ApplicationController begin @resource_id = params[:resource_id] @sonar_address = Redmine::Configuration['sonar_address'] + @jenkins_address = Redmine::Configuration['jenkins_address'] if params[:resource_id].nil? @name_flag = true projects_date = open(@sonar_address + "/api/projects/index").read @@ -174,6 +175,10 @@ class QualityAnalysisController < ApplicationController @quality_analyses = QualityAnalysis.where(:project_id => @project.id).select{|qa| arr.include?(qa.sonar_name)} else + if params[:current_build_status] == "failure" + job_name = params[:job_name] + @console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text') + end complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,file_line,files,functions,classes,directories").read @complexity =JSON.parse(complexity_date).first issue_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations").read diff --git a/app/views/quality_analysis/_console_output.html.erb b/app/views/quality_analysis/_console_output.html.erb new file mode 100644 index 000000000..45115b9fe --- /dev/null +++ b/app/views/quality_analysis/_console_output.html.erb @@ -0,0 +1,8 @@ +<%= javascript_include_tag 'highcharts','highcharts-more' %> +
    +

    质量分析

    +
    +

    + <%= h @console_build.to_json.html_safe %> +

    + diff --git a/app/views/quality_analysis/create.html.erb b/app/views/quality_analysis/create.html.erb new file mode 100644 index 000000000..e7c81f662 --- /dev/null +++ b/app/views/quality_analysis/create.html.erb @@ -0,0 +1,9 @@ +<% if @current_build_status == "success" %> + <%= render :partial => "show", :locals => {:branch => params[:branch]} %> +<% else %> + <% if @build_console_result %> + 运行结果超时 + <% else %> + <%= render :partial => "console_output" %> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/quality_analysis/index.html.erb b/app/views/quality_analysis/index.html.erb index ead8aae48..19b5c5eea 100644 --- a/app/views/quality_analysis/index.html.erb +++ b/app/views/quality_analysis/index.html.erb @@ -1,10 +1,14 @@ <% if @name_flag %> <%= render :partial => "result_list" %> <% else %> - <% if @build_console_result %> - 运行结果超时 - <% else %> + <% if params[:current_build_status].nil? || params[:current_build_status] == "success" %> <%= render :partial => "show", :locals => {:branch => params[:branch]} %> + <% else %> + <% if params[:build_console_result] %> + 运行结果超时 + <% else %> + <%= render :partial => "console_output" %> + <% end %> <% end %> <% end %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 0a9b49470..8164a103f 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -5,9 +5,9 @@ ZIP下载 <%# if is_project_manager?(User.current, @project.id) && QualityAnalysis.where(:project_id => @project.id).first.nil? %> <%# if User.current.member_of?(@project) %> - <%# if quality_analysis(User.current.try(:login), @repository.id).nil? && is_project_manager?(User.current.id, @project.id) %> + <% if quality_analysis(User.current.try(:login), @repository.id).nil? && is_project_manager?(User.current.id, @project.id) && @project.is_public? %> <%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch ), :remote => true, :class => "btn_zipdown fr" %> - <%# end %> + <% end %> <%# end %> <%# else %> <%#= link_to "质量分析", project_quality_analysis_path(:project_id => @project.id, :resource_id => @proje), :class => "btn_zipdown fr" %> diff --git a/config/routes.rb b/config/routes.rb index 075aff6e1..dd6df94ed 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -792,6 +792,7 @@ RedmineApp::Application.routes.draw do member do match 'update_jenkins_job' match 'edit' + match 'create' end end # resources :files, :only => [:index, :new, :create] do From 28c20c966ed4c70aebede52db2d8a416761da375 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 1 Jul 2016 19:28:55 +0800 Subject: [PATCH 11/18] =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/tags/_show_users.html.erb | 2 +- app/views/tags/index.html.erb | 2 +- public/stylesheets/courses.css | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/tags/_show_users.html.erb b/app/views/tags/_show_users.html.erb index d8b172ba9..ab6570a2a 100644 --- a/app/views/tags/_show_users.html.erb +++ b/app/views/tags/_show_users.html.erb @@ -2,7 +2,7 @@ <% if users_results.try(:size).to_i > 0 %>
    <% users_results.each do |user| %> -

    +

    <%= l(:label_tags_user_name) %><%= link_to ("#{user.name}"), :controller => "users",:action => "show",:id => user.id%>
    diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb index 947366eeb..038768a41 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/tags/index.html.erb @@ -16,7 +16,7 @@ <% content_for :content do %>

    <%= l(:label_tags_search_result) %>

    -
    +
    <%= l(:label_tags_numbers) %>: <%= l(:label_issue_plural) %>(<%= @issues_tags_num %>) | <%= l(:label_project_plural) %>(<%= @projects_tags_num %>) | diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index d6026537e..1df2a2ece 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1428,4 +1428,5 @@ a.pages-big{ width:50px;} .W300 {width:300px !important;} .W600{ width:600px;} -.syllabus_input {width: 290px; border: 1px solid #64bdd9; height: 30px;} +.syllabus_input {width: 290px; border: 1px solid #64bdd9; height: 30px;} +.syllabus_input option {max-width:260px;} From 8cc4b7a87864bf67046d7438ac41c086d4c85c13 Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 1 Jul 2016 20:00:23 +0800 Subject: [PATCH 12/18] public questions --- app/controllers/projects_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 8664a1372..54ab3b2c3 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -653,12 +653,14 @@ class ProjectsController < ApplicationController def update @project.safe_attributes = params[:project] @project.organization_id = params[:organization_id] - params[:project][:is_public] ? @project.is_public = 1 : @project.is_public = 0 - params[:project][:hidden_repo] ? @project.hidden_repo = 1 : @project.hidden_repo = 0 + params[:project][:is_public] == "on" ? @project.is_public = 1 : @project.is_public = 0 + params[:project][:hidden_repo] == "on" ? @project.hidden_repo = 1 : @project.hidden_repo = 0 # 更新公开私有时同步gitlab公开私有 - if !@project.gpid.nil? && @project.is_public != (params[:project][:is_public] == "on" ? true : false) + if !@project.gpid.nil? && @project.is_public != (params[:project][:is_public] == "on" ? 1 : 0) + logger.info("########################=>#{params[:project][:is_public]}") g = Gitlab.client - params[:project][:is_public] ? g.edit_project(@project.gpid, 20, params[:branch]) : g.edit_project(@project.gpid, 0, params[:branch]) + params[:project][:is_public] == "on" ? g.edit_project(@project.gpid, 20, params[:branch]) : g.edit_project(@project.gpid, 0, params[:branch]) + logger.info("88888888888888888888888=>#{params[:project][:is_public] == "on"}") end # end if validate_parent_id && @project.save From 1bfb2918f077f8801d13134f1a3236b6ff7a545d Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 1 Jul 2016 20:06:12 +0800 Subject: [PATCH 13/18] =?UTF-8?q?KE=E9=97=B4=E8=B7=9D=E6=94=B9=E5=9B=9E?= =?UTF-8?q?=E5=8E=9F=E6=9D=A5=E7=9A=84=EF=BC=8C=E4=BF=AE=E6=94=B9=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=A4=A7=E7=BA=B2=E9=99=84=E4=BB=B6=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E6=A0=87=E9=A2=98=E4=B8=8E=E7=BD=AE=E9=A1=B6?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 2 +- app/views/attachments/_form_course.html.erb | 12 ++++++------ public/stylesheets/courses.css | 3 +-- public/stylesheets/new_user.css | 1 - public/stylesheets/project.css | 1 - public/stylesheets/public.css | 3 +-- public/stylesheets/syllabus.css | 2 +- 7 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 960bc61e6..a6b5f09cf 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -612,7 +612,7 @@ class AttachmentsController < ApplicationController @attachment.container.board.course) @course = @attachment.container.board.course else - unless @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' + unless @attachment.container_type == 'Syllabus' || @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' @project = @attachment.project end end diff --git a/app/views/attachments/_form_course.html.erb b/app/views/attachments/_form_course.html.erb index 6d921903d..1d51e951a 100644 --- a/app/views/attachments/_form_course.html.erb +++ b/app/views/attachments/_form_course.html.erb @@ -2,31 +2,31 @@ <% if defined?(container) && container && container.saved_attachments %> <% if isReply %> <% container.saved_attachments.each_with_index do |attachment, i| %> - +

    <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly', :readonly=>'readonly')%> <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%> - <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> + <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "#{i+1}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload', :containerid => "2") %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> - +

    <% end %> <% else %> <% container.attachments.each_with_index do |attachment, i| %> - +

    <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly', :readonly=>'readonly')%> <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%> - <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> + <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "#{i+1}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload', :containerid => "2") %> <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> - +

    <% end %> <% end %> <% end %> diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 96c9947b1..178e9bb5d 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -152,7 +152,6 @@ a.postTypeGrey:hover {color:#269ac9;} .homepagePostIntro ul li{list-style-type: disc;margin-left: 40px;} .homepagePostIntro td,.homepagePostIntro tr {border: 1px solid; border-color: inherit;} .homepagePostIntro a{color: #136ec2;} -.homepagePostIntro p{line-height: 1;} .homepagePostDeadline {font-size:12px; color:#888888; float:left; margin-top: 2px;} .homepagePostDate {font-size:12px; color:#888888;margin-bottom: 5px;} .homepagePostReply {width:710px; margin:0px auto; background-color:#f1f1f1; margin-top:10px;} @@ -1429,4 +1428,4 @@ a.pages-big{ width:50px;} .W300 {width:300px !important;} .W600{ width:600px;} -.syllabus_input {width: 290px; border: 1px solid #64bdd9; height: 30px;} +.syllabus_input {width: 290px; border: 1px solid #64bdd9; height: 30px;} diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index a65edc490..b931dff6b 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -683,7 +683,6 @@ a.postTypeGrey:hover {color:#269ac9;} .homepagePostIntro ul li{list-style-type: disc;margin-left: 40px;} .homepagePostIntro td,.homepagePostIntro tr {border: 1px solid; border-color: inherit;} .homepagePostIntro a{color: #136ec2;} -.homepagePostIntro p{line-height: 1;} .homepagePostReplyBanner {width:718px; height:33px; border:1px solid #e4e4e4; line-height:33px; vertical-align:middle; font-size:12px; color:#888888; position: relative;} .borderBottomNone {border-bottom:none !important;} .homepagePostReplyBanner {width:718px; height:33px; border:1px solid #e4e4e4; line-height:33px; vertical-align:middle; font-size:12px; color:#888888;} diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index 354c0f1ac..bde560613 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -969,7 +969,6 @@ a:hover.Reply_pic{border:1px solid #64bdd9;} color: #484848; overflow: hidden; } -.homepagePostIntro p{line-height: 1;} .homepagePostReply { width: 710px; margin: 10px auto 0px; diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 7cfb7f9e0..c86e0f42d 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -633,7 +633,6 @@ a.postTypeGrey:hover {color:#269ac9;} .homepagePostIntro ul li{list-style-type: disc;margin-left: 40px;} .homepagePostIntro td,.homepagePostIntro tr {border: 1px solid; border-color: inherit;} .homepagePostIntro a{color: #136ec2;} -.homepagePostIntro p{line-height: 1;} .homepagePostDeadline {font-size:12px; color:#888888; float:left; margin-top: 2px;} .homepagePostDate {font-size:12px; color:#888888;margin-bottom: 5px;} .homepagePostReplyBanner {width:708px; height:33px; border:1px solid #e4e4e4; line-height:33px; vertical-align:middle; font-size:12px; color:#888888; position: relative;} @@ -1184,4 +1183,4 @@ a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px; .reply_iconup{ position:absolute; top:21px; left:13px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;} /*20160622代码分析弹窗*/ -.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;} +.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;} diff --git a/public/stylesheets/syllabus.css b/public/stylesheets/syllabus.css index 6218f52e0..2abbffda7 100644 --- a/public/stylesheets/syllabus.css +++ b/public/stylesheets/syllabus.css @@ -138,7 +138,7 @@ a.sortupbtn{ background: url(../images/syllabus/icons_syllabus.png) 0 3px no-rep a.sortdownbtn{ background: url(../images/syllabus/icons_syllabus.png) 0 -12px no-repeat; width:12px; height:17px; display:block;cursor:pointer; } a.sort_no{ background: url(../images/syllabus/icons_syllabus.png) -16px -12px no-repeat; width:12px; height:17px; display:block;cursor:pointer; } .item_list{ display:block; width:5px; height:5px;-webkit-border-radius: 25px;border-radius:25px; background-color:#adadad; margin:10px 10px 0 0;} -a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; width:708px;} +a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block;} a:hover.list-title{ color:#269ac9;} .c_red{ font-weight:normal; font-size:12px;} .list-file{ padding:10px 0; border-bottom:1px dashed #ddd;} From 134aa55e04807356886a4acfd262a8aa4e9c1e93 Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 1 Jul 2016 20:16:06 +0800 Subject: [PATCH 14/18] authoriod --- app/views/quality_analysis/_result_list.html.erb | 8 +++++++- app/views/repositories/show.html.erb | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/views/quality_analysis/_result_list.html.erb b/app/views/quality_analysis/_result_list.html.erb index 51d91c04f..b0b8abafe 100644 --- a/app/views/quality_analysis/_result_list.html.erb +++ b/app/views/quality_analysis/_result_list.html.erb @@ -21,7 +21,13 @@
  • <%= qa.branch %>
  • <%= qa.language %>
  • <%= qa.path %>
  • -
  • <%=link_to "编辑", edit_project_quality_analysi_path(qa, :project_id => @project.id), :remote => true %>
  • + <% if User.current.try(:login) == qa.author_login %> +
  • + <%=link_to "编辑", edit_project_quality_analysi_path(qa, :project_id => @project.id), :remote => true, :class => "fontBlue2" %> +
  • + <% else %> +
  • 编辑
  • + <% end %>
    <% end %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 8164a103f..05f25822b 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -5,7 +5,7 @@ ZIP下载 <%# if is_project_manager?(User.current, @project.id) && QualityAnalysis.where(:project_id => @project.id).first.nil? %> <%# if User.current.member_of?(@project) %> - <% if quality_analysis(User.current.try(:login), @repository.id).nil? && is_project_manager?(User.current.id, @project.id) && @project.is_public? %> + <% if quality_analysis(User.current.try(:login), @repository.id).nil? && User.current.member_of?(@project) && @project.is_public? %> <%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch ), :remote => true, :class => "btn_zipdown fr" %> <% end %> <%# end %> From 61b5a100eb7b95d74861f11e6bd79e7c33bbe0d6 Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 1 Jul 2016 20:25:58 +0800 Subject: [PATCH 15/18] delete log messages --- app/controllers/projects_controller.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 54ab3b2c3..cb86f1165 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -657,10 +657,8 @@ class ProjectsController < ApplicationController params[:project][:hidden_repo] == "on" ? @project.hidden_repo = 1 : @project.hidden_repo = 0 # 更新公开私有时同步gitlab公开私有 if !@project.gpid.nil? && @project.is_public != (params[:project][:is_public] == "on" ? 1 : 0) - logger.info("########################=>#{params[:project][:is_public]}") g = Gitlab.client params[:project][:is_public] == "on" ? g.edit_project(@project.gpid, 20, params[:branch]) : g.edit_project(@project.gpid, 0, params[:branch]) - logger.info("88888888888888888888888=>#{params[:project][:is_public] == "on"}") end # end if validate_parent_id && @project.save From 70e26927cba70f4f81cf2091ad4fbd035f51ee5e Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 1 Jul 2016 20:38:33 +0800 Subject: [PATCH 16/18] =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=AD=97=E6=A0=B7=E6=94=B9=E4=B8=BA=E7=8F=AD?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/courses_service.rb | 12 ++++++------ app/views/courses/join.js.erb | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index f6bf59af0..f59beb7e5 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -324,15 +324,15 @@ class CoursesService define_error [ 0, '加入成功', 1, '密码错误', - 2, '课程已过期 请联系课程管理员重启课程。', - 3, '您已经加入了课程', - 4, '您加入的课程不存在', + 2, '班级已过期 请联系班级管理员重启班级。', + 3, '您已经加入了班级', + 4, '您加入的班级不存在', 5, '您还未登录', 6, '申请成功,请等待审核完毕', 7, '您已经发送过申请了,请耐心等待', - 8, '您已经是该课程的教师了', - 9, '您已经是该课程的教辅了', - 10, '您已经是该课程的管理员了', + 8, '您已经是该班级的教师了', + 9, '您已经是该班级的教辅了', + 10, '您已经是该班级的管理员了', '未知错误,请稍后再试' ] end diff --git a/app/views/courses/join.js.erb b/app/views/courses/join.js.erb index 04a77f87b..ac8b717d1 100644 --- a/app/views/courses/join.js.erb +++ b/app/views/courses/join.js.erb @@ -10,12 +10,12 @@ window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/co <% elsif @state == 1 %> alert("密码错误"); <% elsif @state == 2 %> -alert("课程已过期\n请联系课程管理员重启课程。(在配置课程处)"); +alert("班级已过期\n请联系班级管理员重启班级。(在配置班级处)"); <% elsif @state == 3 %> -alert("您已经加入了课程"); +alert("您已经加入了班级"); window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" <% elsif @state == 4 %> -alert("您加入的课程不存在"); +alert("您加入的班级不存在"); <% elsif @state == 5 %> alert("您还未登录"); <% elsif @state == 6 %> @@ -25,15 +25,15 @@ hidden_join_course_form(); alert("您已经发送过申请了,请耐心等待"); hidden_join_course_form(); <% elsif @state == 8%> -alert("您已经是该课程的教师了"); +alert("您已经是该班级的教师了"); hidden_join_course_form(); window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" <% elsif @state == 9%> -alert("您已经是该课程的教辅了"); +alert("您已经是该班级的教辅了"); hidden_join_course_form(); window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" <% elsif @state == 10%> -alert("您已经是该课程的管理员了"); +alert("您已经是该班级的管理员了"); hidden_join_course_form(); window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" <% else %> From 6ac7d322b9715130e420935e215ddf5e8724ae97 Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 1 Jul 2016 21:31:50 +0800 Subject: [PATCH 17/18] some added --- app/controllers/quality_analysis_controller.rb | 3 ++- app/views/quality_analysis/_console_output.html.erb | 6 +++--- app/views/quality_analysis/index.html.erb | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 2c55f780c..bec66aeff 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -165,6 +165,7 @@ class QualityAnalysisController < ApplicationController # resource_id: login + @repository.id def index begin + @branch = params[:branch] @resource_id = params[:resource_id] @sonar_address = Redmine::Configuration['sonar_address'] @jenkins_address = Redmine::Configuration['jenkins_address'] @@ -177,7 +178,7 @@ class QualityAnalysisController < ApplicationController else if params[:current_build_status] == "failure" job_name = params[:job_name] - @console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text') + @console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')["output"] end complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,file_line,files,functions,classes,directories").read @complexity =JSON.parse(complexity_date).first diff --git a/app/views/quality_analysis/_console_output.html.erb b/app/views/quality_analysis/_console_output.html.erb index 45115b9fe..372f7ec8d 100644 --- a/app/views/quality_analysis/_console_output.html.erb +++ b/app/views/quality_analysis/_console_output.html.erb @@ -2,7 +2,7 @@

    质量分析

    -

    - <%= h @console_build.to_json.html_safe %> -

    +
    + <%=h @console_build %> +
    diff --git a/app/views/quality_analysis/index.html.erb b/app/views/quality_analysis/index.html.erb index 19b5c5eea..7925f6120 100644 --- a/app/views/quality_analysis/index.html.erb +++ b/app/views/quality_analysis/index.html.erb @@ -2,7 +2,7 @@ <%= render :partial => "result_list" %> <% else %> <% if params[:current_build_status].nil? || params[:current_build_status] == "success" %> - <%= render :partial => "show", :locals => {:branch => params[:branch]} %> + <%= render :partial => "show", :locals => {:branch => @branch} %> <% else %> <% if params[:build_console_result] %> 运行结果超时 From 447e624f3640ad870e695661628c78836a49fa11 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 1 Jul 2016 21:38:37 +0800 Subject: [PATCH 18/18] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=A4=A7=E7=BA=B2bug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/syllabuses_helper.rb | 12 ++++++------ app/views/courses/private_or_public.js.erb | 4 ++-- app/views/layouts/_syllabus_base_info.html.erb | 6 +++--- app/views/syllabuses/_syllabus_course_list.html.erb | 2 +- app/views/users/_user_course_list.html.erb | 2 +- app/views/users/_user_syllabus_list.html.erb | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/helpers/syllabuses_helper.rb b/app/helpers/syllabuses_helper.rb index 00331e0dc..7e815950b 100644 --- a/app/helpers/syllabuses_helper.rb +++ b/app/helpers/syllabuses_helper.rb @@ -48,17 +48,17 @@ module SyllabusesHelper option6 = [] option1 << "请选择" - option1 << 1 + option1 << 0 option2 << "公共必修课" - option2 << 2 + option2 << 1 option3 << "学科必修课" - option3 << 3 + option3 << 2 option4 << "专业选修课" - option4 << 4 + option4 << 3 option5 << "实践必修课" - option5 << 5 + option5 << 4 option6 << "实践选修课" - option6 << 6 + option6 << 5 type << option1 type << option2 diff --git a/app/views/courses/private_or_public.js.erb b/app/views/courses/private_or_public.js.erb index 4e512a6a0..82180c452 100644 --- a/app/views/courses/private_or_public.js.erb +++ b/app/views/courses/private_or_public.js.erb @@ -9,9 +9,9 @@ } <% else %> <% if @course.is_public? %> - $("#show_course_<%= @course.id %>").attr("title","公开课程:<%= @course.name %>(<%= @course.time.to_s+ @course.term %>)"); + $("#show_course_<%= @course.id %>").attr("title","公开班级:<%= @course.name %>(<%= @course.time.to_s+ @course.term %>)"); <% else %> - $("#show_course_<%= @course.id %>").attr("title","私有课程:<%= @course.name %>(<%= @course.time.to_s+ @course.term %>)"); + $("#show_course_<%= @course.id %>").attr("title","私有班级:<%= @course.name %>(<%= @course.time.to_s+ @course.term %>)"); <% end %> $("#set_course_public_<%= @course.id %>").replaceWith('<%= escape_javascript(link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => "courses", :action => "private_or_public", :id => @course,:user_page => true}, :id => "set_course_public_#{@course.id.to_s}",:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗") %>'); diff --git a/app/views/layouts/_syllabus_base_info.html.erb b/app/views/layouts/_syllabus_base_info.html.erb index cf4926d82..ae6da2ac3 100644 --- a/app/views/layouts/_syllabus_base_info.html.erb +++ b/app/views/layouts/_syllabus_base_info.html.erb @@ -4,7 +4,7 @@ <% end %>
  • <%=syllabus.user.show_name %>
  • - <% unless syllabus.syllabus_type.nil? || syllabus.syllabus_type == 0 %> + <% unless syllabus.syllabus_type.nil? || syllabus.syllabus_type == 0 || syllabus.syllabus_type == '' %>
  • <%=syllabus.syllabus_type_str %>
  • <% end %> <% unless syllabus.credit.nil? || syllabus.credit == '' %> @@ -26,7 +26,7 @@
  • <%=syllabus.pre_course %>
  • <% end %> - <% if syllabus.syllabus_type.nil? || syllabus.syllabus_type == '' %> + <% if syllabus.syllabus_type.nil? || syllabus.syllabus_type == 0 || syllabus.syllabus_type == '' %>
  • <% end %> <% if syllabus.credit.nil? || syllabus.credit == '' %> @@ -48,7 +48,7 @@
  • <% end %> -<% if User.current.logged? && (User.current == syllabus.user || User.current.admin?)&&(syllabus.syllabus_type.nil? || syllabus.syllabus_type == ''||syllabus.credit.nil? || syllabus.credit == ''||syllabus.hours.nil? || syllabus.hours == ''||syllabus.theory_hours.nil? || syllabus.theory_hours == ''||syllabus.practice_hours.nil? || syllabus.practice_hours == ''||syllabus.applicable_major.nil? || syllabus.applicable_major == ''||syllabus.pre_course.nil? || syllabus.pre_course == '')%> +<% if User.current.logged? && (User.current == syllabus.user || User.current.admin?)&&(syllabus.syllabus_type.nil? || syllabus.syllabus_type == 0 || syllabus.syllabus_type == ''||syllabus.credit.nil? || syllabus.credit == ''||syllabus.hours.nil? || syllabus.hours == ''||syllabus.theory_hours.nil? || syllabus.theory_hours == ''||syllabus.practice_hours.nil? || syllabus.practice_hours == ''||syllabus.applicable_major.nil? || syllabus.applicable_major == ''||syllabus.pre_course.nil? || syllabus.pre_course == '')%> <% end %>