diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 44f0d15f4..049842e37 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -432,14 +432,15 @@ class IssuesController < ApplicationController def add_journal if User.current.logged? - jour = Journal.new - jour.user_id = User.current.id - jour.notes = params[:notes] - jour.journalized = @issue - jour.save_attachments(params[:attachments]) - jour.save + @jour = Journal.new + @jour.user_id = User.current.id + @jour.notes = params[:notes] + @jour.journalized = @issue + @jour.save_attachments(params[:attachments]) + @jour.save update_user_activity(@issue.class,@issue.id) update_forge_activity(@issue.class,@issue.id) + @allowed_statuses = @issue.new_statuses_allowed_to(User.current) @user_activity_id = params[:user_activity_id] if params[:issue_id] @@ -492,7 +493,7 @@ class IssuesController < ApplicationController update_forge_activity(@issue.class,@issue.id) respond_to do |format| - format.js + format.html{redirect_to issue_url(@issue)} end end end @@ -502,7 +503,7 @@ class IssuesController < ApplicationController @issue = Issue.find(params[:id]) Journal.destroy(params[:journal_id]) respond_to do |format| - format.js + format.html{redirect_to issue_url(@issue)} end end diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 03ed7945a..3c2f29c84 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, :index] + before_filter :connect_jenkins, :only => [:create, :edit, :update_jenkins_job, :index, :delete] layout "base_projects" include ApplicationHelper include QualityAnalysisHelper @@ -33,7 +33,6 @@ class QualityAnalysisController < ApplicationController arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"] quality_an = QualityAnalysis.where(:sonar_name => sonar_name).first if @client.job.exists?(job_name) && QualityAnalysis.where(:sonar_name => sonar_name).select{|qa| arr.include?(qa.sonar_name)}.blank? - logger.info("88888888888888888888") aa = @client.job.delete("#{job_name}") quality_an.delete unless quality_an.blank? end @@ -84,7 +83,7 @@ class QualityAnalysisController < ApplicationController end # sonar 缓冲,取数据 - sleep(5) + sleep(3) # 获取sonar output结果 console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')["output"] @@ -152,11 +151,31 @@ class QualityAnalysisController < ApplicationController @gitlab_default_branch = @g.project(@project.gpid).default_branch end + # 删除的时候主要删除三方面数据:1/Trustie数据 2/jenkins数据 3/sonar数据 + # 如果只删除数据1,则新建的时候会有冲突 + def delete + begin + qa = QualityAnalysis.find(params[:id]) + rep_id = Repository.where(:project_id => @project.id, :identifier => qa.rep_identifier).first.try(:id) + job_name = "#{qa.author_login}-#{rep_id}" + logger.info("result: job_name ###################==>#{job_name}") + logger.info("result: @client.job ###################==>#{@client.job}") + + d_job = @client.job.delete(job_name) + logger.info("result: delete job ###################==>#{d_job}") + qa.delete + respond_to do |format| + format.html{redirect_to project_quality_analysis_path(:project_id => @project.id)} + end + rescue Exception => e + puts e + end + end + # 更新Jenkins job,主要包括相关配置文件参数的更新,Trustie平台数据的更新 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 @@ -223,7 +242,7 @@ class QualityAnalysisController < ApplicationController if key == "sqale_index" value = com["frmt_val"] else - value = com["val"].to_i + value = com["val"] end @ha.store(key,value) end @@ -260,9 +279,11 @@ class QualityAnalysisController < ApplicationController def connect_jenkins @gitlab_address = Redmine::Configuration['gitlab_address'] @jenkins_address = Redmine::Configuration['jenkins_address'] + jenkins_username = Redmine::Configuration['jenkins_username'] + jenkins_password = Redmine::Configuration['jenkins_password'] # connect jenkins - @client = JenkinsApi::Client.new(:server_url => @jenkins_address, :username => "temp", :password => '123123') + @client = JenkinsApi::Client.new(:server_url => @jenkins_address, :username => jenkins_username, :password => jenkins_password) rescue => e logger.error("failed to connect Jenkins ==> #{e}") end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f5684f202..5a88e90d3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2150,6 +2150,7 @@ class UsersController < ApplicationController # 添加资源到对应的项目 def add_exist_file_to_project @flag = true + # 发送单个资源 if params[:send_id].present? send_id = params[:send_id] project_ids = params[:projects_ids] @@ -2186,6 +2187,8 @@ class UsersController < ApplicationController quotes = ori.quotes.to_i + 1 ori.update_attribute(:quotes, quotes) unless ori.nil? ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + # 项目中添加动态 + ForgeActivity.create(:user_id => User.current.id, :project_id => project_id, :forge_act_id => attach_copied_obj.id, :forge_act_type => "Attachment" ) end unless Project.find(project_id).project_score.nil? Project.find(project_id).project_score.update_attribute(:attach_num, @@ -2194,6 +2197,7 @@ class UsersController < ApplicationController end @ori = ori end + # 发送多个资源 elsif params[:send_ids].present? send_ids = params[:send_ids].split(",") project_ids = params[:projects_ids] @@ -2232,6 +2236,8 @@ class UsersController < ApplicationController quotes = ori.quotes.to_i + 1 ori.update_attribute(:quotes, quotes) unless ori.nil? ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + # 项目中添加动态 + ForgeActivity.create(:user_id => User.current.id, :project_id => project_id, :forge_act_id => attach_copied_obj.id, :forge_act_type => "Attachment" ) end unless Project.find(project_id).project_score.nil? Project.find(project_id).project_score.update_attribute(:attach_num, Project.find(project_id).project_score.attach_num + 1) diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 23acabd1f..cfe9cd695 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -62,7 +62,7 @@ }); $mail.blur(function (event) { - if (/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.value) == false){ + if (/^[a-zA-Z0-9]+([._\\]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.value) == false){ $('#mail_req').html( '邮件格式不对').show(); $mail_correct = false; return ; diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb index 85e0dc8d3..4e9f38c50 100644 --- a/app/views/files/_resource_detail.html.erb +++ b/app/views/files/_resource_detail.html.erb @@ -93,6 +93,6 @@
-
- \ No newline at end of file + +
\ No newline at end of file diff --git a/app/views/issues/_attributes.html.erb b/app/views/issues/_attributes.html.erb index f0967843a..cb9b79c7c 100644 --- a/app/views/issues/_attributes.html.erb +++ b/app/views/issues/_attributes.html.erb @@ -4,15 +4,15 @@
  • - <%# if @copy_from && @copy_from.attachments.any? %> - - - - - <%# end %> <% if @copy_from && !@copy_from.leaf? %>

    @@ -83,23 +76,6 @@ <%= render :partial => 'issues/attributes' %>

    - - - - - <%#= link_to "", -# {:controller => 'watchers', :action => 'new', :project_id => @issue.project}, -# :remote => true, -# :method => 'get', - :class => "pic_sch mt5 ml5" %> - - <%#= javascript_tag "observeSearchfield('user_search', 'users_for_watcher', '#{ escape_javascript watchers_autocomplete_for_user_path(:user => @available_watchers, :format => 'js', :flag => 'ture') }')" %> - - - - - - <%= call_hook(:view_issues_form_details_bottom, {:issue => @issue, :form => f}) %> <% end %> 确定 diff --git a/app/views/issues/_issue_replies.html.erb b/app/views/issues/_issue_replies.html.erb index 7b5383c1e..c120ca1b9 100644 --- a/app/views/issues/_issue_replies.html.erb +++ b/app/views/issues/_issue_replies.html.erb @@ -42,7 +42,6 @@ l(:button_delete), {:controller => 'issues',:action => 'delete_journal', :id => issue.id,:journal_id=>reply.id}, :method => :get, - :remote=>true, :class => 'fr newsGrey mr10', :data => {:confirm => l(:text_are_you_sure)}, :title => l(:button_delete) @@ -73,9 +72,9 @@
    - <%= render :partial => 'attachments/issue_reply', :locals => {:container => @issue} %> + <%= render :partial => 'attachments/issue_reply', :locals => {:container => @jour.nil? ? @issue : @jour} %>
    - +
    <% end %> diff --git a/app/views/issues/_issue_reply_ke_form.html.erb b/app/views/issues/_issue_reply_ke_form.html.erb index 7fbb0d191..87b599aa3 100644 --- a/app/views/issues/_issue_reply_ke_form.html.erb +++ b/app/views/issues/_issue_reply_ke_form.html.erb @@ -7,7 +7,7 @@
    <% if User.current.logged? %>
    - <%= form_for('new_form',:url => add_reply_issue_path(@issue.id),:method => "post", :remote => true) do |f|%> + <%= form_for('new_form',:url => add_reply_issue_path(@issue.id),:method => "post") do |f|%> <%#= kindeditor_tag :notes,"",:height=>"33",:minHeight=>"33",:editor_id=>"issues_reply_editor"%> diff --git a/app/views/issues/add_journal.js.erb b/app/views/issues/add_journal.js.erb index 21519d5a1..838e2d83d 100644 --- a/app/views/issues/add_journal.js.erb +++ b/app/views/issues/add_journal.js.erb @@ -1,8 +1,9 @@ <% if @issue_id %> //issue详情中回复 $("#reply_div_<%= @issue_id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => Issue.find( @issue_id),:replies_all_i=>0}) %>"); $("#div_issue_attachment_<%=@issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_attachments', :locals => {:issue => Issue.find( @issue_id)}) %>"); - $("#issue_edit").replaceWith('<%= escape_javascript(render :partial => 'issues/edit') %>') - sd_create_editor_from_data(<%= @issue.id%>, null, "100%", "<%=@issue.class.name%>"); + $("#issue_detail_show").html('<%= escape_javascript(render :partial => 'issues/detail') %>') + $("#issue_edit_show").html('<%= escape_javascript(render :partial => 'issues/edit') %>') + sd_create_editor_from_data(<%= @issue.id %>, null, "100%", "<%= @issue.class.name %>"); issue_desc_editor = KindEditor.create('#issue_description', {"width":"85%", "resizeType":0, diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index 67bb4d59d..13642c0ca 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -15,7 +15,7 @@ } }); -
    +
    问题跟踪
    @@ -23,8 +23,12 @@
    +
    <%= render :partial => 'issues/detail'%> +
    +
    <%= render :partial => 'issues/edit'%> +
    diff --git a/app/views/projects/_friend_group.html.erb b/app/views/projects/_friend_group.html.erb index feb4fb3ac..d50f96f22 100644 --- a/app/views/projects/_friend_group.html.erb +++ b/app/views/projects/_friend_group.html.erb @@ -22,7 +22,7 @@ <%= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %> <% end %> <% if User.current.member_of?(@project) %> - <%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %> + <%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml105" %> <% end %>
    <% end %> \ No newline at end of file diff --git a/app/views/projects/_project_news.html.erb b/app/views/projects/_project_news.html.erb index 2d498e827..e751e16ae 100644 --- a/app/views/projects/_project_news.html.erb +++ b/app/views/projects/_project_news.html.erb @@ -32,6 +32,25 @@
    <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
    + <% if User.current.logged? %> +
    +
      +
    • + <% if User.current.logged? %> +
        +
      • <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'news')") %>
      • +
      • + <%= link_to(l(:button_edit), {:controller => 'news', :action => 'edit', :id => activity}, :class => 'postOptionLink') if activity.author == User.current %> +
      • +
      • + <%= delete_link(news_path(activity), :data => {:confirm => l(:text_are_you_sure)}, :class => 'postOptionLink') if activity.author == User.current %> +
      • +
      + <% end %> +
    • +
    +
    + <% end %>
    diff --git a/app/views/projects/_research_team.html.erb b/app/views/projects/_research_team.html.erb index 7c8d80c59..1d2debdfe 100644 --- a/app/views/projects/_research_team.html.erb +++ b/app/views/projects/_research_team.html.erb @@ -33,7 +33,7 @@ <%= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %> <% end %> <% if User.current.member_of?(@project) %> - <%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %> + <%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml105" %> <% end %>
    <% end%> diff --git a/app/views/projects/settings/_new_versions.html.erb b/app/views/projects/settings/_new_versions.html.erb index 557025eaa..68d35f9af 100644 --- a/app/views/projects/settings/_new_versions.html.erb +++ b/app/views/projects/settings/_new_versions.html.erb @@ -73,7 +73,7 @@
  • - + <%= f.text_field :effective_date, :size => 10, :readonly => true,:class=>" fl" %> <%= calendar_for('version_effective_date') %>
  • diff --git a/app/views/quality_analysis/_result_list.html.erb b/app/views/quality_analysis/_result_list.html.erb index 3e2a7d373..d27ef6812 100644 --- a/app/views/quality_analysis/_result_list.html.erb +++ b/app/views/quality_analysis/_result_list.html.erb @@ -10,7 +10,7 @@
  • 分支
  • 语言
  • 路径
  • -
  • 编辑
  • +
  • @@ -21,16 +21,17 @@ - <% if User.current.try(:login) == qa.author_login %> + <% if User.current.try(:login) == qa.author_login || User.current.admin? || is_project_manager?(User.current.id, @project.id) %>
  • - <%=link_to "编辑", edit_project_quality_analysi_path(qa, :project_id => @project.id), :remote => true, :class => "fontBlue2" %> + <%=link_to "编辑", edit_project_quality_analysi_path(qa, :project_id => @project.id), :remote => true, :class => "fontBlue2" %> / + <%=link_to "删除", delete_project_quality_analysi_path(qa, :project_id => @project.id), :method => "delete", :confirm => "删除会一并删除分析结果,确定删除吗?", :class => "fontBlue2" %>
  • - <% else %> -
  • 编辑
  • - <% end %> + <% end %>
    <% end %> +<% else %> + <%#= 数据为空时候界面,待完善 %> <% end %> diff --git a/app/views/quality_analysis/error_list.html.erb b/app/views/quality_analysis/error_list.html.erb index 84f2777fa..138dc9c08 100644 --- a/app/views/quality_analysis/error_list.html.erb +++ b/app/views/quality_analysis/error_list.html.erb @@ -6,6 +6,6 @@ <% if @build_console_result == false %> 分析超时 <% else %> - <%= h @error_list.output %> + <%= h @error_list.try(:output).html_safe %> <% end %> \ No newline at end of file diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index ccf0e456e..7b3509f2c 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -51,7 +51,7 @@ <% when 5%> 【周报】 <% end %> - <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey ml5" %> + <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey ml5", :target => "_blank" %> <%= get_issue_priority(activity.priority_id)[1] %> diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb index d1bb99296..00075dc8e 100644 --- a/app/views/users/_project_message.html.erb +++ b/app/views/users/_project_message.html.erb @@ -1,4 +1,4 @@ -
    +
    <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> @@ -46,7 +46,7 @@ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
    <% if User.current.logged? %> -