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 @@
* <%= l(:field_status) %>:
- <% if @issue.safe_attribute?('status_id') && @allowed_statuses.present? %>
+ <%# if @issue.safe_attribute?('status_id') && @allowed_statuses.present? %>
<%= f.select :status_id, (@allowed_statuses.collect { |p| [p.name, p.id] }),
{:no_label => true},
# ajax 刷新
#:onchange => "updateIssueFrom('#{escape_javascript project_issue_form_path(@project, :id => @issue, :format => 'js')}')",
:class => "w150" %>
- <% else %>
- <%= h(@issue.status.name) %>
- <% end %>
+ <%# else %>
+ <%#= h(@issue.status.name) %>
+ <%# end %>
diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb
index 8b313a2ef..e2b6a0a17 100644
--- a/app/views/issues/_form.html.erb
+++ b/app/views/issues/_form.html.erb
@@ -58,13 +58,6 @@
- <%# if @copy_from && @copy_from.attachments.any? %>
-
-
-
-
- <%# end %>
<% if @copy_from && !@copy_from.leaf? %>
<%= l(:label_copy_subtasks) %>
@@ -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 @@
}
});
-
<% 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 @@
- <%=l(:label_date)%>:
+ <%=l(:field_deadline)%>:
<%= 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 @@
<%= qa.branch %>
<%= qa.language %>
<%= qa.path %>
- <% 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? %>
-
+
diff --git a/app/views/users/_user_message_system.html.erb b/app/views/users/_user_message_system.html.erb
index 13967dce1..6bc8f28f3 100644
--- a/app/views/users/_user_message_system.html.erb
+++ b/app/views/users/_user_message_system.html.erb
@@ -10,7 +10,7 @@
【系统消息】
- <%= link_to ma.subject.blank? ? (ma.content.nil? ? message_content(ma.description) : message_content(ma.content)) : ma.subject, user_system_messages_path(User.current),
+ <%= link_to ma.subject.blank? ? (ma.content.nil? ? ma.description.html_safe : ma.content.html_safe) : ma.subject, user_system_messages_path(User.current, :anchor => "position_#{ma.id}"),
:id => "content_link_#{ma.id}", :target => '_blank' %>
diff --git a/app/views/users/_user_message_userfeedaback.html.erb b/app/views/users/_user_message_userfeedaback.html.erb
index 1c33d9de4..bfdbeb9f3 100644
--- a/app/views/users/_user_message_userfeedaback.html.erb
+++ b/app/views/users/_user_message_userfeedaback.html.erb
@@ -9,9 +9,7 @@
"><%= ma.journals_for_message.reply_id == 0 ? "给你留言了:" : "回复了你的留言:" %>
- <%= link_to message_content(ma.journals_for_message.notes), feedback_path(ma.journals_for_message.jour_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank'%>
-
-
+ <%= link_to ma.journals_for_message.notes.gsub("","").gsub("
","").gsub(" ","").html_safe, feedback_path(ma.journals_for_message.jour_id, :anchor => "user_activity_#{ma.journals_for_message.id}"), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank'%>
<% if ma.journals_for_message.reply_id == 0 %>
diff --git a/app/views/users/user_system_messages.html.erb b/app/views/users/user_system_messages.html.erb
index 57c6eb573..9c461cb4a 100644
--- a/app/views/users/user_system_messages.html.erb
+++ b/app/views/users/user_system_messages.html.erb
@@ -1,7 +1,7 @@
<%= render :partial => 'users/selector_for_messages'%>
<% @sytem_messages.each do |system_message| %>
-
+
<%= image_tag("/images/trustie_logo1.png", :width => "50", :height => "50") %>
diff --git a/config/routes.rb b/config/routes.rb
index 539d78df3..bcfb6de98 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -790,12 +790,13 @@ RedmineApp::Application.routes.draw do
end
end
- resources :quality_analysis, :only => [:index, :create, :edit, :update] do
+ resources :quality_analysis, :only => [:index, :create, :edit, :update, :delete] do
collection do
end
member do
match 'update_jenkins_job'
match 'edit'
+ match 'delete'
match 'create'
get 'error_list'
end
diff --git a/lib/tasks/update_homework.rake b/lib/tasks/update_homework.rake
index d97004c8c..33bcc2231 100644
--- a/lib/tasks/update_homework.rake
+++ b/lib/tasks/update_homework.rake
@@ -15,11 +15,9 @@ namespace :update_homework do
unless student_works.nil?
student_works.each do |s|
project = Project.find s.project_id
- unless project.nil? && project.gpid.blank?
+ if !project.nil? && !project.gpid.blank?
project_time=project.updated_on
project_time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last
- puts "the time is =========================> #{time}"
- puts "the project_time is =========================> #{project_time}"
if time.strftime('%Y-%m-%d %H:%M:%S') < project_time.strftime('%Y-%m-%d %H:%M:%S')
#if format_time(time) < format_time(project_time)
time = project_time
@@ -31,9 +29,6 @@ namespace :update_homework do
changesets = g.commits(project.gpid, :ref_name => default_branch)
changesets_latest_coimmit = changesets[0]
unless changesets[0].blank?
- puts "the time is =========================> #{time}"
- puts "the changesets_latest_coimmit is =========================> #{changesets_latest_coimmit.created_at}"
- puts "the distance time is =========================> #{changesets_latest_coimmit.created_at.to_time > Time.now}"
if time.strftime('%Y-%m-%d %H:%M:%S') < changesets_latest_coimmit.created_at.to_time.strftime('%Y-%m-%d %H:%M:%S')
#if format_time(time) < format_time(changesets_latest_coimmit.created_at)
time = changesets_latest_coimmit.created_at.to_time
diff --git a/lib/trustie/gitlab/helper.rb b/lib/trustie/gitlab/helper.rb
index c9cbcee26..615bb6ac3 100644
--- a/lib/trustie/gitlab/helper.rb
+++ b/lib/trustie/gitlab/helper.rb
@@ -60,8 +60,6 @@ module Trustie
def get_gitlab_role m
case m.roles.first.position
- when 1,2
- GUEST
when 5
REPORTER
when 4