From 3c1de111c65d4054918449c4eb3c9de743cf3fd4 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 19 Dec 2016 15:02:40 +0800 Subject: [PATCH 01/12] =?UTF-8?q?issue=E5=9B=9E=E5=A4=8D=E5=B1=80=E9=83=A8?= =?UTF-8?q?=E5=88=B7=E6=96=B0=EF=BC=88=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E3=80=81=E7=94=A8=E6=88=B7=E5=8A=A8=E6=80=81=E3=80=82issue?= =?UTF-8?q?=E8=AF=A6=E6=83=85=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 12 ++++++++---- app/views/issues/_issue_replies.html.erb | 2 +- app/views/issues/_jounal_refresh.js.erb | 13 +++---------- app/views/issues/add_journal.js.erb | 7 ++----- app/views/issues/show.js.erb | 19 +++++++++++++++++++ 5 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 app/views/issues/show.js.erb diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index dd2aec552..fa0f2828d 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -261,6 +261,7 @@ class IssuesController < ApplicationController retrieve_previous_and_next_issue_ids render :template => 'issues/show', :layout => @project_base_tag#by young } + format.js format.api format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } format.pdf { @@ -585,12 +586,15 @@ class IssuesController < ApplicationController 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] - @issue_id = params[:issue_id] - end @priorities = IssuePriority.active + respond_to do |format| - format.js + # Issue详情单独处理 + if params[:is_issue_show] + format.js{redirect_to issue_path(@issue)} + else + format.js + end end end end diff --git a/app/views/issues/_issue_replies.html.erb b/app/views/issues/_issue_replies.html.erb index 7b22f85f3..6f4434a4c 100644 --- a/app/views/issues/_issue_replies.html.erb +++ b/app/views/issues/_issue_replies.html.erb @@ -64,7 +64,7 @@
<% if User.current.logged? %>
- <%= form_for('new_form', :url => add_journal_issue_path(@issue.id), :method => "post", :remote => true) do |f| %> + <%= form_for('new_form', :url => add_journal_issue_path(@issue.id, :is_issue_show => true), :method => "post", :remote => true) do |f| %>
diff --git a/app/views/issues/_jounal_refresh.js.erb b/app/views/issues/_jounal_refresh.js.erb index 5ccbf69d2..33dd364e7 100644 --- a/app/views/issues/_jounal_refresh.js.erb +++ b/app/views/issues/_jounal_refresh.js.erb @@ -1,10 +1,4 @@ -/* $("#reply_div_<%#= @issue.id %>").html("<%#= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue}) %>"); -$("#issue_detail_show").html('<%#= escape_javascript(render :partial => 'issues/detail') %>'); -$("#issue_edit_show").html('<%#= escape_javascript(render :partial => 'issues/edit') %>'); -$("#div_issue_attachment_<%#=@issue.id %>").html("<%#= escape_javascript(render :partial => 'issues/issue_attachments', :locals => {:issue => @issue}) %>"); -sd_create_editor_from_data(<%#= @issue.id %>, null, "100%", "<%#= @issue.class.name %>");*/ - -location.reload(); +$("#div_issue_attachment_<%=@issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_attachments', :locals => {:issue => @issue}) %>"); issue_desc_editor = KindEditor.create('#issue_description', {"width":"85%", "resizeType":0, @@ -18,6 +12,5 @@ issue_desc_editor = KindEditor.create('#issue_description', "allowFileManager":true, "uploadJson":"/kindeditor/upload", "fileManagerJson":"/kindeditor/filemanager"}); -// $("#issue_test_<%#= @issue.id %>").html("<%#= escape_javascript(render :partial => 'issues/edit', :locals => {:issue => Issue.find( @issue_id)}) %>"); -// $(".homepagePostReplyBannerCount").html('<%#= escape_javascript(render :partial => 'issues/issue_reply_banner') %>'); -// sd_create_editor_from_data(<%#= @issue.id%>, null, "100%","<%#= @issue.class.name %>"); \ No newline at end of file +$(".homepagePostReplyBannerCount").html('<%= escape_javascript(render :partial => 'issues/issue_reply_banner') %>'); +sd_create_editor_from_data(<%= @issue.id%>, null, "100%","<%= @issue.class.name %>"); \ No newline at end of file diff --git a/app/views/issues/add_journal.js.erb b/app/views/issues/add_journal.js.erb index 3a34647e8..62a460247 100644 --- a/app/views/issues/add_journal.js.erb +++ b/app/views/issues/add_journal.js.erb @@ -1,6 +1,3 @@ -<% if @issue_id %> //issue详情中回复 -<%= render "jounal_refresh" %> -<%else%> <% if params[:is_project] %> $("#div_user_issue_reply_<%=@user_activity_id %>").html("<%= escape_javascript(render :partial => 'projects/project_issue_reply', :locals => {:activity => @issue, :user_activity_id => @user_activity_id}) %>"); <% else %> @@ -8,6 +5,6 @@ $("#div_user_issue_reply_<%=@user_activity_id %>").html("<%= escape_javascript(r <% end %> sd_create_editor_from_data(<%= @user_activity_id %>, null, "100%", "UserActivity"); -//init_activity_KindEditor_data(<%= @user_activity_id %>,"","87%", 'UserActivity'); +//init_activity_KindEditor_data(<%#= @user_activity_id %>,"","87%", 'UserActivity'); // sd_create_editor_from_data(<%#= @issue.id%>, null, "100%"); -<%end %> + diff --git a/app/views/issues/show.js.erb b/app/views/issues/show.js.erb new file mode 100644 index 000000000..7d7b116a0 --- /dev/null +++ b/app/views/issues/show.js.erb @@ -0,0 +1,19 @@ +$("#div_user_issue_reply_<%=@user_activity_id %>").html("<%= escape_javascript(render :partial => 'projects/project_issue_reply', :locals => {:activity => @issue, :user_activity_id => @user_activity_id}) %>"); + +$("#reply_div_<%= @issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue}) %>"); +$("#div_issue_attachment_<%=@issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_attachments', :locals => {:issue => @issue}) %>"); +issue_desc_editor = KindEditor.create('#issue_description', + {"width":"85%", + "resizeType":0, + "no_label":true, + "at_id":<%= @issue.project_id%>, + "at_type":"Project", + "autoHeightMode":true, + "afterCreate":"eval(function(){ if(typeof enablePasteImg ==='function'){enablePasteImg(self);};if(typeof enableAt ==='function'){enableAt(self, \"<%=@issue.project_id %>\", 'Project');}; this.loadPlugin('autoheight')})", + "emotionsBasePath":'<%= Setting.host_name%>', + "height":300, + "allowFileManager":true, + "uploadJson":"/kindeditor/upload", + "fileManagerJson":"/kindeditor/filemanager"}); +$(".homepagePostReplyBannerCount").html('<%= escape_javascript(render :partial => 'issues/issue_reply_banner') %>'); +sd_create_editor_from_data(<%= @issue.id%>, null, "100%","<%= @issue.class.name %>"); \ No newline at end of file From 1caf8d9935c16ef8f654acb93dec55b3e0b1bde6 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 19 Dec 2016 15:16:45 +0800 Subject: [PATCH 02/12] =?UTF-8?q?issue=20=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BA=8C=E7=BA=A7=E5=9B=9E=E5=A4=8D=E5=B1=80=E9=83=A8?= =?UTF-8?q?=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 6 +++++- app/views/issues/_issue_replies.html.erb | 4 ++-- app/views/issues/_issue_reply_ke_form.html.erb | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index fa0f2828d..dedb71b8b 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -646,7 +646,11 @@ class IssuesController < ApplicationController update_user_activity(@issue.class,@issue.id) update_forge_activity(@issue.class,@issue.id) respond_to do |format| - format.js + if params[:is_issue_show] + format.js{redirect_to issue_path(@issue)} + else + format.js + end end end end diff --git a/app/views/issues/_issue_replies.html.erb b/app/views/issues/_issue_replies.html.erb index 6f4434a4c..ff6c507c6 100644 --- a/app/views/issues/_issue_replies.html.erb +++ b/app/views/issues/_issue_replies.html.erb @@ -28,7 +28,7 @@ <%= render :partial => "praise_tread/praise", :locals => {:activity => comment, :user_activity_id => comment.id, :type => "reply"} %> - <%= link_to( + <%= link_to( l(:button_reply), {:controller => 'issues', :action => 'reply', :user_id => comment.user_id, :id => issue.id, :journal_id => comment.id}, :remote => true, @@ -36,7 +36,7 @@ :title => l(:button_reply)) %> - <%= link_to( + <%= link_to( l(:button_delete), {:controller => 'issues',:action => 'delete_journal', :id => issue.id,:journal_id=>comment.id}, :method => :get, diff --git a/app/views/issues/_issue_reply_ke_form.html.erb b/app/views/issues/_issue_reply_ke_form.html.erb index bcbdcea4d..6c8f9fd00 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, :is_issue_show => true),:method => "post", :remote => true) do |f|%>
From cc68f33a5a52a804c701573ea035c121a62e5ea6 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 19 Dec 2016 15:29:39 +0800 Subject: [PATCH 03/12] =?UTF-8?q?issue=20=E8=AF=A6=E6=83=85=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 34 ++++++++++++------------ app/views/issues/_issue_replies.html.erb | 3 ++- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index dedb71b8b..6af85e836 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -662,23 +662,23 @@ class IssuesController < ApplicationController # 非动态页面直接刷新,动态页面手动刷新 def delete_journal @is_project = params[:is_project] - @issue = Issue.find(params[:id]) - begin - forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id]) - forge_acts.destroy_all unless forge_acts.empty? - at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id]) - at_message.destroy_all unless at_message.empty? - Journal.delete(params[:journal_id]) - rescue Exception => e - puts e - end - @user_activity_id = params[:user_activity_id] - respond_to do |format| - if @user_activity_id - format.js - else - format.html{ redirect_to issue_url(@issue)} - end + @issue = Issue.find(params[:id]) + begin + forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id]) + forge_acts.destroy_all unless forge_acts.empty? + at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id]) + at_message.destroy_all unless at_message.empty? + Journal.delete(params[:journal_id]) + rescue Exception => e + puts e + end + @user_activity_id = params[:user_activity_id] + respond_to do |format| + if @user_activity_id + format.js + else + format.js{ redirect_to issue_url(@issue)} + end end end diff --git a/app/views/issues/_issue_replies.html.erb b/app/views/issues/_issue_replies.html.erb index ff6c507c6..ff2d7e3a6 100644 --- a/app/views/issues/_issue_replies.html.erb +++ b/app/views/issues/_issue_replies.html.erb @@ -38,8 +38,9 @@ <%= link_to( l(:button_delete), - {:controller => 'issues',:action => 'delete_journal', :id => issue.id,:journal_id=>comment.id}, + {:controller => 'issues',:action => 'delete_journal', :id => issue.id, :journal_id=>comment.id}, :method => :get, + :remote => true, :id => "delete_reply_#{comment.id}", :class => 'fr mr20 undis', :data => {:confirm => l(:text_are_you_sure)}, From b34129e8128c3050c0fe1bc184bfe88f3f3bc5ff Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 19 Dec 2016 15:48:33 +0800 Subject: [PATCH 04/12] =?UTF-8?q?commit=20=E5=8E=86=E5=8F=B2=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E9=A1=B5=E9=9D=A2commit=20id=E9=A2=9C=E8=89=B2=20?= =?UTF-8?q?=E8=93=9D=E8=89=B2->=E6=B5=85=E7=81=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/_commit_details.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/repositories/_commit_details.html.erb b/app/views/repositories/_commit_details.html.erb index 420cac846..a0ef37ce2 100644 --- a/app/views/repositories/_commit_details.html.erb +++ b/app/views/repositories/_commit_details.html.erb @@ -13,6 +13,6 @@
<% end %> <% if params[:action] == "commit_diff" %> - + <% end %>
\ No newline at end of file From a3e3c9d4db420411a2f5075bb9ce6fa217be417c Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 19 Dec 2016 16:36:25 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=B7=BB=E5=8A=A0=E4=BA=8B=E5=8A=A1=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=88=E4=B8=A4=E8=BE=B9=E6=95=B0=E6=8D=AE=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E6=80=A7=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index fc7ec3b48..82cbde56f 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -265,12 +265,23 @@ update @repository.type = 'Repository::Gitlab' @repository.identifier = @repository.identifier.downcase @repository.url = @repository.identifier - if request.post? && @repository.save - s = Trustie::Gitlab::Sync.new - s.create_project(@project, @repository) - redirect_to(:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier)) - else - redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages) + ActiveRecord::Base.transaction do + begin + if request.post? && @repository.save + s = Trustie::Gitlab::Sync.new + s.create_project(@project, @repository) + raise "sync failed" if @project.gpid.blank? + redirect_to(:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier)) + else + redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages) + end + rescue Gitlab::Error::Forbidden => e + @message = l(:label_pull_request_forbidden) + rescue Gitlab::Error::NotFound => e + @message = l(:label_pull_request_notfound) + rescue Exception => e + puts e + end end end end From 05d10e20d1f8e5eb0f5ec81854ffc172cab0c04d Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 19 Dec 2016 17:04:27 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=88=90=E5=91=98=20=E4=BD=BF=E7=94=A8=E4=BA=8B=E5=8A=A1?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 40 +++++++++++++++++---------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 5f0dbda97..029716831 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -151,23 +151,33 @@ class MembersController < ApplicationController project_info = [] if params[:membership] if params[:membership][:user_ids] - attrs = params[:membership].dup - user_ids = attrs.delete(:user_ids) - user_ids.each do |user_id| - members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id) - user_grades << UserGrade.new(:user_id => user_id, :project_id => @project.id) + ActiveRecord::Base.transaction do + begin + attrs = params[:membership].dup + user_ids = attrs.delete(:user_ids) + user_ids.each do |user_id| + members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id) + user_grades << UserGrade.new(:user_id => user_id, :project_id => @project.id) - #给新成员发送加入项目的消息,发送者id放在ForgeMessage的forge_message_id字段中, - #forge_message_type设置为JoinProject - forge_join = ForgeMessage.new(:user_id =>user_id, :forge_message_id=>User.current.id,:project_id => @project.id,:forge_message_type=>"JoinProject", :viewed => false) - forge_join.save - ## added by nie - if (params[:membership][:role_ids]) - role = Role.find(params[:membership][:role_ids][0]) - project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id) if role.allowed_to?(:is_manager) - # ProjectInfo.create(:name => "test", :user_id => 123) + #给新成员发送加入项目的消息,发送者id放在ForgeMessage的forge_message_id字段中, + #forge_message_type设置为JoinProject + forge_join = ForgeMessage.new(:user_id =>user_id, :forge_message_id=>User.current.id,:project_id => @project.id,:forge_message_type=>"JoinProject", :viewed => false) + forge_join.save + ## added by nie + if (params[:membership][:role_ids]) + role = Role.find(params[:membership][:role_ids][0]) + project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id) if role.allowed_to?(:is_manager) + # ProjectInfo.create(:name => "test", :user_id => 123) + end + ## end + end + rescue Gitlab::Error::Forbidden => e + @message = l(:label_pull_request_forbidden) + rescue Gitlab::Error::BadRequest => e + @message = "添加成员失败,可能是你添加的用户名中含有非法字符" + rescue Exception => e + puts e end - ## end end else members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id]) From 7faddc30c56f5cadd1a7847c17d5c3517dcfe448 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 19 Dec 2016 17:08:32 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=88=90=E5=91=98?= =?UTF-8?q?=E7=BC=96=E8=BE=91=20=E6=B7=BB=E5=8A=A0=E4=BA=8B=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 33 +++++++++++++++------------ 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 029716831..ee2487246 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -301,26 +301,29 @@ class MembersController < ApplicationController #增加对课程成员修改的支持 if @project if params[:membership] - @member.role_ids = params[:membership][:role_ids] - - #added by nie - if (params[:membership][:role_ids]) - role = Role.find(params[:membership][:role_ids][0]) - if role.allowed_to?(:is_manager) - @projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id) - @projectInfo.save - else - user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id) - if user_admin.size > 0 - user_admin.each do |user| - user.destroy + ActiveRecord::Base.transaction do + begin + @member.role_ids = params[:membership][:role_ids] + if (params[:membership][:role_ids]) + role = Role.find(params[:membership][:role_ids][0]) + if role.allowed_to?(:is_manager) + @projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id) + @projectInfo.save + else + user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id) + if user_admin.size > 0 + user_admin.each do |user| + user.destroy + end + end end end + @member.save! + rescue Exception => e + puts e end end end - - saved = @member.save respond_to do |format| format.html { redirect_to_settings_in_projects } format.js From d3045550446927ba250b7fda42e5261fd9fed789 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 19 Dec 2016 17:26:56 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E3=80=81=E5=88=A0=E9=99=A4=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=88=90=E5=91=98=20=E6=B7=BB=E5=8A=A0=E4=BA=8B=E5=8A=A1?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 44 +++++++++++++++------------ app/controllers/my_controller.rb | 4 +-- app/services/users_service.rb | 32 ++++++++++--------- 3 files changed, 44 insertions(+), 36 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index ee2487246..a558bed98 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -392,27 +392,33 @@ class MembersController < ApplicationController #课程成员删除修改 if @project if request.delete? && @member.deletable? - @member.destroy - # end - user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id) - if user_admin.size > 0 - user_admin.each do |user| - user.destroy + ActiveRecord::Base.transaction do + begin + @member.destroy + # end + user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id) + if user_admin.size > 0 + user_admin.each do |user| + user.destroy + end + end + user_grade = UserGrade.where("user_id = ? and project_id = ?", @member.user_id, @project.id) + if user_grade.size > 0 + user_grade.each do |grade| + grade.destroy + end + end + # 移出的时候删除申请消息,不需要删除消息,所以不必要关联删除 + applied_projects = AppliedProject.where(:project_id => @project.id, :user_id => @member.user_id).first + unless applied_projects.nil? + applied_projects.delete + end + #移出项目发送消息 + ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id) + rescue Exception => e + puts e end end - user_grade = UserGrade.where("user_id = ? and project_id = ?", @member.user_id, @project.id) - if user_grade.size > 0 - user_grade.each do |grade| - grade.destroy - end - end - # 移出的时候删除申请消息,不需要删除消息,所以不必要关联删除 - applied_projects = AppliedProject.where(:project_id => @project.id, :user_id => @member.user_id).first - unless applied_projects.nil? - applied_projects.delete - end - #移出项目发送消息 - ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id) end respond_to do |format| format.html { redirect_to_settings_in_projects } diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index ca6484e49..1097609bf 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -159,8 +159,8 @@ class MyController < ApplicationController g = Gitlab.client begin g.edit_user(@user.gid, :email => params[:user][:mail]) - rescue - logger.error "sync user's email of gitlab failed!" + rescue Exception => e + puts e end end diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 540e1bbff..494bf95fc 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -232,25 +232,27 @@ class UsersService #修改密码 def change_password params - @current_user = User.find(params[:current_user_id]) - if @current_user.check_password?(params[:password]) - @current_user.password, @current_user.password_confirmation = params[:new_password], params[:new_password_confirmation] - @current_user.save - # 修改密码同步gitlab密码修改 - unless @current_user.gid.nil? - begin - g = Gitlab.client - g.edit_user(@current_user.gid, :password => params[:new_password]) - rescue Exception => e - logger.error "change users password failed! ===> #{e}" + ActiveRecord::Base.transaction do + @current_user = User.find(params[:current_user_id]) + if @current_user.check_password?(params[:password]) + @current_user.password, @current_user.password_confirmation = params[:new_password], params[:new_password_confirmation] + @current_user.save + # 修改密码同步gitlab密码修改 + unless @current_user.gid.nil? + begin + g = Gitlab.client + g.edit_user(@current_user.gid, :password => params[:new_password]) + rescue Exception => e + logger.error "change users password failed! ===> #{e}" + end end - end #raise @current_user.errors.full_message #return @current_user - else - raise l(:notice_account_wrong_password,:locale => 'zh') + else + raise l(:notice_account_wrong_password,:locale => 'zh') + end + @current_user end - @current_user end #搜索用户 From ff34ec6de84ad296df70fc7150f9608805706699 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 20 Dec 2016 16:33:26 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=20=20=E5=8F=82=E6=95=B0=E5=8A=A0=E5=AF=86=20gitlab?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A7=A3=E5=AF=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 22 ++++++++++++++++------ app/helpers/application_helper.rb | 17 +++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 82cbde56f..7f2e834cd 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -35,7 +35,7 @@ class RepositoriesController < ApplicationController before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats, :quality_analysis] before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] - before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :project_archive, :export_rep_static] + before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :export_rep_static] # 连接gitlab # before_filter :connect_gitlab, :only => [:quality_analysis, :commit_diff] @@ -121,9 +121,15 @@ class RepositoriesController < ApplicationController # 一键ZIP下载 def project_archive - g = Gitlab.client - g.get() - # g.project_archive(params[:gpid].to_i, params[:rev]) + token = Gitlab.private_token + token = aes_encrypt(token, "abcd") + # g = Gitlab.client + # g.project_archive(@project.gpid, @rev) + # 'git archive --format zip --output /path/to/file.zip master' # 将 master 以zip格式打包到指定文件 + # + # zip_path = Gitlab.endpoint.to_s + "/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=" + Gitlab.private_token + # f = open(zip_path).read + # send_file "/path/to/file.zip" end # 判断用户是否已经fork过该项目 @@ -409,8 +415,12 @@ update @creator = @project.owner.to_s gitlab_address = Redmine::Configuration['gitlab_address'] - # REDO:需优化,仅测试用 - @zip_path = Gitlab.endpoint.to_s + "/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=" + Gitlab.private_token + gitlab_token = Gitlab.private_token + # token值加密解密 + token = aes_encrypt("priEn3UwXfJs3Pmy", gitlab_token) + # token值解密 + # gitlab_token = aes_dicrypt("priEn3UwXfJs3Pmy", token) + @zip_path = Gitlab.endpoint.to_s + "/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=" + token end @creator = @project.owner.to_s diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index aef32f714..542823dc9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -37,6 +37,23 @@ module ApplicationHelper # super # end + # 字符串加密 + def aes_encrypt(key, encrypted_string) + aes = OpenSSL::Cipher::Cipher.new("AES-128-ECB") + aes.encrypt + aes.key = key + txt = aes.update(encrypted_string) << aes.final + txt.unpack('H*')[0].upcase + end + + # 字符串解密 + def aes_dicrypt(key, dicrypted_string) + aes = OpenSSL::Cipher::Cipher.new("AES-128-ECB") + aes.decrypt + aes.key = key + aes.update([dicrypted_string].pack('H*')) << aes.final + end + # 获取多种类型的user用户名 def user_message_username user user.try(:show_name) From 244303f0e4900d1d7e9c277ec863346e4761b330 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 23 Dec 2016 10:54:19 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=97=AE=E5=8D=B7=20?= =?UTF-8?q?=E5=85=B6=E5=AE=83=E9=80=89=E9=A1=B9=E5=A6=82=E6=9E=9C=E8=BF=87?= =?UTF-8?q?=E5=A4=9A=E7=9A=84=E6=97=B6=E5=80=99=E9=BB=98=E8=AE=A4=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=EF=BC=8C=20=E6=B7=BB=E5=8A=A0=E2=80=9C=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E2=80=9D=E5=92=8C=E2=80=9C=E6=98=BE=E7=A4=BA=E2=80=9D?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/poll_helper.rb | 5 ++ app/views/poll/_choice_show.html.erb | 81 ++++++++++++++++++++-------- 2 files changed, 63 insertions(+), 23 deletions(-) diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index eca8b503a..ed34afceb 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -63,6 +63,11 @@ module PollHelper def total_answer id total = PollVote.find_by_sql("SELECT distinct(user_id) FROM `poll_votes` where poll_question_id = #{id}").count end + + # 获取其它选项的答案 + def other_answers poll_question + poll_question.poll_votes.select{|pv| !pv.try(:vote_text).blank?} + end #页面体型显示 def options_show pq diff --git a/app/views/poll/_choice_show.html.erb b/app/views/poll/_choice_show.html.erb index 2269b4dca..c5f0a3813 100644 --- a/app/views/poll/_choice_show.html.erb +++ b/app/views/poll/_choice_show.html.erb @@ -1,28 +1,63 @@
- - - - - - <% poll_question.poll_answers.each do |poll_answer| %> - - - - - - <% end %> - - - - - - -
<%= l(:label_poll_options) %> <%= l(:label_poll_subtotal) %> <%= l(:label_poll_proportion) %>
<%= poll_answer.answer_text == "" ? "其他" :poll_answer.answer_text %> <%= poll_answer.poll_votes.count %> -
- -
- <%= statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)) %>%
<%= l(:label_poll_valid_commit) %> <%= total_answer(poll_question.id) %> 
+ + <%= l(:label_poll_options) %> + <%= l(:label_poll_subtotal) %> + <%= l(:label_poll_proportion) %> + + <% poll_question.poll_answers.each do |poll_answer| %> + + + <% if poll_answer.answer_text == "" %> + 其它<%= "隐藏" if other_answers(poll_question).count > 0 %> + <% else %> + <%= poll_answer.answer_text %> + <% end %> + + <%= poll_answer.poll_votes.count %> + +
+ +
+ <%= statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)) %>% + + <% end %> + + +
+ <% if other_answers(poll_question).count > 0 %> + + + + <% other_answers(poll_question).each do |pv| %> + + <% end %> + +
其它(详情)
<%= pv.vote_text %>
+ <% end %> +
+ + + + + + +
<%= l(:label_poll_valid_commit) %> <%= total_answer(poll_question.id) %> 
+ From 5add0af4b83022e2f96e7bc36360acb0bbccec4b Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 23 Dec 2016 13:45:27 +0800 Subject: [PATCH 11/12] =?UTF-8?q?mail=20notifiacation=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20161223030701_update_user_mail_notification.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20161223030701_update_user_mail_notification.rb diff --git a/db/migrate/20161223030701_update_user_mail_notification.rb b/db/migrate/20161223030701_update_user_mail_notification.rb new file mode 100644 index 000000000..4c81e8afc --- /dev/null +++ b/db/migrate/20161223030701_update_user_mail_notification.rb @@ -0,0 +1,9 @@ +class UpdateUserMailNotification < ActiveRecord::Migration + def up + sql = "update `users` set mail_notification ='all' where mail_notification in ('day','week');" + execute(sql) + end + + def down + end +end From 37f1aa144272951921b3c9491bb43b0bab88daee Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 23 Dec 2016 14:29:48 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/documents_controller.rb | 6 +- app/controllers/files_controller.rb | 8 +- app/controllers/homework_common_controller.rb | 4 +- app/controllers/projects_controller.rb | 8 +- app/controllers/users_controller.rb | 2 +- app/models/comment.rb | 6 +- app/models/document.rb | 4 +- app/models/homework_common.rb | 8 +- app/models/issue_observer.rb | 8 +- app/models/issue_overdue.rb | 62 +- app/models/journal_observer.rb | 26 +- app/models/mailer.rb | 670 +++++++++--------- app/models/memo.rb | 8 +- app/models/message.rb | 2 +- app/models/news.rb | 4 +- app/models/relative_memo.rb | 6 +- app/models/wiki_content_observer.rb | 8 +- app/services/courses_service.rb | 2 +- db/schema.rb | 292 +++++--- lib/tasks/homework_endtime.rake | 2 +- lib/tasks/homework_evaluation.rake | 6 +- lib/tasks/homework_publishtime.rake | 2 +- lib/tasks/issue_due_date.rake | 2 +- 23 files changed, 639 insertions(+), 507 deletions(-) diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 570726320..a931ece46 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -109,9 +109,9 @@ class DocumentsController < ApplicationController attachments = Attachment.attach_files(@document, params[:attachments]) render_attachment_warning_if_needed(@document) - if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added') - Mailer.run.attachments_added(attachments[:files]) - end + # if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added') + # # Mailer.run.attachments_added(attachments[:files]) + # end redirect_to document_url(@document) end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 94939ab4a..a4ed2cbd1 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -524,7 +524,7 @@ class FilesController < ApplicationController attachments = Attachment.attach_filesex(@project, params[:attachments], params[:attachment_type]) if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') # 发送邮件 - Mailer.run.attachments_added(attachments[:files]) + # Mailer.run.attachments_added(attachments[:files]) # 生成动态 attachments[:files].each do |file| ForgeActivity.create(:user_id => User.current.id, :project_id => @project.id, :forge_act_id => file.id, :forge_act_type => "Attachment") @@ -581,9 +581,9 @@ class FilesController < ApplicationController end attachments = Attachment.attach_filesex(@course, params[:attachments], params[:attachment_type]) - if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') - Mailer.run.attachments_added(attachments[:files]) - end + # if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') + # # Mailer.run.attachments_added(attachments[:files]) + # end if !attachments.empty? && attachments[:files] attachments[:files].each do |attachment| if params[:publish_time] diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 5e2e7c48a..540f4bdd3 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -284,7 +284,7 @@ class HomeworkCommonController < ApplicationController @statue = 1 # 匿评开启消息邮件通知 send_message_anonymous_comment(@homework, m_status = 2) - Mailer.send_mail_anonymous_comment_open(@homework).deliver + # Mailer.send_mail_anonymous_comment_open(@homework).deliver else @statue = 2 @@ -326,7 +326,7 @@ class HomeworkCommonController < ApplicationController # 匿评关闭消息邮件通知 send_message_anonymous_comment(@homework, m_status = 3) - Mailer.send_mail_anonymous_comment_close(@homework).deliver + # Mailer.send_mail_anonymous_comment_close(@homework).deliver @user_activity_id = params[:user_activity_id].to_i @hw_status = params[:hw_status].to_i @is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher, @course) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index dcd337df2..d6c138f0c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -432,7 +432,7 @@ class ProjectsController < ApplicationController # 如果已经邀请过该用户,则不重复发送 if InviteList.where("project_id =? and mail =?", @project.id, params[:mail].to_s).first.nil? email = params[:mail] - Mailer.request_member_to_project(email, @project, User.current).deliver + # Mailer.request_member_to_project(email, @project, User.current).deliver flash[:notice] = l(:notice_email_sent, :value => email) else flash[:error] = l(:notice_email_invited) @@ -445,7 +445,7 @@ class ProjectsController < ApplicationController first_name = params[:first_name] last_name = params[:last_name] gender = params[:gender] - Mailer.send_invite_in_project(email, @project, User.current, first_name, last_name, gender).deliver + # Mailer.send_invite_in_project(email, @project, User.current, first_name, last_name, gender).deliver @is_zhuce = false flash[:notice] = l(:notice_email_sent, :value => email) end @@ -458,13 +458,13 @@ class ProjectsController < ApplicationController invite_list = InviteList.where("project_id =? and mail =?", @project.id, params[:mail].to_s).first if invite_list.nil? email = params[:mail] - Mailer.request_member_to_project(email, @project, User.current).deliver + # Mailer.request_member_to_project(email, @project, User.current).deliver flash[:notice] = l(:notice_email_sent, :value => email) else # 已经发送过了,则隔3小时才能再次发送 if Time.now - invite_list.created_at > 10800 email = params[:mail] - Mailer.request_member_to_project(email, @project, User.current).deliver + # Mailer.request_member_to_project(email, @project, User.current).deliver flash[:notice] = l(:notice_email_sent, :value => email) else flash[:error] = l(:notice_email_invited) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 314f63069..cb9b6abb1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -768,7 +768,7 @@ class UsersController < ApplicationController ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:homework_id].to_i) if ah.empty? ApplyHomework.create(:user_id => params[:id].to_i, :homework_common_id => params[:homework_id].to_i, :status => 1) - Mailer.run.apply_for_homework_request(homework, User.current) + # Mailer.run.apply_for_homework_request(homework, User.current) CourseMessage.create(:user_id => homework.user_id, :course_id => homework.course.id, :viewed => false,:course_message_id=>params[:homework_id].to_i,:course_message_type=>'HomeworkCommon',:status=>5,:apply_user_id=>params[:id].to_i,:content=>params[:content]) @state = 2 @ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", params[:id].to_i, params[:homework_id].to_i).first diff --git a/app/models/comment.rb b/app/models/comment.rb index 9a87201dc..f0add239f 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -64,9 +64,9 @@ class Comment < ActiveRecord::Base end def send_mail - if self.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added') - Mailer.run.news_comment_added(self) - end + # if self.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added') + # Mailer.run.news_comment_added(self) + # end end after_destroy :delete_kindeditor_assets diff --git a/app/models/document.rb b/app/models/document.rb index b45a74775..8577059dc 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -24,7 +24,7 @@ class Document < ActiveRecord::Base after_save :be_user_score # user_score after_destroy :down_user_score acts_as_attachable :delete_permission => :delete_documents - after_create :send_mail + # after_create :send_mail # 被ForgeActivity虚拟关联 has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy # end @@ -89,7 +89,7 @@ class Document < ActiveRecord::Base end def send_mail - Mailer.run.document_added(self) if Setting.notified_events.include?('document_added') + # Mailer.run.document_added(self) if Setting.notified_events.include?('document_added') end end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index f183ff2e4..34147a7d1 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -31,7 +31,7 @@ class HomeworkCommon < ActiveRecord::Base :description => :description, :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} - after_create :act_as_activity, :send_mail,:act_as_course_message + after_create :act_as_activity, :act_as_course_message after_update :update_activity after_save :act_as_course_activity after_destroy :delete_kindeditor_assets @@ -129,9 +129,9 @@ class HomeworkCommon < ActiveRecord::Base end def send_mail - if self.homework_detail_manual.comment_status != 0 - Mailer.run.homework_added(self) - end + # if self.homework_detail_manual.comment_status != 0 + # Mailer.run.homework_added(self) + # end end def is_program_homework? diff --git a/app/models/issue_observer.rb b/app/models/issue_observer.rb index ea78349af..9a293fe73 100644 --- a/app/models/issue_observer.rb +++ b/app/models/issue_observer.rb @@ -19,10 +19,10 @@ class IssueObserver < ActiveRecord::Observer def after_create(issue) # 将跟踪者与本项目的其他成员都设为收件方,并去重,不在进行抄送, - recipients = issue.recipients - issue.watcher_recipients + issue.watcher_recipients - recipients.each do |rec| - Mailer.run.issue_add(issue,rec) if Setting.notified_events.include?('issue_added') - end + # recipients = issue.recipients - issue.watcher_recipients + issue.watcher_recipients + # recipients.each do |rec| + # Mailer.run.issue_add(issue,rec) if Setting.notified_events.include?('issue_added') + # end end end diff --git a/app/models/issue_overdue.rb b/app/models/issue_overdue.rb index 3002b74ef..35060e319 100644 --- a/app/models/issue_overdue.rb +++ b/app/models/issue_overdue.rb @@ -2,36 +2,36 @@ class IssueOverdue < ActiveRecord::Base #缺陷到期后发送邮件提示 #只监听已经提交的未到期的缺陷,已过期的缺陷默认已经发过邮件通知,不再提醒。 def self.mail_issue - threads = [] - issues = Issue.where("done_ratio <> 100 and closed_on is null and due_date is not null") - puts issues - issues.each do |issue| - thread = Thread.new do - while true - cur_issue = Issue.find issue.id - if cur_issue.done_ratio == 100 || cur_issue.closed_on != nil - break - end - if Time.now < Time.parse(cur_issue.due_date.to_s) - #休眠一个小时。。。 - puts cur_issue.id.to_s - sleep 5 - else - #发邮件 - #puts "11" + issue.id.to_s - #Mailer.issue_expire(issue).deliver - recipients = issue.recipients - recipients.each do |rec| - - Mailer.issue_edit(issue,rec).deliver - end - break - end - end - end - threads << thread - end - puts threads - return threads + # threads = [] + # issues = Issue.where("done_ratio <> 100 and closed_on is null and due_date is not null") + # puts issues + # issues.each do |issue| + # thread = Thread.new do + # while true + # cur_issue = Issue.find issue.id + # if cur_issue.done_ratio == 100 || cur_issue.closed_on != nil + # break + # end + # if Time.now < Time.parse(cur_issue.due_date.to_s) + # #休眠一个小时。。。 + # puts cur_issue.id.to_s + # sleep 5 + # else + # #发邮件 + # #puts "11" + issue.id.to_s + # #Mailer.issue_expire(issue).deliver + # recipients = issue.recipients + # recipients.each do |rec| + # + # Mailer.issue_edit(issue,rec).deliver + # end + # break + # end + # end + # end + # threads << thread + # end + # puts threads + # return threads end end \ No newline at end of file diff --git a/app/models/journal_observer.rb b/app/models/journal_observer.rb index c5b0e496b..edffe95fb 100644 --- a/app/models/journal_observer.rb +++ b/app/models/journal_observer.rb @@ -17,18 +17,18 @@ class JournalObserver < ActiveRecord::Observer def after_create(journal) - if journal.notify? && - (Setting.notified_events.include?('issue_updated') || - (Setting.notified_events.include?('issue_note_added') && journal.notes.present?) || - (Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) || - (Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?) - ) - # 将跟踪者与本项目的其他成员都设为收件方,并去重,不在进行抄送, - recipients = journal.recipients - journal.watcher_recipients + journal.watcher_recipients - recipients.each do |rec| - - Mailer.run.issue_edit(journal,rec) - end - end + # if journal.notify? && + # (Setting.notified_events.include?('issue_updated') || + # (Setting.notified_events.include?('issue_note_added') && journal.notes.present?) || + # (Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) || + # (Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?) + # ) + # # 将跟踪者与本项目的其他成员都设为收件方,并去重,不在进行抄送, + # recipients = journal.recipients - journal.watcher_recipients + journal.watcher_recipients + # recipients.each do |rec| + # + # Mailer.run.issue_edit(journal,rec) + # end + # end end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index c37004066..b114b5fd6 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -50,59 +50,59 @@ class Mailer < ActionMailer::Base # 作业匿评开启 def send_mail_anonymous_comment_open(homework_common) - course = homework_common.course - recipients ||= [] - course.members.each do |member| - user = User.find(member.user_id) - @subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}" - @token = Token.get_token_from_user(user, 'autologin') - @anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value)) - @anonymous_comment_close_name = homework_common.name - @author = homework_common.user - #收件人邮箱 - recipients << user.mail - end - mail :to => recipients, - :subject => @subject + # course = homework_common.course + # recipients ||= [] + # course.members.each do |member| + # user = User.find(member.user_id) + # @subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}" + # @token = Token.get_token_from_user(user, 'autologin') + # @anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value)) + # @anonymous_comment_close_name = homework_common.name + # @author = homework_common.user + # #收件人邮箱 + # recipients << user.mail + # end + # mail :to => recipients, + # :subject => @subject end # 作业匿评关闭 def send_mail_anonymous_comment_close(homework_common) - course = homework_common.course - recipients ||= [] - course.members.each do |member| - user = User.find(member.user_id) - @subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_close)}" - @token = Token.get_token_from_user(user, 'autologin') - @anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value)) - @anonymous_comment_close_name = homework_common.name - @author = homework_common.user - #收件人邮箱 - recipients << user.mail - end - mail :to => recipients, - :subject => @subject + # course = homework_common.course + # recipients ||= [] + # course.members.each do |member| + # user = User.find(member.user_id) + # @subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_close)}" + # @token = Token.get_token_from_user(user, 'autologin') + # @anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value)) + # @anonymous_comment_close_name = homework_common.name + # @author = homework_common.user + # #收件人邮箱 + # recipients << user.mail + # end + # mail :to => recipients, + # :subject => @subject end # 匿评失败给老师发送邮件通知 def send_mail_anonymous_comment_fail(homework_common) - course = homework_common.course - recipients ||= [] - # 只给该课程的老师发送邮件提醒 - course.members.each do |member| - if member.user.allowed_to?(:as_teacher,course) - user = User.find(member.user_id) - @subject = "[#{l(:mail_homework)} #{homework_common.name}] #{l(:mail_anonymous_comment_failed)}" - @token = Token.get_token_from_user(user, 'autologin') - @anonymous_comment_fail_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value)) - @anonymous_comment_fail_name = homework_common.name - @author = homework_common.user - #收件人邮箱 - recipients << user.mail - end - end - mail :to => recipients, - :subject => @subject + # course = homework_common.course + # recipients ||= [] + # # 只给该课程的老师发送邮件提醒 + # course.members.each do |member| + # if member.user.allowed_to?(:as_teacher,course) + # user = User.find(member.user_id) + # @subject = "[#{l(:mail_homework)} #{homework_common.name}] #{l(:mail_anonymous_comment_failed)}" + # @token = Token.get_token_from_user(user, 'autologin') + # @anonymous_comment_fail_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value)) + # @anonymous_comment_fail_name = homework_common.name + # @author = homework_common.user + # #收件人邮箱 + # recipients << user.mail + # end + # end + # mail :to => recipients, + # :subject => @subject end # author: alan @@ -146,149 +146,149 @@ class Mailer < ActionMailer::Base end # 邀请信息消息 注:forge_message_id 为邀请人ID(特殊情况) - def send_message_request_member(user, project) - key = newpass(6).to_s - ForgeMessage.create(:user_id => user.id, :project_id => project.id, :forge_message_type => "ProjectInvite",:forge_message_id => User.current.id, :viewed => false, :secret_key =>key) - end + # def send_message_request_member(user, project) + # key = newpass(6).to_s + # ForgeMessage.create(:user_id => user.id, :project_id => project.id, :forge_message_type => "ProjectInvite",:forge_message_id => User.current.id, :viewed => false, :secret_key =>key) + # end # author: alan # 根据用户选择发送个人日报或周报 # 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言 def send_for_user_activities(user, date_to, days) - date_from = date_to - days.days - date_from = "#{date_from} 17:59:59" - date_to = "#{date_to} 17:59:59" - # 生成token用于直接点击登录 - @user = user - @token = Token.get_token_from_user(user, 'autologin') - - # 查询user参加的项目及课程 - projects = user.projects - courses = user.courses - project_ids = projects.map{|project| project.id}.join(",") - course_ids = courses.map {|course| course.id}.join(",") - - # 查询user的缺陷,项目中成员都能收到 - sql = "select DISTINCT * from members m, issues i where i.project_id = m.project_id and m.user_id='#{user.id}' - and (i.updated_on between '#{date_from}' and '#{date_to}') order by i.project_id, i.updated_on desc" - @issues = Issue.find_by_sql(sql) - - # issue回复 - @issues_journals = Journal.find_by_sql("select j.* from journals j, members m, projects p, issues i - where m.user_id = '#{user.id}' and p.id = m.project_id and i.project_id = p.id and j.journalized_id = i.id - and j.journalized_type='Issue' and (j.created_on between '#{date_from}' and '#{date_to}') order by i.project_id, created_on desc") - - # @bids 查询课程作业,包括老师发布的作业,以及user提交作业 - # @attachments查询课程课件更新 - @attachments ||= [] - @bids ||= [] # 老师发布的作业 - unless courses.first.nil? - count = courses.count - count = count - 1 - for i in 0..count do - bids = courses[i].homework_commons.where("homework_commons.created_at between '#{date_from}' and '#{date_to}'").order("homework_commons.created_at desc") - attachments = courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'") - @bids += bids if bids.count > 0 - @attachments += attachments if attachments.count > 0 - end - # @bids = @bids.sort_by { |obj| obj.created_at } - end - - # 项目附件 - @project_attachments = Attachment.find_by_sql("select DISTINCT a.* from members m, attachments a - where a.container_id = m.project_id and m.user_id='#{user.id}' and container_type = 'Project' and (a.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, a.created_on desc") - - # user 提交的作业 - # @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc") - - # 查询user所在项目添加wiki - @wiki_contents = WikiContent.find_by_sql("select DISTINCT wc.* from wikis w, members m, projects p, wiki_pages wp, wiki_contents wc where - m.user_id = '#{user.id}' and m.project_id = p.id and w.project_id = p.id and w.id = wp.wiki_id and wc.page_id = wp.id and w.project_id>0 - and (wc.updated_on between '#{date_from}' and '#{date_to}') order by m.project_id, updated_on desc") - - # 查询user在课程中发布的讨论帖子 - course_mesages = Message.find_by_sql("select DISTINCT me.* from messages me, boards b, members m where - b.id = me.board_id and b.course_id = m.course_id - and b.course_id is not Null and m.user_id = '#{user.id}' - and (me.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc") - - # 查询user在项目中发布的讨论帖子 - project_messages = Message.find_by_sql("select DISTINCT me.* from messages me, boards b, members m where - b.id = me.board_id and b.project_id = m.project_id - and b.project_id != '-1' and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc") - # messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") - @course_messages ||= [] - @project_messages ||= [] - unless course_mesages.first.nil? - course_mesages.each do |msg| - @course_messages << msg - end - end - unless project_messages.first.nil? - project_messages.each do |msg| - @project_messages << msg - end - end - # wiki - - # 查询user在课程中发布的通知和回复通知 - @course_news = (course_ids && !course_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n - where n.course_id in (#{course_ids}) - and (created_on between '#{date_from}' and '#{date_to}') order by n.course_id, created_on desc") : [] - - @course_news_comments = Comment.find_by_sql("select cm.* from comments cm, members m, courses c, news n - where m.user_id = '#{user.id}' and c.id = m.course_id and n.course_id = c.id and cm.commented_id = n.id - and cm.commented_type ='News' and (cm.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc") - - # 查询user在项目中添加新闻和回复新闻 - @project_news = (project_ids && !project_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n where n.project_id in (#{project_ids}) - and (created_on between '#{date_from}' and '#{date_to}') order by n.project_id, created_on desc") : [] - - @project_news_comments = Comment.find_by_sql("select c.* from comments c, members m, projects p, news n - where m.user_id = '#{user.id}' and p.id = m.project_id and n.project_id = p.id and c.commented_id = n.id - and c.commented_type ='News' and (c.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc") - - # 查询user在课程及个人中留言 - @course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, courses c - where m.user_id = '#{user.id}' and c.id = m.course_id and jfm.jour_id = c.id - and jfm.jour_type='Course' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc") - - @user_journal_messages = user.journals_for_messages.where("jour_type='Principal' and (created_on between '#{date_from}' and '#{date_to}')").order('created_on DESC') - - # 查询user在项目中留言(用户反馈) - @project_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, projects p - where m.user_id = '#{user.id}' and p.id = m.project_id and jfm.jour_id = p.id - and jfm.jour_type='Project' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc") - - # 查询user新建贴吧或发布帖子 - @forums = Forum.find_by_sql("select DISTINCT * from forums where creator_id = #{user.id} and (created_at between '#{date_from}' and '#{date_to}') order by created_at desc") - @memos = Memo.find_by_sql("select DISTINCT m.* from memos m, forums f where (m.author_id = #{user.id} or (m.forum_id = f.id and f.creator_id = #{user.id})) - and (m.created_at between '#{date_from}' and '#{date_to}') order by m.created_at desc") - - has_content = [@issues,@issues_journals,@course_messages,@project_messages,@course_news,@course_news_comments,@project_news,@project_news_comments,@project_attachments, - @course_journal_messages,@user_journal_messages,@project_journal_messages,@forums,@memos,@attachments,@bids,@wiki_contents].any? {|o| !o.empty?} - total_count = @issues.count + @issues_journals.count + @course_messages.count + @project_messages.count + @course_news.count + @course_news_comments.count + @project_news.count + @project_news_comments.count + - @project_attachments.count + @course_journal_messages.count + @user_journal_messages.count + @project_journal_messages.count + @forums.count + @memos.count + @attachments.count + - @bids.count + @wiki_contents.count - subject = "[ #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}]" - @subject = " #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}" - mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}" - #有内容才发,没有不发 - mail :to => user.mail,:subject => @subject if has_content + # date_from = date_to - days.days + # date_from = "#{date_from} 17:59:59" + # date_to = "#{date_to} 17:59:59" + # # 生成token用于直接点击登录 + # @user = user + # @token = Token.get_token_from_user(user, 'autologin') + # + # # 查询user参加的项目及课程 + # projects = user.projects + # courses = user.courses + # project_ids = projects.map{|project| project.id}.join(",") + # course_ids = courses.map {|course| course.id}.join(",") + # + # # 查询user的缺陷,项目中成员都能收到 + # sql = "select DISTINCT * from members m, issues i where i.project_id = m.project_id and m.user_id='#{user.id}' + # and (i.updated_on between '#{date_from}' and '#{date_to}') order by i.project_id, i.updated_on desc" + # @issues = Issue.find_by_sql(sql) + # + # # issue回复 + # @issues_journals = Journal.find_by_sql("select j.* from journals j, members m, projects p, issues i + # where m.user_id = '#{user.id}' and p.id = m.project_id and i.project_id = p.id and j.journalized_id = i.id + # and j.journalized_type='Issue' and (j.created_on between '#{date_from}' and '#{date_to}') order by i.project_id, created_on desc") + # + # # @bids 查询课程作业,包括老师发布的作业,以及user提交作业 + # # @attachments查询课程课件更新 + # @attachments ||= [] + # @bids ||= [] # 老师发布的作业 + # unless courses.first.nil? + # count = courses.count + # count = count - 1 + # for i in 0..count do + # bids = courses[i].homework_commons.where("homework_commons.created_at between '#{date_from}' and '#{date_to}'").order("homework_commons.created_at desc") + # attachments = courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'") + # @bids += bids if bids.count > 0 + # @attachments += attachments if attachments.count > 0 + # end + # # @bids = @bids.sort_by { |obj| obj.created_at } + # end + # + # # 项目附件 + # @project_attachments = Attachment.find_by_sql("select DISTINCT a.* from members m, attachments a + # where a.container_id = m.project_id and m.user_id='#{user.id}' and container_type = 'Project' and (a.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, a.created_on desc") + # + # # user 提交的作业 + # # @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc") + # + # # 查询user所在项目添加wiki + # @wiki_contents = WikiContent.find_by_sql("select DISTINCT wc.* from wikis w, members m, projects p, wiki_pages wp, wiki_contents wc where + # m.user_id = '#{user.id}' and m.project_id = p.id and w.project_id = p.id and w.id = wp.wiki_id and wc.page_id = wp.id and w.project_id>0 + # and (wc.updated_on between '#{date_from}' and '#{date_to}') order by m.project_id, updated_on desc") + # + # # 查询user在课程中发布的讨论帖子 + # course_mesages = Message.find_by_sql("select DISTINCT me.* from messages me, boards b, members m where + # b.id = me.board_id and b.course_id = m.course_id + # and b.course_id is not Null and m.user_id = '#{user.id}' + # and (me.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc") + # + # # 查询user在项目中发布的讨论帖子 + # project_messages = Message.find_by_sql("select DISTINCT me.* from messages me, boards b, members m where + # b.id = me.board_id and b.project_id = m.project_id + # and b.project_id != '-1' and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc") + # # messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") + # @course_messages ||= [] + # @project_messages ||= [] + # unless course_mesages.first.nil? + # course_mesages.each do |msg| + # @course_messages << msg + # end + # end + # unless project_messages.first.nil? + # project_messages.each do |msg| + # @project_messages << msg + # end + # end + # # wiki + # + # # 查询user在课程中发布的通知和回复通知 + # @course_news = (course_ids && !course_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n + # where n.course_id in (#{course_ids}) + # and (created_on between '#{date_from}' and '#{date_to}') order by n.course_id, created_on desc") : [] + # + # @course_news_comments = Comment.find_by_sql("select cm.* from comments cm, members m, courses c, news n + # where m.user_id = '#{user.id}' and c.id = m.course_id and n.course_id = c.id and cm.commented_id = n.id + # and cm.commented_type ='News' and (cm.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc") + # + # # 查询user在项目中添加新闻和回复新闻 + # @project_news = (project_ids && !project_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n where n.project_id in (#{project_ids}) + # and (created_on between '#{date_from}' and '#{date_to}') order by n.project_id, created_on desc") : [] + # + # @project_news_comments = Comment.find_by_sql("select c.* from comments c, members m, projects p, news n + # where m.user_id = '#{user.id}' and p.id = m.project_id and n.project_id = p.id and c.commented_id = n.id + # and c.commented_type ='News' and (c.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc") + # + # # 查询user在课程及个人中留言 + # @course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, courses c + # where m.user_id = '#{user.id}' and c.id = m.course_id and jfm.jour_id = c.id + # and jfm.jour_type='Course' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by m.course_id, created_on desc") + # + # @user_journal_messages = user.journals_for_messages.where("jour_type='Principal' and (created_on between '#{date_from}' and '#{date_to}')").order('created_on DESC') + # + # # 查询user在项目中留言(用户反馈) + # @project_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, projects p + # where m.user_id = '#{user.id}' and p.id = m.project_id and jfm.jour_id = p.id + # and jfm.jour_type='Project' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by m.project_id, created_on desc") + # + # # 查询user新建贴吧或发布帖子 + # @forums = Forum.find_by_sql("select DISTINCT * from forums where creator_id = #{user.id} and (created_at between '#{date_from}' and '#{date_to}') order by created_at desc") + # @memos = Memo.find_by_sql("select DISTINCT m.* from memos m, forums f where (m.author_id = #{user.id} or (m.forum_id = f.id and f.creator_id = #{user.id})) + # and (m.created_at between '#{date_from}' and '#{date_to}') order by m.created_at desc") + # + # has_content = [@issues,@issues_journals,@course_messages,@project_messages,@course_news,@course_news_comments,@project_news,@project_news_comments,@project_attachments, + # @course_journal_messages,@user_journal_messages,@project_journal_messages,@forums,@memos,@attachments,@bids,@wiki_contents].any? {|o| !o.empty?} + # total_count = @issues.count + @issues_journals.count + @course_messages.count + @project_messages.count + @course_news.count + @course_news_comments.count + @project_news.count + @project_news_comments.count + + # @project_attachments.count + @course_journal_messages.count + @user_journal_messages.count + @project_journal_messages.count + @forums.count + @memos.count + @attachments.count + + # @bids.count + @wiki_contents.count + # subject = "[ #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}]" + # @subject = " #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}" + # mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}" + # #有内容才发,没有不发 + # mail :to => user.mail,:subject => @subject if has_content end # 作业截止时间邮件提醒 def homework_endtime__added(homework_common, user_id) - user = User.find(user_id) - @subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_homework_endtime)} " - @token = Token.get_token_from_user(user, 'autologin') - @homework_endtime_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value)) - @homework_endtime_name = homework_common.name - @author = homework_common.user - #收件人邮箱 - recipient = user.mail - mail :to => recipient, - :subject => @subject + # user = User.find(user_id) + # @subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_homework_endtime)} " + # @token = Token.get_token_from_user(user, 'autologin') + # @homework_endtime_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value)) + # @homework_endtime_name = homework_common.name + # @author = homework_common.user + # #收件人邮箱 + # recipient = user.mail + # mail :to => recipient, + # :subject => @subject end # 公共讨论区发帖、回帖添加邮件发送信息 @@ -382,20 +382,20 @@ class Mailer < ActionMailer::Base # issue截止时间提醒 def issue_due_date(issue) - recipients ||= [] - if issue.author.id != issue.assigned_to_id - recipients << issue.author.mail - end - - # 被指派人邮箱地址加入数组 - recipients << issue.assigned_to.mail - # cc = wiki_content.page.wiki.watcher_recipients - recipients - @author = issue.author - @issue_name = issue.subject - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id) - @subject = "#{l(:mail_issue)}#{issue.subject} #{l(:mail_issue_due_date)} " - mail :to => recipients, - :subject => @subject + # recipients ||= [] + # if issue.author.id != issue.assigned_to_id + # recipients << issue.author.mail + # end + # + # # 被指派人邮箱地址加入数组 + # recipients << issue.assigned_to.mail + # # cc = wiki_content.page.wiki.watcher_recipients - recipients + # @author = issue.author + # @issue_name = issue.subject + # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id) + # @subject = "#{l(:mail_issue)}#{issue.subject} #{l(:mail_issue_due_date)} " + # mail :to => recipients, + # :subject => @subject end # Builds a Mail::Message object used to email recipients of the added issue. @@ -404,31 +404,31 @@ class Mailer < ActionMailer::Base # issue_add(issue) => Mail::Message object # Mailer.issue_add(issue).deliver => sends an email to issue recipients def issue_add(issue, recipients) - issue_id = issue.project_index - redmine_headers 'Project' => issue.project.identifier, - 'Issue-Id' => issue_id, - 'Issue-Author' => issue.author.login - redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to - message_id issue - - @author = issue.author - @issue = issue - user = User.find_by_mail(recipients) - @user = user - # @token = Token.get_token_from_user(user, 'autologin') - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id) - - # edit - @issue_author_url = url_for(user_activities_url(@author)) - @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id) - - @user_url = url_for(my_account_url(user)) - - - subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" - mail :to => recipients, - :subject => subject, - :filter => true + # issue_id = issue.project_index + # redmine_headers 'Project' => issue.project.identifier, + # 'Issue-Id' => issue_id, + # 'Issue-Author' => issue.author.login + # redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to + # message_id issue + # + # @author = issue.author + # @issue = issue + # user = User.find_by_mail(recipients) + # @user = user + # # @token = Token.get_token_from_user(user, 'autologin') + # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id) + # + # # edit + # @issue_author_url = url_for(user_activities_url(@author)) + # @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id) + # + # @user_url = url_for(my_account_url(user)) + # + # + # subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" + # mail :to => recipients, + # :subject => subject, + # :filter => true end # issue.attachments.each do |attach| # attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}") @@ -445,36 +445,36 @@ class Mailer < ActionMailer::Base # issue_edit(journal) => Mail::Message object # Mailer.issue_edit(journal).deliver => sends an email to issue recipients def issue_edit(journal,recipients) - issue = journal.journalized.reload - issue_id = issue.project_index - redmine_headers 'Project' => issue.project.identifier, - 'Issue-Id' => issue_id.to_s, - 'Issue-Author' => issue.author.login - redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to - message_id journal - references issue - @author = journal.user - - user = User.find_by_mail(recipients) - @user = user - # @token = Token.get_token_from_user(user, 'autologin') - - - # edit - @issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id) - @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id) - @user_url = url_for(my_account_url(user)) - - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}") - s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] " - s << "(#{issue.status.name}) " if journal.new_value_for('status_id') - s << issue.subject - @issue = issue - @journal = journal - # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") - mail :to => recipients, - :subject => s, - :filter => true + # issue = journal.journalized.reload + # issue_id = issue.project_index + # redmine_headers 'Project' => issue.project.identifier, + # 'Issue-Id' => issue_id.to_s, + # 'Issue-Author' => issue.author.login + # redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to + # message_id journal + # references issue + # @author = journal.user + # + # user = User.find_by_mail(recipients) + # @user = user + # # @token = Token.get_token_from_user(user, 'autologin') + # + # + # # edit + # @issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id) + # @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id) + # @user_url = url_for(my_account_url(user)) + # + # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}") + # s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] " + # s << "(#{issue.status.name}) " if journal.new_value_for('status_id') + # s << issue.subject + # @issue = issue + # @journal = journal + # # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") + # mail :to => recipients, + # :subject => s, + # :filter => true end def self.deliver_mailer(to,cc, subject) @@ -510,19 +510,19 @@ class Mailer < ActionMailer::Base #缺陷到期邮件通知 def issue_expire issue - issue_id = issue.project_index - redmine_headers 'Project' => issue.project.identifier, - 'Issue-Id' => issue_id, - 'Issue-Author' => issue.author.login - redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to - message_id issue - @author = issue.author - @issue = issue - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id) - recipients = issue.recipients - s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}") - mail :to => recipients, - :subject => s + # issue_id = issue.project_index + # redmine_headers 'Project' => issue.project.identifier, + # 'Issue-Id' => issue_id, + # 'Issue-Author' => issue.author.login + # redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to + # message_id issue + # @author = issue.author + # @issue = issue + # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id) + # recipients = issue.recipients + # s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}") + # mail :to => recipients, + # :subject => s ######################################################################################################### #@issues = issues #s = l(:text_issue_expire,:issue => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}") @@ -627,19 +627,19 @@ class Mailer < ActionMailer::Base # attachments_added(attachments) => Mail::Message object # Mailer.attachments_added(attachments).deliver => sends an email to the project's recipients def homework_added(homework_common) - logger.info "homework added" - @homework_common = homework_common - @author = homework_common.user - @homework_common_url = url_for(:controller => "homework_common", :action =>"index", :homework => @homework_common.id) - @homework_author_url = url_for(user_activities_url(@author)) - recipients ||= [] - #将帖子创建者邮箱地址加入数组 - @homework_common.course.members.each do |member| - recipients << member.user.mail - end - mail :to => recipients, - :subject => "[ #{l(:label_user_homework)} : #{homework_common.name} #{l(:label_memo_create_succ)}]", - :filter => true + # logger.info "homework added" + # @homework_common = homework_common + # @author = homework_common.user + # @homework_common_url = url_for(:controller => "homework_common", :action =>"index", :homework => @homework_common.id) + # @homework_author_url = url_for(user_activities_url(@author)) + # recipients ||= [] + # #将帖子创建者邮箱地址加入数组 + # @homework_common.course.members.each do |member| + # recipients << member.user.mail + # end + # mail :to => recipients, + # :subject => "[ #{l(:label_user_homework)} : #{homework_common.name} #{l(:label_memo_create_succ)}]", + # :filter => true end # Builds a Mail::Message object used to email recipients of a news' project when a news item is added. @@ -649,28 +649,28 @@ class Mailer < ActionMailer::Base # Mailer.news_added(news).deliver => sends an email to the news' project recipients def news_added(news) - if news.project - # redmine_headers 'Project' => news.project.identifier - # @author = news.author - # @issue_author_url = url_for(user_activities_url(@author)) - # message_id news - # @news = news - # @news_url = url_for(:controller => 'news', :action => 'show', :id => news) - # mail :to => news.recipients, - # :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}", - # :filter => true - elsif news.course - redmine_headers 'Course' => news.course.id - @author = news.author - @issue_author_url = url_for(user_activities_url(@author)) - message_id news - @news = news - recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail } - @news_url = url_for(:controller => 'news', :action => 'show', :id => news) - mail :to => recipients, - :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}", - :filter => true - end + # if news.project + # # redmine_headers 'Project' => news.project.identifier + # # @author = news.author + # # @issue_author_url = url_for(user_activities_url(@author)) + # # message_id news + # # @news = news + # # @news_url = url_for(:controller => 'news', :action => 'show', :id => news) + # # mail :to => news.recipients, + # # :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}", + # # :filter => true + # elsif news.course + # redmine_headers 'Course' => news.course.id + # @author = news.author + # @issue_author_url = url_for(user_activities_url(@author)) + # message_id news + # @news = news + # recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail } + # @news_url = url_for(:controller => 'news', :action => 'show', :id => news) + # mail :to => recipients, + # :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}", + # :filter => true + # end end # Builds a Mail::Message object used to email recipients of a news' project when a news comment is added. @@ -679,33 +679,33 @@ class Mailer < ActionMailer::Base # news_comment_added(comment) => Mail::Message object # Mailer.news_comment_added(comment) => sends an email to the news' project recipients def news_comment_added(comment) - news = comment.commented - if news.project - # redmine_headers 'Project' => news.project.identifier - # @author = comment.author - # @issue_author_url = url_for(user_activities_url(@author)) - # message_id comment - # @news = news - # @comment = comment - # @news_url = url_for(:controller => 'news', :action => 'show', :id => news) - # mail :to => news.recipients, - # :cc => news.watcher_recipients, - # :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}", - # :filter => true - elsif news.course - redmine_headers 'Course' => news.course.id - @author = comment.author - @issue_author_url = url_for(user_activities_url(@author)) - message_id comment - @news = news - @comment = comment - @news_url = url_for(:controller => 'news', :action => 'show', :id => news) - recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail } - - mail :to => recipients, - :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}", - :filter => true - end + # news = comment.commented + # if news.project + # # redmine_headers 'Project' => news.project.identifier + # # @author = comment.author + # # @issue_author_url = url_for(user_activities_url(@author)) + # # message_id comment + # # @news = news + # # @comment = comment + # # @news_url = url_for(:controller => 'news', :action => 'show', :id => news) + # # mail :to => news.recipients, + # # :cc => news.watcher_recipients, + # # :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}", + # # :filter => true + # elsif news.course + # redmine_headers 'Course' => news.course.id + # @author = comment.author + # @issue_author_url = url_for(user_activities_url(@author)) + # message_id comment + # @news = news + # @comment = comment + # @news_url = url_for(:controller => 'news', :action => 'show', :id => news) + # recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail } + # + # mail :to => recipients, + # :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}", + # :filter => true + # end end # Builds a Mail::Message object used to email the recipients of the specified message that was posted. @@ -1032,21 +1032,21 @@ class Mailer < ActionMailer::Base end def join_course_request(course, user, role) - @receive = User.find(course.tea_id) - @course = course - @user = user - @role = role - @subject = "#{@user.show_name} #{l(:label_apply_join_course)} #{@course.name} " - mail :to => @receive.mail, - :subject => @subject + # @receive = User.find(course.tea_id) + # @course = course + # @user = user + # @role = role + # @subject = "#{@user.show_name} #{l(:label_apply_join_course)} #{@course.name} " + # mail :to => @receive.mail, + # :subject => @subject end def apply_for_homework_request(homework, user) - @receive = User.find(homework.user_id) - @user = user - @subject = "#{@user.show_name} #{l(:label_apply_for_homework)} #{homework.name} " - mail :to => @receive.mail, - :subject => @subject + # @receive = User.find(homework.user_id) + # @user = user + # @subject = "#{@user.show_name} #{l(:label_apply_for_homework)} #{homework.name} " + # mail :to => @receive.mail, + # :subject => @subject end private diff --git a/app/models/memo.rb b/app/models/memo.rb index e6701849f..a580f02a8 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -124,7 +124,7 @@ class Memo < ActiveRecord::Base end def send_mail - Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added') + # Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added') end def creator_user @@ -218,9 +218,9 @@ class Memo < ActiveRecord::Base end def send_notification - if Setting.notified_events.include?('message_posted') - Mailer.run.message_posted(self) - end + # if Setting.notified_events.include?('message_posted') + # Mailer.run.message_posted(self) + # end end def plusParentAndForum diff --git a/app/models/message.rb b/app/models/message.rb index 5366724eb..a71cca6ec 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -389,7 +389,7 @@ class Message < ActiveRecord::Base end def send_mail - Mailer.run.message_posted(self) if Setting.notified_events.include?('message_posted') + # Mailer.run.message_posted(self) if Setting.notified_events.include?('message_posted') end # Time 2015-03-31 09:15:06 diff --git a/app/models/news.rb b/app/models/news.rb index c436724fd..b5a4c85e0 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -65,7 +65,7 @@ class News < ActiveRecord::Base :author_key => :author_id acts_as_watchable - after_create :act_as_course_activity, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send + after_create :act_as_course_activity, :add_author_as_watcher, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send after_update :update_activity after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score @@ -241,7 +241,7 @@ class News < ActiveRecord::Base end def send_mail - Mailer.run.news_added(self) if Setting.notified_events.include?('news_added') + # Mailer.run.news_added(self) if Setting.notified_events.include?('news_added') end def delete_org_activities diff --git a/app/models/relative_memo.rb b/app/models/relative_memo.rb index 07767c7d6..72430054a 100644 --- a/app/models/relative_memo.rb +++ b/app/models/relative_memo.rb @@ -158,9 +158,9 @@ class RelativeMemo < ActiveRecord::Base end def send_notification - if Setting.notified_events.include?('message_posted') - Mailer.run.message_posted(self) - end + # if Setting.notified_events.include?('message_posted') + # Mailer.run.message_posted(self) + # end end # def plusParentAndForum diff --git a/app/models/wiki_content_observer.rb b/app/models/wiki_content_observer.rb index 3ded4da86..b08127a21 100644 --- a/app/models/wiki_content_observer.rb +++ b/app/models/wiki_content_observer.rb @@ -17,12 +17,12 @@ class WikiContentObserver < ActiveRecord::Observer def after_create(wiki_content) - Mailer.run.wiki_content_added(wiki_content) if Setting.notified_events.include?('wiki_content_added') + # Mailer.run.wiki_content_added(wiki_content) if Setting.notified_events.include?('wiki_content_added') end def after_update(wiki_content) - if wiki_content.text_changed? - Mailer.run.wiki_content_updated(wiki_content) if Setting.notified_events.include?('wiki_content_updated') - end + # if wiki_content.text_changed? + # Mailer.run.wiki_content_updated(wiki_content) if Setting.notified_events.include?('wiki_content_updated') + # end end end diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index c1c5f4f9f..a36adaeaa 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -658,7 +658,7 @@ class CoursesService @state = 7 end else - Mailer.run.join_course_request(course, current_user, params[:role]) + # Mailer.run.join_course_request(course, current_user, params[:role]) CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> role_str,:course_message_id=>current_user.id,:course_message_type=>'JoinCourseRequest',:status=>0) #----------------微信通知---------------------- diff --git a/db/schema.rb b/db/schema.rb index 6dd41fa00..6e305986d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20161208015939) do +ActiveRecord::Schema.define(:version => 20161223030701) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -325,14 +325,16 @@ ActiveRecord::Schema.define(:version => 20161208015939) do add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false + t.integer "repository_id", :null => false + t.string "revision", :null => false t.string "committer" - t.datetime "committed_on", :null => false + t.datetime "committed_on", :null => false t.text "comments" t.date "commit_date" t.string "scmid" t.integer "user_id" + t.integer "project_id" + t.integer "type", :default => 0 end add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" @@ -426,6 +428,14 @@ ActiveRecord::Schema.define(:version => 20161208015939) do add_index "comments", ["author_id"], :name => "index_comments_on_author_id" add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" + create_table "commit_issues", :force => true do |t| + t.string "commit_id" + t.integer "issue_id" + t.integer "project_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "commits", :force => true do |t| t.integer "repository_id" t.string "version" @@ -437,54 +447,123 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.datetime "updated_at", :null => false end - create_table "contest_notifications", :force => true do |t| - t.text "title" + create_table "contest_activities", :force => true do |t| + t.integer "user_id" + t.integer "contest_id" + t.integer "contest_act_id" + t.string "contest_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "contest_activities", ["contest_id"], :name => "index_contest_activities_on_contest_id" + add_index "contest_activities", ["user_id"], :name => "index_contest_activities_on_user_id" + + create_table "contest_member_roles", :force => true do |t| + t.integer "contest_member_id" + t.integer "role_id" + t.boolean "is_current", :default => true + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "contest_member_roles", ["contest_member_id"], :name => "index_contest_member_roles_on_contest_member_id" + add_index "contest_member_roles", ["role_id"], :name => "index_contest_member_roles_on_role_id" + + create_table "contest_members", :force => true do |t| + t.integer "user_id" + t.integer "contest_id" + t.boolean "is_collect", :default => true + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "contest_members", ["contest_id"], :name => "index_contest_members_on_contest_id" + add_index "contest_members", ["user_id"], :name => "index_contest_members_on_user_id" + + create_table "contest_messages", :force => true do |t| + t.integer "user_id" + t.integer "contest_id" + t.integer "contest_message_id" + t.string "course_message_type" + t.boolean "viewed", :default => false t.text "content" + t.integer "status" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "contest_messages", ["contest_id"], :name => "index_contest_messages_on_contest_id" + add_index "contest_messages", ["user_id"], :name => "index_contest_messages_on_user_id" + + create_table "contestant_for_contests", :force => true do |t| + t.integer "student_id" + t.integer "contest_id" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end - create_table "contesting_projects", :force => true do |t| - t.integer "project_id" - t.string "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end + add_index "contestant_for_contests", ["contest_id"], :name => "index_contestant_for_contests_on_contest_id" + add_index "contestant_for_contests", ["student_id"], :name => "index_contestant_for_contests_on_student_id" - create_table "contesting_softapplications", :force => true do |t| - t.integer "softapplication_id" + create_table "contestant_work_projects", :force => true do |t| t.integer "contest_id" + t.integer "work_id" + t.integer "contestant_work_id" + t.integer "project_id" t.integer "user_id" - t.string "description" + t.boolean "is_leader" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.string "reward" end - create_table "contestnotifications", :force => true do |t| - t.integer "contest_id" - t.string "title" - t.string "summary" - t.text "description" - t.integer "author_id" - t.integer "notificationcomments_count" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + add_index "contestant_work_projects", ["contest_id"], :name => "index_contestant_work_projects_on_contest_id" + add_index "contestant_work_projects", ["contestant_work_id"], :name => "index_contestant_work_projects_on_contestant_work_id" + add_index "contestant_work_projects", ["user_id"], :name => "index_contestant_work_projects_on_user_id" + add_index "contestant_work_projects", ["work_id"], :name => "index_contestant_work_projects_on_work_id" + + create_table "contestant_work_scores", :force => true do |t| + t.integer "contestant_work_id" + t.integer "user_id" + t.integer "score" + t.text "comment" + t.integer "reviewer_role" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end + add_index "contestant_work_scores", ["contestant_work_id"], :name => "index_contestant_work_scores_on_contestant_work_id" + add_index "contestant_work_scores", ["user_id"], :name => "index_contestant_work_scores_on_user_id" + + create_table "contestant_works", :force => true do |t| + t.string "name" + t.text "description" + t.integer "work_id" + t.integer "user_id" + t.float "work_score" + t.integer "project_id" + t.integer "work_status" + t.datetime "commit_time" + t.boolean "is_delete", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "contestant_works", ["project_id"], :name => "index_contestant_works_on_project_id" + add_index "contestant_works", ["user_id"], :name => "index_contestant_works_on_user_id" + add_index "contestant_works", ["work_id"], :name => "index_contestant_works_on_work_id" + create_table "contests", :force => true do |t| + t.integer "user_id" t.string "name" - t.string "budget", :default => "" - t.integer "author_id" - t.date "deadline" - t.string "description" - t.integer "commit" - t.string "password" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false + t.text "description" + t.boolean "is_public" + t.boolean "is_delete", :default => false + t.integer "visits", :default => 0 + t.string "invite_code" + t.integer "invite_code_halt", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "course_activities", :force => true do |t| @@ -516,20 +595,6 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.integer "container_id", :default => 0 end - create_table "course_class_post", :id => false, :force => true do |t| - t.integer "班级id", :default => 0, :null => false - t.string "班级名" - t.integer "帖子id", :default => 0, :null => false - t.integer "主贴id" - t.string "帖子标题", :default => "", :null => false - t.text "帖子内容" - t.integer "帖子用户id" - t.integer "帖子回复数", :default => 0, :null => false - t.integer "最后回帖id" - t.datetime "发帖时间", :null => false - t.datetime "帖子更新时间", :null => false - end - create_table "course_contributor_scores", :force => true do |t| t.integer "course_id" t.integer "user_id" @@ -598,8 +663,8 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.string "code" t.integer "time" t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "location" t.string "term" t.string "string" @@ -609,27 +674,28 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.string "class_period" t.integer "school_id" t.text "description" - t.integer "status", :default => 1 - t.integer "attachmenttype", :default => 2 + t.integer "status", :default => 1 + t.integer "attachmenttype", :default => 2 t.integer "lft" t.integer "rgt" - t.integer "is_public", :limit => 1, :default => 1 - t.integer "inherit_members", :limit => 1, :default => 1 - t.integer "open_student", :default => 0 - t.integer "outline", :default => 0 - t.integer "publish_resource", :default => 0 - t.integer "is_delete", :default => 0 + t.integer "is_public", :limit => 1, :default => 1 + t.integer "inherit_members", :limit => 1, :default => 1 + t.integer "open_student", :default => 0 + t.integer "outline", :default => 0 + t.integer "publish_resource", :default => 0 + t.integer "is_delete", :default => 0 t.integer "end_time" t.string "end_term" - t.integer "is_excellent", :default => 0 - t.integer "excellent_option", :default => 0 - t.integer "is_copy", :default => 0 - t.integer "visits", :default => 0 + t.integer "is_excellent", :default => 0 + t.integer "excellent_option", :default => 0 + t.integer "is_copy", :default => 0 + t.integer "visits", :default => 0 t.integer "syllabus_id" t.string "invite_code" t.string "qrcode" - t.integer "qrcode_expiretime", :default => 0 - t.integer "invite_code_halt", :limit => 1, :default => 0 + t.integer "qrcode_expiretime", :default => 0 + t.integer "professional_level_id", :limit => 1 + t.integer "invite_code_halt", :limit => 1, :default => 0 end add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true @@ -680,6 +746,14 @@ ActiveRecord::Schema.define(:version => 20161208015939) do add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" + create_table "data_exceptions", :force => true do |t| + t.string "message" + t.integer "container_id" + t.string "container_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "delayed_jobs", :force => true do |t| t.integer "priority", :default => 0, :null => false t.integer "attempts", :default => 0, :null => false @@ -696,6 +770,11 @@ ActiveRecord::Schema.define(:version => 20161208015939) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + create_table "disciplines", :force => true do |t| + t.string "name" + t.integer "professional_level_id", :limit => 1 + end + create_table "discuss_demos", :force => true do |t| t.string "title" t.text "body" @@ -821,13 +900,11 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.integer "exercise_status" t.integer "user_id" t.integer "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.datetime "publish_time" t.datetime "end_time" t.integer "show_result" - t.integer "question_random", :default => 0 - t.integer "choice_random", :default => 0 end create_table "first_pages", :force => true do |t| @@ -944,6 +1021,7 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.integer "is_open", :default => 0 t.datetime "simi_time" t.integer "score_open", :default => 1 + t.integer "anonymous_appeal", :default => 0 end add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" @@ -970,6 +1048,7 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.integer "no_anon_penalty", :default => 1 + t.integer "appeal_penalty", :default => 0 end create_table "homework_detail_programings", :force => true do |t| @@ -1014,6 +1093,10 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.datetime "updated_at", :null => false end + create_table "innodb_monitor", :id => false, :force => true do |t| + t.integer "a" + end + create_table "invite_lists", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -1545,9 +1628,12 @@ ActiveRecord::Schema.define(:version => 20161208015939) do end create_table "professional_levels", :force => true do |t| - t.string "level" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "level" + end + + create_table "professions", :force => true do |t| + t.string "name" + t.integer "discipline_id", :limit => 1 end create_table "project_infos", :force => true do |t| @@ -1610,7 +1696,6 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.boolean "hidden_repo", :default => false, :null => false t.integer "attachmenttype", :default => 1 t.integer "user_id" - t.integer "dts_test", :default => 0 t.string "enterprise_name" t.integer "organization_id" t.integer "project_new_type" @@ -1618,6 +1703,11 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.integer "forked_from_project_id" t.integer "forked_count" t.integer "publish_resource", :default => 0 + t.integer "boards_count", :default => 0 + t.integer "news_count", :default => 0 + t.integer "acts_count", :default => 0 + t.integer "journals_count", :default => 0 + t.integer "boards_reply_count", :default => 0 t.integer "visits", :default => 0 t.integer "hot", :default => 0 t.string "invite_code" @@ -1922,6 +2012,7 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.integer "work_status", :default => 0 t.datetime "commit_time" t.integer "is_delete", :default => 0 + t.integer "appeal_penalty", :default => 0 end add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" @@ -1939,13 +2030,23 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.integer "score" t.text "comment" t.integer "reviewer_role" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "appeal_status", :default => 0 end add_index "student_works_scores", ["student_work_id"], :name => "student_work_id" add_index "student_works_scores", ["user_id"], :name => "user_id" + create_table "student_works_scores_appeals", :force => true do |t| + t.integer "student_works_score_id" + t.integer "user_id" + t.text "comment" + t.integer "appeal_status" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "students_for_courses", :force => true do |t| t.integer "student_id" t.integer "course_id" @@ -2004,8 +2105,8 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.string "title" t.text "description" t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "eng_name" t.integer "syllabus_type" t.integer "credit" @@ -2014,8 +2115,9 @@ ActiveRecord::Schema.define(:version => 20161208015939) do t.integer "practice_hours" t.string "applicable_major" t.string "pre_course" - t.integer "visits", :default => 0 - t.integer "des_status", :default => 0 + t.integer "visits", :default => 0 + t.integer "des_status", :default => 0 + t.integer "professional_level_id", :limit => 1 end add_index "syllabuses", ["user_id"], :name => "index_syllabuses_on_user_id" @@ -2379,6 +2481,17 @@ ActiveRecord::Schema.define(:version => 20161208015939) do add_index "wikis", ["project_id"], :name => "wikis_project_id" + create_table "work_detail_groups", :force => true do |t| + t.integer "work_id" + t.integer "min_num" + t.integer "max_num" + t.boolean "base_on_project" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "work_detail_groups", ["work_id"], :name => "index_work_detail_groups_on_work_id" + create_table "workflows", :force => true do |t| t.integer "tracker_id", :default => 0, :null => false t.integer "old_status_id", :default => 0, :null => false @@ -2396,6 +2509,25 @@ ActiveRecord::Schema.define(:version => 20161208015939) do add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" + create_table "works", :force => true do |t| + t.string "name" + t.integer "user_id" + t.text "description" + t.date "publish_time" + t.date "end_time" + t.integer "work_type" + t.integer "contest_id" + t.boolean "is_delete", :default => false + t.boolean "score_open", :default => true + t.boolean "is_open", :default => false + t.integer "work_status" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "works", ["contest_id"], :name => "index_works_on_contest_id" + add_index "works", ["user_id"], :name => "index_works_on_user_id" + create_table "works_categories", :force => true do |t| t.string "category" t.datetime "created_at", :null => false diff --git a/lib/tasks/homework_endtime.rake b/lib/tasks/homework_endtime.rake index d5d894122..e59148071 100644 --- a/lib/tasks/homework_endtime.rake +++ b/lib/tasks/homework_endtime.rake @@ -10,7 +10,7 @@ namespace :homework_endtime do homework_common.course.student.each do |s| homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :status => true) # 发送邮件通知 - Mailer.homework_endtime__added(homework_common, s.student_id).deliver + # Mailer.homework_endtime__added(homework_common, s.student_id).deliver end end end diff --git a/lib/tasks/homework_evaluation.rake b/lib/tasks/homework_evaluation.rake index 6a1b09947..3aba5235e 100644 --- a/lib/tasks/homework_evaluation.rake +++ b/lib/tasks/homework_evaluation.rake @@ -53,7 +53,7 @@ namespace :homework_evaluation do homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) end # 邮件通知 - Mailer.send_mail_anonymous_comment_open(homework_common).deliver + # Mailer.send_mail_anonymous_comment_open(homework_common).deliver else #作业数小于2,启动失败, 只给老师发 # status==4 发送失败 @@ -65,7 +65,7 @@ namespace :homework_evaluation do end end # 邮件通知 - Mailer.send_mail_anonymous_comment_fail(homework_common).deliver + # Mailer.send_mail_anonymous_comment_fail(homework_common).deliver end end end @@ -109,7 +109,7 @@ namespace :homework_evaluation do homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3) end # 邮件通知 - Mailer.send_mail_anonymous_comment_close(homework_common).deliver + # Mailer.send_mail_anonymous_comment_close(homework_common).deliver end end end diff --git a/lib/tasks/homework_publishtime.rake b/lib/tasks/homework_publishtime.rake index c18d529e1..23aae2925 100644 --- a/lib/tasks/homework_publishtime.rake +++ b/lib/tasks/homework_publishtime.rake @@ -34,7 +34,7 @@ namespace :homework_publishtime do homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id) end # 邮件通知 - Mailer.run.homework_added(homework) + # Mailer.run.homework_added(homework) end end Rails.logger.info("log--------------------------------homework_publish end") diff --git a/lib/tasks/issue_due_date.rake b/lib/tasks/issue_due_date.rake index 8ea6d9ed0..f4207579e 100644 --- a/lib/tasks/issue_due_date.rake +++ b/lib/tasks/issue_due_date.rake @@ -17,7 +17,7 @@ namespace :issue_due_date do end end # issue截止时间邮件提醒 - Mailer.issue_due_date(issue).deliver + # Mailer.issue_due_date(issue).deliver end end end