<%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname +
@@ -452,7 +490,8 @@
<%= User.current.show_name %>老师您好!
- <%= ma.course_message.user.show_name%><%= ma.course_message.user.allowed_to?(:as_teacher, ma.course)?"老师":"同学"%>回复了您的作品评论。详情如下:
+ <%= User.find(ma.course_message.user).show_name %>
+ <%= ma.course_message.user.allowed_to?(:as_teacher, ma.course)?"老师":"同学"%>回复了您的作品评论。详情如下:
- 回复内容:<%= ma.course_message.notes %>
diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb
index 5a1cecfb6..71b051a30 100644
--- a/app/views/users/_user_message_forge.html.erb
+++ b/app/views/users/_user_message_forge.html.erb
@@ -162,7 +162,7 @@
<% if ma.forge_message_type == "Message" %>
- <%=link_to image_tag(url_to_avatar(ma.forge_message.author), :width => "30", :height => "30"), user_path(ma.forge_message.author), :target => '_blank' %>
- - <%=link_to User.find(ma.forge_message.user_id).show_name, user_path(ma.forge_message.author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
+
- <%=link_to User.find(ma.forge_message.author).show_name, user_path(ma.forge_message.author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
"><%= ma.forge_message.parent_id.nil? ? "发布了项目帖子:" : "评论了项目帖子:" %>
-
<%= link_to ma.forge_message.subject, board_message_path(ma.forge_message.board_id, ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
@@ -181,7 +181,7 @@
-
- <%=link_to User.find(ma.forge_message.user_id).show_name, user_path(ma.forge_message.author),
+ <%=link_to User.find(ma.forge_message.author).show_name, user_path(ma.forge_message.author),
:class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
">评论了新闻:
diff --git a/db/migrate/20161128030405_delete_error_message_all_and_org_message.rb b/db/migrate/20161128030405_delete_error_message_all_and_org_message.rb
new file mode 100644
index 000000000..ef666a73e
--- /dev/null
+++ b/db/migrate/20161128030405_delete_error_message_all_and_org_message.rb
@@ -0,0 +1,9 @@
+class DeleteErrorMessageAllAndOrgMessage < ActiveRecord::Migration
+ def up
+ MessageAll.where("message_type = 'OrgMessage' and message_id in(15, 17, 18, 19, 170, 172, 173)").destroy_all
+ OrgMessage.where("organization_id in (30, 82)").destroy_all
+ end
+
+ def down
+ end
+end
From 2c664dcd212098248609c5e86812d7116aa3e67c Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Mon, 28 Nov 2016 15:32:02 +0800
Subject: [PATCH 2/5] =?UTF-8?q?=E6=88=91=E7=9A=84issue=E5=AF=BC=E5=87=BA?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=88=E6=9C=AA=E5=AE=8C=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/users_controller.rb | 8 ++++++++
app/views/users/_all_issue_list.html.erb | 3 ++-
app/views/users/user_issues.html.erb | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index aebc82b14..f74a46e93 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -127,6 +127,10 @@ class UsersController < ApplicationController
@issues_author_count = Issue.where("author_id =? and subject like ?", @user.id, "%#{@subject}%").count
@issue_open_count = Issue.where(" (author_id =? or assigned_to_id =?) and status_id in (1,2,3,4,6)", (author_id ? author_id : @user.id) , @user).count
@issue_close_count = Issue.where("(author_id =? or assigned_to_id =?) and status_id = 5", (author_id ? author_id : @user.id) , @user.id).count
+
+ # 导出excel的issues
+ @excel_issues = @issues
+
@issue_count = @issues.count
@limit = 10
@is_remote = true
@@ -135,6 +139,10 @@ class UsersController < ApplicationController
@issues = paginateHelper @issues, @limit
respond_to do |format|
format.html{render :layout => 'static_base'}
+ format.xls{
+ filename = "我的_#{l(:label_issue_list_xls)}.xls"
+ send_data(issue_list_xls(@excel_issues), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
+ }
format.api
format.js
end
diff --git a/app/views/users/_all_issue_list.html.erb b/app/views/users/_all_issue_list.html.erb
index cc33fc95d..6ddb571aa 100644
--- a/app/views/users/_all_issue_list.html.erb
+++ b/app/views/users/_all_issue_list.html.erb
@@ -10,7 +10,8 @@
- 导出EXCEL
+
+ <%= link_to "导出EXCEL", user_issues_user_path(:format => 'xls'), :class => "hw_btn_blue ml10 mt10 mb10" %>
diff --git a/app/views/users/user_issues.html.erb b/app/views/users/user_issues.html.erb
index e211c84b4..4ee8d736d 100644
--- a/app/views/users/user_issues.html.erb
+++ b/app/views/users/user_issues.html.erb
@@ -269,7 +269,7 @@
<%= l(:label_no_data) %>
<% else %>
- <%= render :partial => 'users/all_issue_list', :locals => {:issues => @issues, :issue_pages => @issue_pages,:issue_count => @issue_count, :subject => @subject } %>
+ <%= render :partial => 'users/all_issue_list', :locals => {:issues => @issues, :excel_issues => @excel_issues, :issue_pages => @issue_pages,:issue_count => @issue_count, :subject => @subject } %>
<% end %>
From 2cbc7bca3311a7693ebe0b8f04669ea19cd74796 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Mon, 28 Nov 2016 16:11:52 +0800
Subject: [PATCH 3/5] =?UTF-8?q?=E6=88=91=E7=9A=84Issue=E5=AF=BC=E5=87=BA?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/users_controller.rb | 79 ++++++++++++------------
app/views/users/_all_issue_list.html.erb | 3 +-
app/views/users/user_issues.html.erb | 7 ++-
3 files changed, 46 insertions(+), 43 deletions(-)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index f74a46e93..86c04e9e4 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -90,53 +90,54 @@ class UsersController < ApplicationController
# order 排序条件
# subject 主题:搜索用(注意:搜索和列表调用同一方法,通过参数或者remote区分)
def user_issues
- @subject = params[:subject]
- # author_id = params[:author_id]
- params[:assigned_to_id].to_i == 0 ? @assigned_to = nil : @assigned_to = params[:assigned_to_id].to_i
- params[:author_id].to_i == 0 ? author_id = nil : author_id = params[:author_id].to_i
- params[:project_id].to_i == 0 ? @project_id = nil : @project_id = params[:project_id]
- if @project_id.nil?
- if @assigned_to.nil?
- if author_id.nil?
- @issues = Issue.where("(author_id =? or assigned_to_id =? ) and subject like ?",
- @user.id , @user.id, "%#{@subject}%").order('updated_on desc')
+ @subject = params[:subject]
+ # author_id = params[:author_id]
+ params[:assigned_to_id].to_i == 0 ? @assigned_to = nil : @assigned_to = params[:assigned_to_id].to_i
+ params[:author_id].to_i == 0 ? author_id = nil : author_id = params[:author_id].to_i
+ params[:project_id].to_i == 0 ? @project_id = nil : @project_id = params[:project_id]
+ if @project_id.nil?
+ if @assigned_to.nil?
+ if author_id.nil?
+ @issues = Issue.where("(author_id =? or assigned_to_id =? ) and subject like ?",
+ @user.id , @user.id, "%#{@subject}%").order('updated_on desc')
+ else
+ @issues = Issue.where("author_id =? and subject like ?",
+ author_id , "%#{@subject}%").order('updated_on desc')
+ end
else
- @issues = Issue.where("author_id =? and subject like ?",
- author_id , "%#{@subject}%").order('updated_on desc')
+ @issues = Issue.where("assigned_to_id =? and subject like ?", @assigned_to, "%#{@subject}%").order('updated_on desc')
end
- else
- @issues = Issue.where("assigned_to_id =? and subject like ?", @assigned_to, "%#{@subject}%").order('updated_on desc')
- end
- else
- if @assigned_to.nil?
- if author_id.nil?
- @issues = Issue.where("(author_id =? or assigned_to_id =? ) and project_id=? and subject like ?",
- (author_id ? author_id : @user.id) , @user.id, @project_id, "%#{@subject}%").order('updated_on desc')
+ else
+ if @assigned_to.nil?
+ if author_id.nil?
+ @issues = Issue.where("(author_id =? or assigned_to_id =? ) and project_id=? and subject like ?",
+ (author_id ? author_id : @user.id) , @user.id, @project_id, "%#{@subject}%").order('updated_on desc')
+ else
+ @issues = Issue.where("author_id =? and project_id=? and subject like ?",
+ author_id , @project_id, "%#{@subject}%").order('updated_on desc')
+ end
else
- @issues = Issue.where("author_id =? and project_id=? and subject like ?",
- author_id , @project_id, "%#{@subject}%").order('updated_on desc')
+ @issues = Issue.where("assigned_to_id =? and project_id=? and subject like ?",
+ @assigned_to, @project_id, "%#{@subject}%").order('updated_on desc')
end
- else
- @issues = Issue.where("assigned_to_id =? and project_id=? and subject like ?",
- @assigned_to, @project_id, "%#{@subject}%").order('updated_on desc')
end
- end
- @issues_filter = Issue.where("author_id =? or assigned_to_id =?", (author_id ? author_id : @user.id) , @user).order('updated_on desc')
- @issues_assigned_count = Issue.where("assigned_to_id =? and subject like ?", @user.id, "%#{@subject}%").count
- @issues_author_count = Issue.where("author_id =? and subject like ?", @user.id, "%#{@subject}%").count
- @issue_open_count = Issue.where(" (author_id =? or assigned_to_id =?) and status_id in (1,2,3,4,6)", (author_id ? author_id : @user.id) , @user).count
- @issue_close_count = Issue.where("(author_id =? or assigned_to_id =?) and status_id = 5", (author_id ? author_id : @user.id) , @user.id).count
+ @issues_filter = Issue.where("author_id =? or assigned_to_id =?", (author_id ? author_id : @user.id) , @user).order('updated_on desc')
+ @issues_assigned_count = Issue.where("assigned_to_id =? and subject like ?", @user.id, "%#{@subject}%").count
+ @issues_author_count = Issue.where("author_id =? and subject like ?", @user.id, "%#{@subject}%").count
+ @issue_open_count = Issue.where(" (author_id =? or assigned_to_id =?) and status_id in (1,2,3,4,6)", (author_id ? author_id : @user.id) , @user).count
+ @issue_close_count = Issue.where("(author_id =? or assigned_to_id =?) and status_id = 5", (author_id ? author_id : @user.id) , @user.id).count
- # 导出excel的issues
- @excel_issues = @issues
+ # 导出excel的issues
+ @excel_issues = @issues
+
+ @issue_count = @issues.count
+ @limit = 10
+ @is_remote = true
+ @issue_pages = Paginator.new @issue_count, @limit, params['page'] || 1
+ @offset ||= @issue_pages.offset
+ @issues = paginateHelper @issues, @limit
- @issue_count = @issues.count
- @limit = 10
- @is_remote = true
- @issue_pages = Paginator.new @issue_count, @limit, params['page'] || 1
- @offset ||= @issue_pages.offset
- @issues = paginateHelper @issues, @limit
respond_to do |format|
format.html{render :layout => 'static_base'}
format.xls{
diff --git a/app/views/users/_all_issue_list.html.erb b/app/views/users/_all_issue_list.html.erb
index 6ddb571aa..9d380fd68 100644
--- a/app/views/users/_all_issue_list.html.erb
+++ b/app/views/users/_all_issue_list.html.erb
@@ -11,7 +11,8 @@
- <%= link_to "导出EXCEL", user_issues_user_path(:format => 'xls'), :class => "hw_btn_blue ml10 mt10 mb10" %>
+ <%= link_to "导出EXCEL", user_issues_user_path(:format => 'xls'), :class => "hw_btn_blue ml10 mt10 mb10", :id=>"sendexcel",
+ :onclick=> "remote_function_export('#{User.current}')"%>
diff --git a/app/views/users/user_issues.html.erb b/app/views/users/user_issues.html.erb
index 4ee8d736d..b3aef1a09 100644
--- a/app/views/users/user_issues.html.erb
+++ b/app/views/users/user_issues.html.erb
@@ -81,7 +81,8 @@
$("#issue_query_form").submit();
}
- function remote_function_export(project_id) {
+ function remote_function_export(user) {
+ var project_id = $("#project_id").attr("value");
var tracker_id = $("#tracker_id").attr("value");
var subject = $("#v_subject").attr("value");
var assigned_to_id = $("#assigned_to_id").attr("value");
@@ -93,7 +94,7 @@
var priority_id = $("#priority_id").attr("value");
var issue_create_date_start = $("#issue_date_start_issue_export").attr("value");
var issue_create_date_end = $("#issue_date_end_issue_export").attr("value");
- $("#sendexcel").attr("href","/projects/"+project_id+"/issues.xls?export=true&set_filter=1&tracker_id="+tracker_id+"&assigned_to_id="+assigned_to_id+"&fixed_version_id="+fixed_version_id+"&status_id="+status_id+"&done_ratio="+done_ratio+"&test="+test+"&author_id="+author_id+"&subject="+subject+"&issue_create_date_start="+issue_create_date_start+"&issue_create_date_end="+issue_create_date_end+"&priority_id="+priority_id);
+ $("#sendexcel").attr("href","/users/"+user+"/user_issues.xls?project_id="+project_id+"&tracker_id="+tracker_id+"&assigned_to_id="+assigned_to_id+"&fixed_version_id="+fixed_version_id+"&status_id="+status_id+"&done_ratio="+done_ratio+"&test="+test+"&author_id="+author_id+"&subject="+subject+"&issue_create_date_start="+issue_create_date_start+"&issue_create_date_end="+issue_create_date_end+"&priority_id="+priority_id);
///projects/1811/issues.xls?export=true&set_filter=1
}
function EnterPress(e){
@@ -225,7 +226,7 @@
-->
<%= select( :project, :project_id, options_for_issue_project_list(@issues_filter),
{ :include_blank => false,:selected => @project_id ? @project_id : 0 },
- { :onchange => "remote_function();add_style();",:id => "proeject_id", :name => "project_id", :class => "fl", :style=>"width: 80px; margin-right:20px;"}
+ { :onchange => "remote_function();add_style();",:id => "project_id", :name => "project_id", :class => "fl", :style=>"width: 80px; margin-right:20px;"}
)%>
diff --git a/app/views/users/user_issues.html.erb b/app/views/users/user_issues.html.erb
index b3aef1a09..7284f3769 100644
--- a/app/views/users/user_issues.html.erb
+++ b/app/views/users/user_issues.html.erb
@@ -113,6 +113,7 @@
$("select[id='assigned_to_id']").find(assign).attr("selected", "selected");
$("select[id='author_id']").val('');
$("select[id='priority_id']").val('');
+ $("select[id='project_id']").val('');
$("select[id='tracker_id']").val('');
$("select[id='fixed_version_id']").val('');
$("select[id='status_id']").val('');
@@ -138,6 +139,7 @@
$("select[id='author_id']").find(user).attr("selected", "selected");
$("select[id='assigned_to_id']").val('');
$("select[id='priority_id']").val('');
+ $("select[id='project_id']").val('');
$("select[id='tracker_id']").val('');
$("select[id='fixed_version_id']").val('');
$("select[id='status_id']").val('');
@@ -270,7 +272,7 @@
<%= l(:label_no_data) %>
<% else %>
- <%= render :partial => 'users/all_issue_list', :locals => {:issues => @issues, :excel_issues => @excel_issues, :issue_pages => @issue_pages,:issue_count => @issue_count, :subject => @subject } %>
+ <%= render :partial => 'users/all_issue_list', :locals => {:issues => @issues, :issue_pages => @issue_pages,:issue_count => @issue_count, :subject => @subject } %>
<% end %>
From e4d43cc16379c86df6978e3177c083d5765515c6 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 29 Nov 2016 12:25:15 +0800
Subject: [PATCH 5/5] =?UTF-8?q?=E9=A1=B9=E7=9B=AEpull=20request=20?=
=?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=B6=88=E6=81=AF=E6=A1=86=E6=9E=B6=E6=90=AD?=
=?UTF-8?q?=E5=BB=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/pull_requests_controller.rb | 12 +++++++++++
app/models/forge_message.rb | 2 +-
app/models/pull_request.rb | 5 ++++-
app/views/pull_requests/_form.html.erb | 2 +-
app/views/users/_user_message_forge.html.erb | 20 +++++++++++++++++++
...61129032534_add_status_to_pull_requests.rb | 5 +++++
...9033440_add_project_id_to_pull_requests.rb | 5 +++++
7 files changed, 48 insertions(+), 3 deletions(-)
create mode 100644 db/migrate/20161129032534_add_status_to_pull_requests.rb
create mode 100644 db/migrate/20161129033440_add_project_id_to_pull_requests.rb
diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb
index e4a2dc9df..ff74eb9f3 100644
--- a/app/controllers/pull_requests_controller.rb
+++ b/app/controllers/pull_requests_controller.rb
@@ -97,8 +97,16 @@ class PullRequestsController < ApplicationController
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id)
@fork_project_name = Project.find(params[:target_project_id]).try(:name)
@fork_pr_message = true if @fork_project_name
+ # 发送消息
+ send_message(User.current.id, target_project_id, title)
+ # 创建Trustie数据
+ PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => target_project_id)
else
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch)
+ # 发送消息
+ send_message(User.current.id, @project.id, title)
+ # 创建Trustie数据
+ PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => @project.id)
respond_to do |format|
format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)}
end
@@ -287,6 +295,10 @@ class PullRequestsController < ApplicationController
end
private
+ def send_message user_id, project_id, title
+ self.forge_acts << ForgeMessage.new(:user_id => user_id, :project_id => project_id, :title => title)
+ end
+
def authorize_logged
if !User.current.logged?
redirect_to signin_path
diff --git a/app/models/forge_message.rb b/app/models/forge_message.rb
index 8bf754719..bc514025e 100644
--- a/app/models/forge_message.rb
+++ b/app/models/forge_message.rb
@@ -6,7 +6,7 @@ class ForgeMessage < ActiveRecord::Base
belongs_to :forge_message ,:polymorphic => true
belongs_to :project
belongs_to :user
- has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
+ has_many :message_alls, :class_name => 'MessageAll', :as => :message, :dependent => :destroy
validates :user_id,presence: true
validates :project_id,presence: true
diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb
index f40397cf0..ec13ff16b 100644
--- a/app/models/pull_request.rb
+++ b/app/models/pull_request.rb
@@ -1,4 +1,7 @@
class PullRequest < ActiveRecord::Base
- attr_accessible :gpid, :pull_request_id, :user_id
+ # status 1:创建 2:接受 3:重新打开 4:关闭
+ attr_accessible :gpid, :pull_request_id, :user_id, :status
validates_uniqueness_of :pull_request_id
+
+ has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
end
diff --git a/app/views/pull_requests/_form.html.erb b/app/views/pull_requests/_form.html.erb
index d76c3e8a8..0aa2a1177 100644
--- a/app/views/pull_requests/_form.html.erb
+++ b/app/views/pull_requests/_form.html.erb
@@ -112,4 +112,4 @@
var defaultBranch = $("#targetBranch option:first-child").val();
$("#targetBranch").val(defaultBranch);
});
-
\ No newline at end of file
+
diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb
index 71b051a30..00b141d31 100644
--- a/app/views/users/_user_message_forge.html.erb
+++ b/app/views/users/_user_message_forge.html.erb
@@ -194,4 +194,24 @@