From 3f5e840e76a045589b98b5c8373f3d1b7c652f93 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 28 Nov 2016 16:08:04 +0800 Subject: [PATCH 001/110] =?UTF-8?q?commit=5Fdiff=20json=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E6=88=90OpenStruct=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index af1e2d336..daad5ba41 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -581,11 +581,9 @@ update def commit_diff # 顶部导航 @project_menu_type = 5 - @commit_diff = @g.commit_diff(@project.gpid, params[:changeset]) - diff = @commit_diff.first + diff = ActiveSupport::JSON.decode(@commit_diff.to_json).first diff = OpenStruct.new(diff) - logger.info("######################{diff}") @diff_file = Trustie::Gitlab::Diff::File.new(diff) # diff_file.diff_lines.each_with_index do |line, index| From ece69b9e7a76d6b2400d487fae26191e7d6a33ce Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 28 Nov 2016 17:16:43 +0800 Subject: [PATCH 002/110] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=AF=94=E8=BE=83=E5=8A=9F=E8=83=BD=EF=BC=88=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=EF=BC=8C=E5=BE=85=E8=AE=BE=E8=AE=A1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 15 ----- app/views/repositories/commit_diff.html.erb | 63 ++++++++------------- 2 files changed, 23 insertions(+), 55 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index daad5ba41..ce03962e1 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -586,21 +586,6 @@ update diff = OpenStruct.new(diff) @diff_file = Trustie::Gitlab::Diff::File.new(diff) - # diff_file.diff_lines.each_with_index do |line, index| - # type = line.type - # last_line = line.new_pos - # line_old = line.old_pos.to_s - # - # - # if type == 'match' - # ## 表示没有修改,两个都要显示行号 - # output += "|#{line_old.center(4)}|#{last_line.to_s.center(4)}|#{line.text}\n" - # else - # old_line = type == 'new' ? ' '*4: line_old - # new_line = type == 'old' ? ' '*4: last_line - # output += "|#{old_line.to_s.center(4)}|#{new_line.to_s.center(4)}|#{line.text}\n" - # end - # end @commit_details = @g.commit(@project.gpid, params[:changeset]) render :layout => 'base_projects' end diff --git a/app/views/repositories/commit_diff.html.erb b/app/views/repositories/commit_diff.html.erb index bb6ccc393..cf6ff3237 100644 --- a/app/views/repositories/commit_diff.html.erb +++ b/app/views/repositories/commit_diff.html.erb @@ -9,46 +9,29 @@
<%= @commit_details.message %>
- - - - - - - - <%= @diff_file.diff_lines %> <% @diff_file.diff_lines.each_with_index do |line, index| %> - - <%= type = ldine.type %> - <%= last_line = line.new_pos %> - <%= line_old = line.old_pos.to_s %> -
- - <%= cd.new_path %> - -
-
- - - <% line_num = diff_line_num(cd.diff) %> - <% diff_content = diff_content(cd.diff) %> - <% syntax_highlight_lines(cd.new_path, Redmine::CodesetUtil.to_utf8_by_setting(diff_content)).each do |line| %> - - - <% if line[0,1] == "-" %> - - <% elsif line[0,1] == "+" %> - - <% else%> - - <% end %> - - <% line_num += 1 %> - <% end %> - -
- <%= line_num %> -
<%= line.html_safe %>
<%= line.html_safe %>
<%= line.html_safe %>
-
+ <%= line[0] %> + <% type = line.type %> + <% last_line = line.new_pos.to_s %> + <% line_old = line.old_pos.to_s %> + + + <% if type == "match" %> + + + + + + <% else %> + <% old_line = type == 'new' ? ' '*4: line_old %> + <% new_line = type == 'old' ? ' '*4: last_line %> + + + + + + <% end %> + +
<%= line_old.center(4) %><%= last_line.center(4) %><%= line.text %>
<%= old_line.to_s.center(4) %><%= new_line.to_s.center(4) %><%= line.text %>
<% end %> From 3f35b7f806f5e7f9415f59d1bbeacaaa89e90369 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Nov 2016 09:36:38 +0800 Subject: [PATCH 003/110] =?UTF-8?q?=E8=B4=B4=E5=90=A7=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E6=94=B9=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/memos_controller.rb | 71 +++++++++-------- app/controllers/users_controller.rb | 11 +++ app/helpers/application_helper.rb | 2 + app/models/memo.rb | 15 +++- app/views/forums/_show_topics.html.erb | 3 +- app/views/layouts/base_forums.html.erb | 5 +- app/views/memos/_memo_all_replies.html.erb | 77 +++++++++++++++++++ app/views/memos/_reply_message.html.erb | 31 ++++++++ app/views/memos/quote.js.erb | 10 +-- app/views/memos/show.html.erb | 58 +------------- app/views/memos/show.js.erb | 1 + app/views/praise_tread/praise_plus.js.erb | 10 +-- app/views/users/reply_detail.js.erb | 4 +- app/views/users/show_all_replies.js.erb | 2 +- .../20161128072528_add_root_id_to_memos.rb | 26 +++++++ db/schema.rb | 31 +++++--- 16 files changed, 243 insertions(+), 114 deletions(-) create mode 100644 app/views/memos/_memo_all_replies.html.erb create mode 100644 app/views/memos/_reply_message.html.erb create mode 100644 app/views/memos/show.js.erb create mode 100644 db/migrate/20161128072528_add_root_id_to_memos.rb diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index a47ddf787..69a1b829c 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -14,17 +14,17 @@ class MemosController < ApplicationController # layout 'base_memos' def quote - @subject = @memo.subject - @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') - - @content = "#{ll(Setting.default_language, :text_user_wrote, @memo.author)}
  " - @content << @memo.content.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n") + "\n\n
" - @content = "
" << @content - #@content = "> #{ll(Setting.default_language, :text_user_wrote, @memo.author)}\n> " - #@content << @memo.content.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" - #@content_html = textilizable(@content) - @temp = Memo.new - @temp.content = @content + # @subject = @memo.subject + # @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + # + # @content = "#{ll(Setting.default_language, :text_user_wrote, @memo.author)}
  " + # @content << @memo.content.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n") + "
\n\n
" + # @content = "
" << @content + # #@content = "> #{ll(Setting.default_language, :text_user_wrote, @memo.author)}\n> " + # #@content << @memo.content.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" + # #@content_html = textilizable(@content) + # @temp = Memo.new + # @temp.content = @content end def new @@ -47,6 +47,8 @@ class MemosController < ApplicationController @quote = params[:quote] end + + #unless params[:quote].nil? # @quote = params[:quote][:quote] #end @@ -55,6 +57,10 @@ class MemosController < ApplicationController @memo.forum_id = params[:forum_id] @memo.author_id = User.current.id + if params[:memo][:parent_id] + @memo.root_id = (Memo.find params[:memo][:parent_id]).root_id.nil? ? params[:memo][:parent_id].to_i : (Memo.find params[:memo][:parent_id]).root_id + end + @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) @memo.content = @quote + @memo.content respond_to do |format| @@ -111,32 +117,37 @@ class MemosController < ApplicationController @memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示 @memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1)) - page = params[:page] - if params[:r] && page.nil? - offset = @memo.children.where("#{Memo.table_name}.id < ?", params[:r].to_i).count - page = 1 + offset / pre_count - else - - end - @reply_count = @memo.children.count - @reply_pages = Paginator.new @reply_count, pre_count, page - @replies = @memo.children. - includes(:author, :attachments). - reorder("#{Memo.table_name}.created_at DESC"). - limit(@reply_pages.per_page). - offset(@reply_pages.offset). - all + # page = params[:page] + # if params[:r] && page.nil? + # offset = @memo.children.where("#{Memo.table_name}.id < ?", params[:r].to_i).count + # page = 1 + offset / pre_count + # else + # end + + # @reply_count = @memo.children.count + # @reply_pages = Paginator.new @reply_count, pre_count, page + # @replies = @memo.children. + # includes(:author, :attachments). + # reorder("#{Memo.table_name}.created_at DESC"). + # limit(@reply_pages.per_page). + # offset(@reply_pages.offset). + # all + + @replies = Memo.where("root_id = #{@memo.id}").reorder("created_at desc") + @reply_count = @replies.count + @replies = get_no_children_comments_all @replies + @limit_count = @replies.count + @page = params[:page] ? params[:page].to_i + 1 : 0 + @limit = 10 + @replies = @replies[@page * @limit..@page * @limit + 9] @memo_new = Memo.new @my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is null").count @my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is not null").count - # @memo = Memo.find_by_id(params[:id]) - # @forum = Forum.find(params[:forum_id]) - # @replies = @memo.replies - # @mome_new = Memo.new respond_to do |format| + format.js format.html {render :layout=> 'base_forums'}#:layout=> 'base_forums', format.json { render json: @memo } format.xml { render xml: @memo } diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index aebc82b14..26b09e6e8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -155,6 +155,8 @@ class UsersController < ApplicationController @comment = Comment.find params[:comment].to_i when 'Journal','is_project_issue' @comment = Journal.find params[:comment].to_i + when 'Memo' + @comment = Memo.find params[:comment].to_i end @user_activity_id = params[:user_activity_id] @parent_id = params[:parent_id] if params[:parent_id] @@ -299,6 +301,15 @@ class UsersController < ApplicationController @root.update_column('updated_at', Time.now) @count = @root.journals_for_messages.count @comments = @root.journals_for_messages.reorder("created_on desc").limit(3) + when 'Memo' + @root = reply.root + comment = Memo.new + comment.author = User.current + comment.forum = reply.forum + comment.content = params[:reply_message] + comment.subject = "#{@root.subject}" + comment.root_id = reply.root_id + reply.children << comment end update_course_activity(@root.class.to_s,@root.id) update_user_activity(@root.class.to_s,@root.id) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8301407ae..5b74f631a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3422,6 +3422,8 @@ def get_reply_by_type type, reply_id reply = Journal.find reply_id when 'Syllabus' reply = JournalsForMessage.find reply_id + when 'Memo' + reply = Memo.find reply_id end reply end diff --git a/app/models/memo.rb b/app/models/memo.rb index 793d534d4..2ea4a63eb 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -79,7 +79,8 @@ class Memo < ActiveRecord::Base "lock", "sticky", "parent_id", - "replies_count" + "replies_count", + "root_id" after_create :add_author_as_watcher, :reset_counters!, :send_mail, :send_message,:create_memo_ealasticsearch_index after_update :update_memo_ealasticsearch_index @@ -126,6 +127,18 @@ class Memo < ActiveRecord::Base Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added') end + def creator_user + self.author + end + + def created_time + self.created_on + end + + def content_detail + self.content + end + # 公共贴吧消息记录 # 原则:贴吧创始人;发帖人,wanglingchun(特殊用户) def send_message diff --git a/app/views/forums/_show_topics.html.erb b/app/views/forums/_show_topics.html.erb index c3b8b4dbe..80b77a79b 100644 --- a/app/views/forums/_show_topics.html.erb +++ b/app/views/forums/_show_topics.html.erb @@ -18,7 +18,8 @@
- <%= link_to (topic.replies_count), forum_memo_path(topic.forum, topic),:target =>'_blank',:class=>'linkGrey2' %> + <% replies_count = Memo.where("root_id = #{topic.id}").count %> + <%= link_to (replies_count), forum_memo_path(topic.forum, topic),:target =>'_blank',:class=>'linkGrey2' %> <%= get_praise_num(topic)%>
diff --git a/app/views/layouts/base_forums.html.erb b/app/views/layouts/base_forums.html.erb index b57feb5bd..f5509959b 100644 --- a/app/views/layouts/base_forums.html.erb +++ b/app/views/layouts/base_forums.html.erb @@ -7,13 +7,10 @@ <%= csrf_meta_tag %> <%= favicon %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','application','prettify', 'nyan', :media => 'all' %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','application','prettify', :media => 'all' %> <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'application', 'jquery.colorbox-min') %> - <%= import_ke(enable_at: false, prettify: true, init_activity: false) %> - - <%= heads_for_theme %> <%= call_hook :view_layouts_base_html_head %> diff --git a/app/views/memos/_memo_all_replies.html.erb b/app/views/memos/_memo_all_replies.html.erb new file mode 100644 index 000000000..33e699d9b --- /dev/null +++ b/app/views/memos/_memo_all_replies.html.erb @@ -0,0 +1,77 @@ +<% @replies.each do |reply| %> + + +
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> +
+
+
+ <%= render :partial => 'users/message_contents', :locals => {:comment => reply, :type => 'Memo', :user_activity_id => @memo.id}%> +
+
+

<%= reply.content.gsub(/script/, "script ").html_safe %>

+
+
+
+ + + <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %> + + + <%= link_to( + l(:button_reply), + {:action => 'quote', :id => reply}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + <%= link_to( + l(:button_delete), + forum_memo_path(@memo.forum, reply), + :method => :delete, + :id => "delete_reply_#{reply.id}", + :class => 'fr mr20 undis', + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) if @memo.author.id == User.current.id || User.current.admin? %> + +
+
+
+

+
+
+
+<% end %> +<% if @limit_count > @page * @limit + 10 %> +
+
+ + + <%= link_to '点击展开更多回复', forum_memo_path(@memo.forum_id, @memo, :page => @page),:remote=>true %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/memos/_reply_message.html.erb b/app/views/memos/_reply_message.html.erb new file mode 100644 index 000000000..ff8436a84 --- /dev/null +++ b/app/views/memos/_reply_message.html.erb @@ -0,0 +1,31 @@ +
+
+ <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %> +
+
+ <% if User.current.logged? %> +
+ <%= form_for('memo',:url=>forum_memos_path,:method => "post") do |f|%> + <%= f.hidden_field :subject, :required => true, value: reply.subject %> + <%= f.hidden_field :forum_id, :required => true, value: reply.forum_id %> + <%= f.hidden_field :parent_id, :required => true, value: reply.id %> + <%= hidden_field_tag :quote,"",:required => false,:style => 'display:none' %> +
+ + +
+

+ <% end%> +
+ <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %> +
+
+
+
+ \ No newline at end of file diff --git a/app/views/memos/quote.js.erb b/app/views/memos/quote.js.erb index 3dbf9eb95..d757dc7f5 100644 --- a/app/views/memos/quote.js.erb +++ b/app/views/memos/quote.js.erb @@ -1,5 +1,5 @@ -//ckeditor.setData("<%= raw escape_javascript(@content) %>"); -$('#message_quote').html("<%= raw escape_javascript(@temp.content.html_safe) %>"); -$('#quote').val("<%= raw escape_javascript(@content) %>"); -showAndScrollTo("new_memo", "cke_editor01"); -$("img").removeAttr("align"); \ No newline at end of file +if($("#reply_message_<%= @memo.id%>").length > 0) { + $("#reply_message_<%= @memo.id%>").replaceWith("<%= escape_javascript(render :partial => 'memos/reply_message', :locals => {:reply => @memo}) %>"); +}else if($("#reply_to_message_<%= @memo.id%>").length >0) { + $("#reply_to_message_<%= @memo.id%>").replaceWith("

"); +} \ No newline at end of file diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 25732c36b..922afe740 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -4,22 +4,6 @@ <% end %> -
- - <% end %> +
+ <%= render :partial => 'memos/memo_all_replies' %>
diff --git a/app/views/memos/show.js.erb b/app/views/memos/show.js.erb new file mode 100644 index 000000000..8ac3f6194 --- /dev/null +++ b/app/views/memos/show.js.erb @@ -0,0 +1 @@ +$("#more_memo_replies").replaceWith("<%= escape_javascript(render :partial => 'memos/memo_all_replies')%>"); \ No newline at end of file diff --git a/app/views/praise_tread/praise_plus.js.erb b/app/views/praise_tread/praise_plus.js.erb index 29041cd57..c06ad88e5 100644 --- a/app/views/praise_tread/praise_plus.js.erb +++ b/app/views/praise_tread/praise_plus.js.erb @@ -1,13 +1,13 @@ -<% if @obj_type == 'Memo'%> - $('#praise_tread_<%= @obj.id %>').html('<%= j( - render :partial => "/memos/praise_tread",:locals => {:obj => @obj,:user_id => User.current.id,:horizontal => @horizontal} - )%>'); -<% elsif @activity %> +<% if @activity %> <% if @type.to_s == 'activity' %> $('#praise_count_<%=@user_activity_id %>').html('<%=j(render :partial=> "praise_tread/praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"activity"})%>'); <% else @type.to_s == 'reply' %> $('#reply_praise_count_<%=@user_activity_id %>').html('<%=j(render :partial=> "praise_tread/praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"reply"})%>'); <% end %> +<% elsif @obj_type == 'Memo'%> + $('#praise_tread_<%= @obj.id %>').html('<%= j( + render :partial => "/memos/praise_tread",:locals => {:obj => @obj,:user_id => User.current.id,:horizontal => @horizontal} + )%>'); <% else %> $('#praise_tread_<%= @obj.id %>').html('<%= j( render :partial => "/praise_tread/praise_tread",:locals => {:obj => @obj,:user_id => User.current.id,:horizontal => @horizontal} diff --git a/app/views/users/reply_detail.js.erb b/app/views/users/reply_detail.js.erb index 097d36720..23de03a76 100644 --- a/app/views/users/reply_detail.js.erb +++ b/app/views/users/reply_detail.js.erb @@ -43,6 +43,8 @@ $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(re window.location.href = "<%=org_document_comment_path(:id => @root.id, :organization_id => @root.organization.id) %>"; <% end %> <% elsif @type == 'Syllabus' %> -$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'syllabuses/syllabus_post_reply', :locals => {:activity => @root, :user_activity_id => @user_activity_id}) %>"); + $("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'syllabuses/syllabus_post_reply', :locals => {:activity => @root, :user_activity_id => @user_activity_id}) %>"); +<% elsif @type == 'Memo' %> + window.location.href = "<%=forum_memo_path(@root.forum_id, @root) %>"; <% end %> sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); \ No newline at end of file diff --git a/app/views/users/show_all_replies.js.erb b/app/views/users/show_all_replies.js.erb index d5d2a6b54..b02cb0add 100644 --- a/app/views/users/show_all_replies.js.erb +++ b/app/views/users/show_all_replies.js.erb @@ -5,7 +5,7 @@ $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'projects/journal_comment_reply', :locals => {:comment => @comment.parent, :user_activity_id => @user_activity_id, :parent_id => @parent_id})%>"); <% elsif params[:type] == 'is_project_issue' %> $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'projects/project_issue_comments_reply', :locals => {:comment => @comment.parent, :user_activity_id => @user_activity_id, :parent_id => @parent_id})%>"); - <% elsif (@comment.class.to_s == 'Message' || @comment.class.to_s == 'BlogComment' || @comment.class.to_s == 'OrgDocumentComment') %> + <% elsif (@comment.class.to_s == 'Message' || @comment.class.to_s == 'BlogComment' || @comment.class.to_s == 'OrgDocumentComment' || @comment.class.to_s == 'Memo') %> $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/journal_comment_reply', :locals => {:comment => @comment.parent, :type => params[:type], :user_activity_id => @user_activity_id, :parent_id => @parent_id})%>"); <% else %> $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/comment_reply', :locals => {:comment => @comment.parent, :type => params[:type], :user_activity_id => @user_activity_id, :parent_id => @parent_id})%>"); diff --git a/db/migrate/20161128072528_add_root_id_to_memos.rb b/db/migrate/20161128072528_add_root_id_to_memos.rb new file mode 100644 index 000000000..2f7d60ea1 --- /dev/null +++ b/db/migrate/20161128072528_add_root_id_to_memos.rb @@ -0,0 +1,26 @@ +class AddRootIdToMemos < ActiveRecord::Migration + def change + add_column :memos, :root_id, :integer + add_index :memos, :root_id + + def get_base_parent comment + comm = comment + while comm.parent + comm = comm.parent + end + comm + end + + count = Memo.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + Memo.page(i).per(30).each do |memo| + unless memo.parent.nil? + parent = get_base_parent memo + memo.update_column('root_id', parent.id) + end + end + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a57b4fa4c..bd3645e2c 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 => 20161125024643) do +ActiveRecord::Schema.define(:version => 20161128072528) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -325,16 +325,14 @@ ActiveRecord::Schema.define(:version => 20161125024643) 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" @@ -518,6 +516,20 @@ ActiveRecord::Schema.define(:version => 20161125024643) 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" @@ -996,10 +1008,6 @@ ActiveRecord::Schema.define(:version => 20161125024643) 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" @@ -1211,8 +1219,11 @@ ActiveRecord::Schema.define(:version => 20161125024643) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.integer "viewed_count", :default => 0 + t.integer "root_id" end + add_index "memos", ["root_id"], :name => "index_memos_on_root_id" + create_table "message_alls", :force => true do |t| t.integer "user_id" t.integer "message_id" From 4c45518913b614628949cacf0cffb5a87c297de0 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Nov 2016 10:22:54 +0800 Subject: [PATCH 004/110] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=97=A0=E6=B3=95=E6=90=9C=E7=B4=A2=E8=8B=B1=E6=96=87?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E7=9A=84=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 1f8cdd275..d8fc9ce28 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -175,8 +175,10 @@ class AdminController < ApplicationController def courses @name = params[:name].to_s.strip.downcase if @name && @name != "" - @courses = Course.select{ |course| course.teacher && ((course.teacher.show_name).include?(@name) || course.name.include?(@name))} - @courses = @courses.sort{|x, y| y.created_at <=> x.created_at} + all_user_ids = Course.all.map{|course| course.tea_id} + user_str_ids = search_user_by_name all_user_ids, @name + user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")" + @courses = Course.where("tea_id in #{user_ids} or name like '%#{@name}%'").reorder("created_at desc") else @courses = Course.order('created_at desc') end From 7ea9f000540645763f050ccdd7e2e99f8d49bbed Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 29 Nov 2016 10:52:57 +0800 Subject: [PATCH 005/110] =?UTF-8?q?pull=20request=20=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=E5=AF=B9=E6=AF=94=E6=98=BE=E7=A4=BA=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 684 +++++++++--------- .../_pull_request_changes.html.erb | 84 +-- app/views/repositories/_change_diff.html.erb | 27 + app/views/repositories/commit_diff.html.erb | 33 +- 4 files changed, 398 insertions(+), 430 deletions(-) create mode 100644 app/views/repositories/_change_diff.html.erb diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 72a1132c9..8e99767aa 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -1,353 +1,331 @@ -# encoding: utf-8 -# 如果你对改模块任何功能不清楚,请不要随便改 -# @Hjqreturn -class PullRequestsController < ApplicationController - before_filter :authorize_logged - before_filter :find_project_and_repository - before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, :update_pull_request, :pull_request_comments, :create_pull_request_comment, :compare_pull_request] - before_filter :member_allowed, :only => [:new, :create] - before_filter :manager_allowed, :only => [:accept_pull_request] - - layout "base_projects" - include PullRequestsHelper - include ApplicationHelper - - require 'ostruct' - - # 返回json格式 - def index - # project_menu_type 为了控制base顶部导航 - @project_menu_type = 6 - # 不符合pullrequest条件的给出提示 - @allow_to_pull_request = allow_pull_request(@project) > 0 - - type = params[:type] - merge_requests = @g.merge_requests(@project.gpid) - merge_requests_count = merge_requests.count - case type - when nil, "1" - @requests = merge_requests.select{|request| request.state == "opened" || request.state == "reopened"} - # 更新统计数字 - project_score = @project.project_score.update_column(:pull_request_num, merge_requests_count) - when "2" - @requests = merge_requests.select{|request| request.state == "merged"} - when "3" - @requests = merge_requests.select{|request| request.state == "closed"} - end - @requests_opened_count = @requests.count - @requests_merged_count = merge_requests.select{|request| request.state == "merged"}.count - @requests_closed_count = merge_requests.select{|request| request.state == "closed"}.count - - @limit = 10 - @is_remote = true - @count = type_count(type, @requests_opened_count, @requests_merged_count, @requests_closed_count) - @pages = Paginator.new @count, @limit, params['page'] || 1 - @offset ||= @pages.offset - @requests = paginateHelper @requests, 10 - respond_to do |format| - format.html - format.js - end - end - - # 主要取源项目和目标项目分支及标识(用户名/版本库名) - # @tip 为空的时候表明发送的pr请求有改动,为1的时候源分支和目标分支没有改动,则不能成功创建 - def new - # project_menu_type 为了控制base顶部导航 - @project_menu_type = 6 - @tip = params[:show_tip] - identifier = get_rep_identifier_by_project @project - @source_project_name = "#{get_user_name(@project.user_id)}/#{identifier}" - @source_rev = @g.branches(@project.gpid).map{|b| b.name} - - # 获取forked源项目信息 - if @project.forked_from_project_id - @forked_project = Project.find(@project.forked_from_project_id) - identifier = get_rep_identifier_by_project @forked_project - @forked_project_name = "#{get_user_name(@forked_project.user_id)}/#{identifier}" - @forked_rev = @g.branches(@forked_project.gpid).map{|b| b.name} - end - end - - # Creates a merge request. - # If the operation is successful, 200 and the newly created merge request is returned. If an error occurs, an error number and a message explaining the reason is returned. - # - # @example - # Gitlab.create_merge_request(5, 'New merge request', - # :source_branch => 'source_branch', :target_branch => 'target_branch') - # Gitlab.create_merge_request(5, 'New merge request', - # :source_branch => 'source_branch', :target_branch => 'target_branch', :assignee_id => 42) - # - # @param [Integer] project The ID of a project. - # @param [String] title The title of a merge request. - # @param [Hash] options A customizable set of options. - # @option options [String] :source_branch (required) The source branch name. - # @option options [String] :target_branch (required) The target branch name. - # @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request. - # @return [Gitlab::ObjectifiedHash] Information about created merge request. - def create - title = params[:title] - description = params[:description] - source_branch = params[:source_branch] - target_branch = params[:target_branch] - target_project_id = params[:target_project_id] - begin - # 如果分支有改动 - if compare_pull_request(source_branch, target_project_id, target_branch) - # 如果传送了目标项目ID即向fork源项目发送请求 - # if params[:forked_project_id] && params[:source_project] == "forked_project_name" - if !params[:target_project_id].blank? - target_project_id = params[:forked_project_id].to_i - request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id) - @fork_project_name = Project.find(params[:target_project_id]).try(:name) - @fork_pr_message = true if @fork_project_name - else - request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch) - respond_to do |format| - format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)} - end - end - else - tip = 1 - respond_to do |format| - format.js{redirect_to new_project_pull_request_path(:show_tip => tip)} - end - end - rescue Gitlab::Error::Forbidden => e - @message = l(:label_pull_request_forbidden) - rescue Gitlab::Error::Conflict => e - @message = l(:label_pull_request_conflic) - rescue Gitlab::Error::NotFound => e - @message = l(:label_pull_request_notfound) - rescue Exception => e - puts e - end - end - - # Compare branch for MR - # 判断源分支和目标分支是否有改动 - # status 为true 表示有改动; false:便是没有改动 - def compare_pull_request source_branch, target_project, target_branch - user_name_source = @project.owner.try(:login) - identifier = @repository.identifier.downcase - git_source_tree = '--git-dir=/home/git/repositories/' + user_name_source + '/' + identifier + '.git' - if target_project - forked_source_project = Project.find(target_project) - user_name_target = forked_source_project.owner.try(:login) - git_target_tree = '--git-dir=/home/git/repositories/' + user_name_target + '/' + identifier + '.git' - git_sourse_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, source_branch) - git_target_commit_id = @g.get_branch_commit_id(forked_source_project.gpid, git_target_tree, target_branch) - else - git_sourse_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, source_branch) - git_target_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, target_branch) - end - status = (git_sourse_commit_id.try(:commit_id) == git_target_commit_id.try(:commit_id) ? false : true) - end - - # @project_menu_type 为了控制base顶部导航 - # merge_when_succeeds - def show - # compare_pull_request source_project, source_branch, target_project, target_branch - # compare_pull_request - @project_menu_type = 6 - @type = params[:type] - @request = @g.merge_request(@project.gpid, params[:id]) - @commits = @g.merge_request_commits(@project.gpid, params[:id].to_i) - @commits_count = @commits.count - # @commits_day = @commits.chunk - @changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes) - @changes_count = @changes.count - @comments = @g.merge_request_comments(@project.gpid, params[:id]).reverse - @comments_count = @comments.count - - @limit = 10 - @is_remote = true - @count = @comments_count - @pages = Paginator.new @count, @limit, params['page'] || 1 - @offset ||= @pages.offset - @comments = paginateHelper @comments, 10 - end - - # Accept a merge request. - # If merge success you get 200 OK. - # Accept a merge request. - # - # @example - # Gitlab.accept_pull_rquest(5, 1) - # - # @param [Integer] project The ID of a project. - # @param [Integer] id The ID of a merge request. - # @return [Gitlab::ObjectifiedHash] - def accept_pull_request - begin - status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid) - PullRequest.create(:pull_request_id => status.id, :user_id => User.current.id, :gpid => status.project_id) - respond_to do |format| - format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)} - end - rescue Exception => e - @message = e.message - end - end - - # Updates a merge request. - # - # @example - # Gitlab.update_merge_request(5, 42, :title => 'New title') - # - # @param [Integer] project The ID of a project. - # @param [Integer] id The ID of a merge request. - # @param [Hash] options A customizable set of options. - # @option options [String] :title The title of a merge request. - # @option options [String] :source_branch The source branch name. - # @option options [String] :target_branch The target branch name. - # @option options [Integer] :assignee_id The ID of a user to assign merge request. - # @option options [String] :state_event New state (close|reopen|merge). - # @return [Gitlab::ObjectifiedHash] Information about updated merge request. - def update_pull_request - begin - @g.update_merge_request(@project.gpid, params[:id], User.current.gid, :state_event => params[:state]) - respond_to do |format| - format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)} - end - rescue Exception => e - @message = e.message - end - end - - # Creates a merge request. - # - # @example - # Gitlab.create_merge_request(5, 'New merge request', - # :source_branch => 'source_branch', :target_branch => 'target_branch') - # Gitlab.create_merge_request(5, 'New merge request', - # :source_branch => 'source_branch', :target_branch => 'target_branch', :assignee_id => 42) - def create_pull_request_comment - content = params[:pull_request_comment] - begin - @comments = @g.create_merge_request_comment(@project.gpid, params[:id], content, User.current.gid) - respond_to do |format| - format.js{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)} - end - rescue Exception => e - @message = e.message - end - end - - # Gets the comments on a merge request. - # - # @example - # Gitlab.merge_request_comments(5, 1) - def pull_request_comments - begin - @comments = @g.merge_request_comments(@project.gpid, params[:id]).reverse - @comments_count = @comments.count - - @limit = 10 - @is_remote = true - @count = @comments_count - @pages = Paginator.new @count, @limit, params['page'] || 1 - @offset ||= @pages.offset - @comments = paginateHelper @comments, 10 - rescue Exception => e - @message = e.message - end - end - - # Get a list of merge request commits. - # Parameters: - # id (required) - The ID of a project - # merge_request_id (required) - The ID of MR - def pull_request_commits - begin - @type = params[:type] - @commits = @g.merge_request_commits(@project.gpid, params[:id]) - @commits_count = @commits.count - - @limit = 10 - @is_remote = true - @count = @commits_count - @pages = Paginator.new @count, @limit, params['page'] || 1 - @offset ||= @pages.offset - @commits = paginateHelper @commits, 10 - rescue Exception => e - @message = e.message - end - end - - # Shows information about the merge request including its files and changes. With GitLab 8.2 the return fields upvotes and downvotes are deprecated and always return 0. - # Parameters: - # id (required) - The ID of a project - # merge_request_id (required) - The ID of MR - def pull_request_changes - - @type = params[:type] - @changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes) - logger.info("###############################{@changes}") - diff = ActiveSupport::JSON.decode(@changes).first - diff = OpenStruct.new(diff) - diff_file = Trustie::Gitlab::Diff::File.new(diff) - logger.info("##############################") - output = '' - diff_file.diff_lines.each_with_index do |line, index| - type = line.type - last_line = line.new_pos - line_old = line.old_pos.to_s - - - if type == 'match' - ## 表示没有修改,两个都要显示行号 - output += "|#{line_old.center(4)}|#{last_line.to_s.center(4)}|#{line.text}\n" - else - old_line = type == 'new' ? ' '*4: line_old - new_line = type == 'old' ? ' '*4: last_line - output += "|#{old_line.to_s.center(4)}|#{new_line.to_s.center(4)}|#{line.text}\n" - end - end - - @changes_count = @changes.count - - @is_remote = true - @count = @changes_count - @pages = Paginator.new @count, @limit, params['page'] || 1 - @offset ||= @pages.offset - @changes = paginateHelper @changes, 10 - - end - - private - # post 相关操作权限控制 - # 项目管理员可操作 - def manager_allowed - unless is_project_manager?(User.current.id, @project.id) - return render_403 - end - end - - # 项目成员可操作 - def member_allowed - unless User.current.member_of?(@project) - return render_403 - end - end - - def authorize_logged - if !User.current.logged? - redirect_to signin_path - return - end - end - - def connect_gitlab - @g = Gitlab.client - end - - def find_project_and_repository - @project = Project.find(params[:project_id]) - render_404 if @project.gpid.blank? - @repository = Repository.where(:project_id => @project.id, :type => "Repository::Gitlab").first - rescue ActiveRecord::RecordNotFound - render_404 - end - -end +# encoding: utf-8 +# 如果你对改模块任何功能不清楚,请不要随便改 +# @Hjqreturn +class PullRequestsController < ApplicationController + before_filter :authorize_logged + before_filter :find_project_and_repository + before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, :update_pull_request, :pull_request_comments, :create_pull_request_comment, :compare_pull_request] + before_filter :member_allowed, :only => [:new, :create] + before_filter :manager_allowed, :only => [:accept_pull_request] + + layout "base_projects" + include PullRequestsHelper + include ApplicationHelper + + require 'ostruct' + + # 返回json格式 + def index + # project_menu_type 为了控制base顶部导航 + @project_menu_type = 6 + # 不符合pullrequest条件的给出提示 + @allow_to_pull_request = allow_pull_request(@project) > 0 + + type = params[:type] + merge_requests = @g.merge_requests(@project.gpid) + merge_requests_count = merge_requests.count + case type + when nil, "1" + @requests = merge_requests.select{|request| request.state == "opened" || request.state == "reopened"} + # 更新统计数字 + project_score = @project.project_score.update_column(:pull_request_num, merge_requests_count) + when "2" + @requests = merge_requests.select{|request| request.state == "merged"} + when "3" + @requests = merge_requests.select{|request| request.state == "closed"} + end + @requests_opened_count = @requests.count + @requests_merged_count = merge_requests.select{|request| request.state == "merged"}.count + @requests_closed_count = merge_requests.select{|request| request.state == "closed"}.count + + @limit = 10 + @is_remote = true + @count = type_count(type, @requests_opened_count, @requests_merged_count, @requests_closed_count) + @pages = Paginator.new @count, @limit, params['page'] || 1 + @offset ||= @pages.offset + @requests = paginateHelper @requests, 10 + respond_to do |format| + format.html + format.js + end + end + + # 主要取源项目和目标项目分支及标识(用户名/版本库名) + # @tip 为空的时候表明发送的pr请求有改动,为1的时候源分支和目标分支没有改动,则不能成功创建 + def new + # project_menu_type 为了控制base顶部导航 + @project_menu_type = 6 + @tip = params[:show_tip] + identifier = get_rep_identifier_by_project @project + @source_project_name = "#{get_user_name(@project.user_id)}/#{identifier}" + @source_rev = @g.branches(@project.gpid).map{|b| b.name} + + # 获取forked源项目信息 + if @project.forked_from_project_id + @forked_project = Project.find(@project.forked_from_project_id) + identifier = get_rep_identifier_by_project @forked_project + @forked_project_name = "#{get_user_name(@forked_project.user_id)}/#{identifier}" + @forked_rev = @g.branches(@forked_project.gpid).map{|b| b.name} + end + end + + # Creates a merge request. + # If the operation is successful, 200 and the newly created merge request is returned. If an error occurs, an error number and a message explaining the reason is returned. + # + # @example + # Gitlab.create_merge_request(5, 'New merge request', + # :source_branch => 'source_branch', :target_branch => 'target_branch') + # Gitlab.create_merge_request(5, 'New merge request', + # :source_branch => 'source_branch', :target_branch => 'target_branch', :assignee_id => 42) + # + # @param [Integer] project The ID of a project. + # @param [String] title The title of a merge request. + # @param [Hash] options A customizable set of options. + # @option options [String] :source_branch (required) The source branch name. + # @option options [String] :target_branch (required) The target branch name. + # @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request. + # @return [Gitlab::ObjectifiedHash] Information about created merge request. + def create + title = params[:title] + description = params[:description] + source_branch = params[:source_branch] + target_branch = params[:target_branch] + target_project_id = params[:target_project_id] + begin + # 如果分支有改动 + if compare_pull_request(source_branch, target_project_id, target_branch) + # 如果传送了目标项目ID即向fork源项目发送请求 + # if params[:forked_project_id] && params[:source_project] == "forked_project_name" + if !params[:target_project_id].blank? + target_project_id = params[:forked_project_id].to_i + request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id) + @fork_project_name = Project.find(params[:target_project_id]).try(:name) + @fork_pr_message = true if @fork_project_name + else + request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch) + respond_to do |format| + format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)} + end + end + else + tip = 1 + respond_to do |format| + format.js{redirect_to new_project_pull_request_path(:show_tip => tip)} + end + end + rescue Gitlab::Error::Forbidden => e + @message = l(:label_pull_request_forbidden) + rescue Gitlab::Error::Conflict => e + @message = l(:label_pull_request_conflic) + rescue Gitlab::Error::NotFound => e + @message = l(:label_pull_request_notfound) + rescue Exception => e + puts e + end + end + + # Compare branch for MR + # 判断源分支和目标分支是否有改动 + # status 为true 表示有改动; false:便是没有改动 + def compare_pull_request source_branch, target_project, target_branch + user_name_source = @project.owner.try(:login) + identifier = @repository.identifier.downcase + git_source_tree = '--git-dir=/home/git/repositories/' + user_name_source + '/' + identifier + '.git' + if target_project + forked_source_project = Project.find(target_project) + user_name_target = forked_source_project.owner.try(:login) + git_target_tree = '--git-dir=/home/git/repositories/' + user_name_target + '/' + identifier + '.git' + git_sourse_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, source_branch) + git_target_commit_id = @g.get_branch_commit_id(forked_source_project.gpid, git_target_tree, target_branch) + else + git_sourse_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, source_branch) + git_target_commit_id = @g.get_branch_commit_id(@project.gpid, git_source_tree, target_branch) + end + status = (git_sourse_commit_id.try(:commit_id) == git_target_commit_id.try(:commit_id) ? false : true) + end + + # @project_menu_type 为了控制base顶部导航 + # merge_when_succeeds + def show + # compare_pull_request source_project, source_branch, target_project, target_branch + # compare_pull_request + @project_menu_type = 6 + @type = params[:type] + @request = @g.merge_request(@project.gpid, params[:id]) + @commits = @g.merge_request_commits(@project.gpid, params[:id].to_i) + @commits_count = @commits.count + # @commits_day = @commits.chunk + @changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes) + @changes_count = @changes.count + @comments = @g.merge_request_comments(@project.gpid, params[:id]).reverse + @comments_count = @comments.count + + @limit = 10 + @is_remote = true + @count = @comments_count + @pages = Paginator.new @count, @limit, params['page'] || 1 + @offset ||= @pages.offset + @comments = paginateHelper @comments, 10 + end + + # Accept a merge request. + # If merge success you get 200 OK. + # Accept a merge request. + # + # @example + # Gitlab.accept_pull_rquest(5, 1) + # + # @param [Integer] project The ID of a project. + # @param [Integer] id The ID of a merge request. + # @return [Gitlab::ObjectifiedHash] + def accept_pull_request + begin + status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid) + PullRequest.create(:pull_request_id => status.id, :user_id => User.current.id, :gpid => status.project_id) + respond_to do |format| + format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)} + end + rescue Exception => e + @message = e.message + end + end + + # Updates a merge request. + # + # @example + # Gitlab.update_merge_request(5, 42, :title => 'New title') + # + # @param [Integer] project The ID of a project. + # @param [Integer] id The ID of a merge request. + # @param [Hash] options A customizable set of options. + # @option options [String] :title The title of a merge request. + # @option options [String] :source_branch The source branch name. + # @option options [String] :target_branch The target branch name. + # @option options [Integer] :assignee_id The ID of a user to assign merge request. + # @option options [String] :state_event New state (close|reopen|merge). + # @return [Gitlab::ObjectifiedHash] Information about updated merge request. + def update_pull_request + begin + @g.update_merge_request(@project.gpid, params[:id], User.current.gid, :state_event => params[:state]) + respond_to do |format| + format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)} + end + rescue Exception => e + @message = e.message + end + end + + # Creates a merge request. + # + # @example + # Gitlab.create_merge_request(5, 'New merge request', + # :source_branch => 'source_branch', :target_branch => 'target_branch') + # Gitlab.create_merge_request(5, 'New merge request', + # :source_branch => 'source_branch', :target_branch => 'target_branch', :assignee_id => 42) + def create_pull_request_comment + content = params[:pull_request_comment] + begin + @comments = @g.create_merge_request_comment(@project.gpid, params[:id], content, User.current.gid) + respond_to do |format| + format.js{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)} + end + rescue Exception => e + @message = e.message + end + end + + # Gets the comments on a merge request. + # + # @example + # Gitlab.merge_request_comments(5, 1) + def pull_request_comments + begin + @comments = @g.merge_request_comments(@project.gpid, params[:id]).reverse + @comments_count = @comments.count + + @limit = 10 + @is_remote = true + @count = @comments_count + @pages = Paginator.new @count, @limit, params['page'] || 1 + @offset ||= @pages.offset + @comments = paginateHelper @comments, 10 + rescue Exception => e + @message = e.message + end + end + + # Get a list of merge request commits. + # Parameters: + # id (required) - The ID of a project + # merge_request_id (required) - The ID of MR + def pull_request_commits + begin + @type = params[:type] + @commits = @g.merge_request_commits(@project.gpid, params[:id]) + @commits_count = @commits.count + + @limit = 10 + @is_remote = true + @count = @commits_count + @pages = Paginator.new @count, @limit, params['page'] || 1 + @offset ||= @pages.offset + @commits = paginateHelper @commits, 10 + rescue Exception => e + @message = e.message + end + end + + # Shows information about the merge request including its files and changes. With GitLab 8.2 the return fields upvotes and downvotes are deprecated and always return 0. + # Parameters: + # id (required) - The ID of a project + # merge_request_id (required) - The ID of MR + def pull_request_changes + @type = params[:type] + @changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes) + + @changes_count = @changes.count + @limit = 10 + @is_remote = true + @count = @changes_count + @pages = Paginator.new @count, @limit, params['page'] || 1 + @offset ||= @pages.offset + @changes = paginateHelper @changes, 10 + + end + + private + # post 相关操作权限控制 + # 项目管理员可操作 + def manager_allowed + unless is_project_manager?(User.current.id, @project.id) + return render_403 + end + end + + # 项目成员可操作 + def member_allowed + unless User.current.member_of?(@project) + return render_403 + end + end + + def authorize_logged + if !User.current.logged? + redirect_to signin_path + return + end + end + + def connect_gitlab + @g = Gitlab.client + end + + def find_project_and_repository + @project = Project.find(params[:project_id]) + render_404 if @project.gpid.blank? + @repository = Repository.where(:project_id => @project.id, :type => "Repository::Gitlab").first + rescue ActiveRecord::RecordNotFound + render_404 + end + +end diff --git a/app/views/pull_requests/_pull_request_changes.html.erb b/app/views/pull_requests/_pull_request_changes.html.erb index 612fb0f53..897cb9659 100644 --- a/app/views/pull_requests/_pull_request_changes.html.erb +++ b/app/views/pull_requests/_pull_request_changes.html.erb @@ -1,53 +1,31 @@ -<% if !@changes.blank? && @type == "3" %> -
-
-

改动了 <%= @changes_count %> 个文件

-
-
    - <% @changes.each do |change| %> -
  • <%= change['new_path'] %>

  • - <% end %> -
-
- <% @changes.each do |change| %> - -
- - - <% diff = ActiveSupport::JSON.decode(change['diff']).first %> - <% diff = OpenStruct.new(diff) %> - <% diff_file = Trustie::Gitlab::Diff::File.new(diff) %> - <% diff_file.diff_lines.each_with_index do |line, index| %> - <% type = line.type %> - <% last_line = line.new_pos %> - <% line_old = line.old_pos.to_s %> - <% if type == 'match' %> - - <% output += "|#{line_old.center(4)}|#{last_line.to_s.center(4)}|#{line.text}\n" %> - <% else %> - <% old_line = type == 'new' ? ' '*4: line_old %> - <% new_line = type == 'old' ? ' '*4: last_line %> - <% output += "|#{old_line.to_s.center(4)}|#{new_line.to_s.center(4)}|#{line.text}\n" %> - <% end %> - <% end %> - <%# line_num = diff_line_num(change['diff']) %> - <%# diff_content = diff_content(change['diff']) %> - - -
-
- <% end %> - -
-
-
    - <%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%> -
-
-
-
-<% end %> +<% if !@changes.blank? && @type == "3" %> +
+
+

改动了 <%= @changes_count %> 个文件

+
+
    + <% @changes.each do |change| %> +
  • <%= change['new_path'] %>

  • + <% end %> +
+
+ <% @changes.each do |change| %> + +
+ <%= render 'repositories/change_diff', :local => {:change => change} %> +
+ <% end %> + +
+
+
    + <%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%> +
+
+
+
+<% end %> diff --git a/app/views/repositories/_change_diff.html.erb b/app/views/repositories/_change_diff.html.erb new file mode 100644 index 000000000..81bae132e --- /dev/null +++ b/app/views/repositories/_change_diff.html.erb @@ -0,0 +1,27 @@ +<% diff = ActiveSupport::JSON.decode(change.to_json) %> +<% diff = OpenStruct.new(diff) %> +<% @diff_file = Trustie::Gitlab::Diff::File.new(diff) %> +<% @diff_file.diff_lines.each_with_index do |line, index| %> + <% type = line.type %> + <% last_line = line.new_pos.to_s %> + <% line_old = line.old_pos.to_s %> + + + <% if type == "match" %> + + + + + + <% else %> + <% old_line = type == 'new' ? ' '*4: line_old %> + <% new_line = type == 'old' ? ' '*4: last_line %> + + + + + + <% end %> + +
<%= line_old.center(4) %><%= last_line.center(4) %><%= line.text %>
<%= old_line.to_s.center(4) %><%= new_line.to_s.center(4) %><%= line.text %>
+<% end %> \ No newline at end of file diff --git a/app/views/repositories/commit_diff.html.erb b/app/views/repositories/commit_diff.html.erb index cf6ff3237..d78465cdb 100644 --- a/app/views/repositories/commit_diff.html.erb +++ b/app/views/repositories/commit_diff.html.erb @@ -9,29 +9,14 @@
<%= @commit_details.message %>
- <% @diff_file.diff_lines.each_with_index do |line, index| %> - <%= line[0] %> - <% type = line.type %> - <% last_line = line.new_pos.to_s %> - <% line_old = line.old_pos.to_s %> - - - <% if type == "match" %> - - - - - - <% else %> - <% old_line = type == 'new' ? ' '*4: line_old %> - <% new_line = type == 'old' ? ' '*4: last_line %> - - - - - - <% end %> - -
<%= line_old.center(4) %><%= last_line.center(4) %><%= line.text %>
<%= old_line.to_s.center(4) %><%= new_line.to_s.center(4) %><%= line.text %>
+ <% @commit_diff.each do |commit_diff| %> + +
+ <%= render 'repositories/change_diff', :local => {:change => commit_diff} %> +
<% end %> From 896f8a2ac79a4b18e369fc2bf6426107ec25afd6 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Nov 2016 11:03:05 +0800 Subject: [PATCH 006/110] =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E6=B4=BB=E8=B7=83?= =?UTF-8?q?=E5=BA=A6=E4=B8=AA=E6=95=B0=E4=B8=BA0=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_course_activity_users.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/courses/_course_activity_users.html.erb b/app/views/courses/_course_activity_users.html.erb index 459f60f3d..cffd383e6 100644 --- a/app/views/courses/_course_activity_users.html.erb +++ b/app/views/courses/_course_activity_users.html.erb @@ -1,4 +1,5 @@ -<% unless contributor_course_scor(course.id).count == 0 %> +<% count = contributor_course_scor(course.id).select{|ccs| ccs.con_score != 0 && !ccs.con_score.nil?}.count %> +<% unless count == 0 %>

    From fcadf65688dabf8b1a154680e3351142736fdd1c Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Nov 2016 11:14:35 +0800 Subject: [PATCH 007/110] =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E5=88=97=E8=A1=A8=EF=BC=9A=E5=88=A0=E9=99=A4=E6=88=90=E5=91=98?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=88=90=E5=91=98=E5=88=97=E8=A1=A8=E6=9C=AA?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/delete_member.js.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/courses/delete_member.js.erb b/app/views/courses/delete_member.js.erb index 89588f4c1..4e31a87c1 100644 --- a/app/views/courses/delete_member.js.erb +++ b/app/views/courses/delete_member.js.erb @@ -1,5 +1,9 @@ hideModal(); -$("#member_li_<%=params[:member_id] %>").html(""); +var all_indexes = $("#member_li_<%=params[:member_id] %>").nextAll().find("td:first-child"); +for(var i = 0; i < all_indexes.length; i++){ + $(all_indexes[i]).html(parseInt($(all_indexes[i]).html()) - 1); +} +$("#member_li_<%=params[:member_id] %>").remove(); $("#st_groups").html("<%=escape_javascript(render :partial => 'new_groups_name', :locals => {:course_groups => @course_groups}) %>"); $("#group_children_list").html("<%= escape_javascript( render :partial => 'layouts/group_children_list', :locals => {:course => @course})%>"); $("#student_number").html("<%= studentCount(@course) %>"); From cb67e136d699cee9ba6a88324e77c3794a412231 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Nov 2016 14:06:25 +0800 Subject: [PATCH 008/110] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=9A=84=E5=85=B3?= =?UTF-8?q?=E8=81=94=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/_relate_projects.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/student_work/_relate_projects.html.erb b/app/views/student_work/_relate_projects.html.erb index b538d2aa6..c6a372a47 100644 --- a/app/views/student_work/_relate_projects.html.erb +++ b/app/views/student_work/_relate_projects.html.erb @@ -23,7 +23,7 @@

    <%= link_to project.members.count, allow_visit ? member_project_path(project) : 'javascript:void(0)', :class => "c_blue" %>成员  | <%= link_to project.project_score.issue_num, allow_visit ? project_issues_path(project) : 'javascript:void(0)', :class => "c_blue" %>问题  | - <%= link_to project.project_score.attach_num, allow_visit ? file_project_path(project) : 'javascript:void(0)', :class => "c_blue" %>资源 + <%= link_to project.project_score.changeset_num, visible_repository?(project) ? ({:controller => 'repositories', :action => 'show', :id => project, :repository_id => gitlab_repository(project).try(:identifier)}) : 'javascript:void(0)', :class => "c_blue" %>提交

From 97f40e4697f4291e670d0ec85c3f3ca581ca79ce Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Nov 2016 14:38:26 +0800 Subject: [PATCH 009/110] =?UTF-8?q?=E5=8C=BF=E8=AF=84=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_evaluation_un_group_member_work.html.erb | 16 +++++++++++++++- .../student_work/_evaluation_un_work.html.erb | 14 +++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/views/student_work/_evaluation_un_group_member_work.html.erb b/app/views/student_work/_evaluation_un_group_member_work.html.erb index 347bea20e..23bef1cb0 100644 --- a/app/views/student_work/_evaluation_un_group_member_work.html.erb +++ b/app/views/student_work/_evaluation_un_group_member_work.html.erb @@ -27,7 +27,21 @@
<% if st.student_score.nil? %> - 未参与 + <% pro = @homework.student_work_projects.where("user_id = #{st.user_id}").first + if pro.nil? || pro.student_work_id == "" || pro.student_work_id.nil? + work = st + else + work = StudentWork.find pro.student_work_id + end %> + <% if @homework.homework_detail_manual.comment_status < 2 %> + 未参与 + <% elsif @homework.homework_detail_manual.comment_status == 2 && work.student_works_evaluation_distributions.count != 0 %> + 待匿评 + <% elsif @homework.homework_detail_manual.comment_status == 3 && work.student_works_evaluation_distributions.count != 0 %> + 未评分 + <% else %> + 迟交 + <% end %> <% else %> <%= format("%.1f", st.student_score) %> <% end %> diff --git a/app/views/student_work/_evaluation_un_work.html.erb b/app/views/student_work/_evaluation_un_work.html.erb index 9b247f3d6..42985806c 100644 --- a/app/views/student_work/_evaluation_un_work.html.erb +++ b/app/views/student_work/_evaluation_un_work.html.erb @@ -69,7 +69,19 @@ <% if @homework.anonymous_comment == 0%> <% if student_work.student_score.nil? %> - 未参与 + <% if student_work.work_status != 0 %> + <% if @homework.homework_detail_manual.comment_status < 2 %> + 未参与 + <% elsif @homework.homework_detail_manual.comment_status >= 2 && student_work.student_works_evaluation_distributions.count == 0 %> + 迟交 + <% elsif @homework.homework_detail_manual.comment_status == 2 && student_work.student_works_evaluation_distributions.count != 0 %> + 待匿评 + <% elsif @homework.homework_detail_manual.comment_status == 3 && student_work.student_works_evaluation_distributions.count != 0 %> + 未评分 + <% end %> + <% else %> + -- + <% end %> <% else %> <%=format("%.1f",student_work.student_score) %> <% end %> From 4814c1db3d1efce400ba56dd5d866d1937ca73bd Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 29 Nov 2016 15:29:30 +0800 Subject: [PATCH 010/110] =?UTF-8?q?=E5=8F=A0=E5=B1=82=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E3=80=81=E8=B5=9E=E7=9A=84=E6=98=BE=E9=9A=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_blog_comment_show_replies.html.erb | 2 +- app/views/courses/_history.html.erb | 2 +- app/views/issues/_issue_replies.html.erb | 2 +- app/views/memos/_memo_all_replies.html.erb | 2 +- app/views/messages/_course_show_replies.html.erb | 2 +- app/views/messages/_org_show_replies.html.erb | 2 +- app/views/messages/_project_show_replies.html.erb | 2 +- app/views/news/_news_replies_detail.html.erb | 2 +- .../_document_show_replies.html.erb | 2 +- .../organizations/_org_course_homework.html.erb | 2 +- .../organizations/_org_course_message.html.erb | 2 +- app/views/organizations/_org_course_news.html.erb | 2 +- .../organizations/_org_project_issue.html.erb | 2 +- app/views/organizations/_project_message.html.erb | 2 +- app/views/praise_tread/praise_minus.js.erb | 2 +- app/views/praise_tread/praise_plus.js.erb | 2 +- app/views/projects/_comment_reply_detail.html.erb | 10 +++++----- app/views/projects/_history.html.erb | 2 +- .../_project_issue_comments_reply_detail.html.erb | 12 ++++++------ .../projects/_project_issue_expand_show.html.erb | 2 +- .../projects/_project_message_replies.html.erb | 2 +- app/views/projects/_project_news_replies.html.erb | 2 +- app/views/users/_comment_reply_detail.html.erb | 14 +++++++------- app/views/users/_message_replies.html.erb | 2 +- app/views/users/_news_replies.html.erb | 2 +- app/views/words/_journal_reply_items.html.erb | 2 +- 26 files changed, 41 insertions(+), 41 deletions(-) diff --git a/app/views/blog_comments/_blog_comment_show_replies.html.erb b/app/views/blog_comments/_blog_comment_show_replies.html.erb index 3a3e8ef81..23cabb67d 100644 --- a/app/views/blog_comments/_blog_comment_show_replies.html.erb +++ b/app/views/blog_comments/_blog_comment_show_replies.html.erb @@ -19,7 +19,7 @@
- + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> diff --git a/app/views/courses/_history.html.erb b/app/views/courses/_history.html.erb index eb7ecff7a..a0b526eee 100644 --- a/app/views/courses/_history.html.erb +++ b/app/views/courses/_history.html.erb @@ -25,7 +25,7 @@
<% ids = 'project_respond_form_'+ journal.id.to_s%> - + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>journal, :user_activity_id=>journal.id,:type=>"reply"}%> <% if reply_allow %> diff --git a/app/views/issues/_issue_replies.html.erb b/app/views/issues/_issue_replies.html.erb index e67040138..c23cabe1b 100644 --- a/app/views/issues/_issue_replies.html.erb +++ b/app/views/issues/_issue_replies.html.erb @@ -24,7 +24,7 @@
- + <%= render :partial => "praise_tread/praise", :locals => {:activity => comment, :user_activity_id => comment.id, :type => "reply"} %> diff --git a/app/views/memos/_memo_all_replies.html.erb b/app/views/memos/_memo_all_replies.html.erb index 33e699d9b..05ec1c1df 100644 --- a/app/views/memos/_memo_all_replies.html.erb +++ b/app/views/memos/_memo_all_replies.html.erb @@ -36,7 +36,7 @@
- + <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %> diff --git a/app/views/messages/_course_show_replies.html.erb b/app/views/messages/_course_show_replies.html.erb index e56d19406..3ea86596f 100644 --- a/app/views/messages/_course_show_replies.html.erb +++ b/app/views/messages/_course_show_replies.html.erb @@ -18,7 +18,7 @@
- + <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %> diff --git a/app/views/messages/_org_show_replies.html.erb b/app/views/messages/_org_show_replies.html.erb index df1b2c301..9b63c80ed 100644 --- a/app/views/messages/_org_show_replies.html.erb +++ b/app/views/messages/_org_show_replies.html.erb @@ -18,7 +18,7 @@
- + <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %> diff --git a/app/views/messages/_project_show_replies.html.erb b/app/views/messages/_project_show_replies.html.erb index b2f22aecb..637fade8a 100644 --- a/app/views/messages/_project_show_replies.html.erb +++ b/app/views/messages/_project_show_replies.html.erb @@ -18,7 +18,7 @@
- + <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %> diff --git a/app/views/news/_news_replies_detail.html.erb b/app/views/news/_news_replies_detail.html.erb index 924a6a329..0f4ede154 100644 --- a/app/views/news/_news_replies_detail.html.erb +++ b/app/views/news/_news_replies_detail.html.erb @@ -19,7 +19,7 @@
- + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> diff --git a/app/views/org_document_comments/_document_show_replies.html.erb b/app/views/org_document_comments/_document_show_replies.html.erb index c3faef645..8507a6272 100644 --- a/app/views/org_document_comments/_document_show_replies.html.erb +++ b/app/views/org_document_comments/_document_show_replies.html.erb @@ -20,7 +20,7 @@
- + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index e6d94042d..f78a22e6f 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -356,7 +356,7 @@
- + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> diff --git a/app/views/organizations/_org_course_message.html.erb b/app/views/organizations/_org_course_message.html.erb index ea074344d..aa3237643 100644 --- a/app/views/organizations/_org_course_message.html.erb +++ b/app/views/organizations/_org_course_message.html.erb @@ -112,7 +112,7 @@ <%= link_to reply.try(:author).try(:realname), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(reply.created_on) %> - + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
diff --git a/app/views/organizations/_org_course_news.html.erb b/app/views/organizations/_org_course_news.html.erb index 6b2146cb1..bbb7b84eb 100644 --- a/app/views/organizations/_org_course_news.html.erb +++ b/app/views/organizations/_org_course_news.html.erb @@ -81,7 +81,7 @@ <%= link_to comment.try(:author).try(:realname), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> - + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%>
diff --git a/app/views/organizations/_org_project_issue.html.erb b/app/views/organizations/_org_project_issue.html.erb index 42f725d12..48814eb23 100644 --- a/app/views/organizations/_org_project_issue.html.erb +++ b/app/views/organizations/_org_project_issue.html.erb @@ -92,7 +92,7 @@ <%= link_to reply.try(:user).try(:realname), user_url_in_org(reply.user_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(reply.created_on) %> - + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
diff --git a/app/views/organizations/_project_message.html.erb b/app/views/organizations/_project_message.html.erb index ae11b0042..fadb29c9e 100644 --- a/app/views/organizations/_project_message.html.erb +++ b/app/views/organizations/_project_message.html.erb @@ -91,7 +91,7 @@ <%= link_to reply.try(:author).try(:realname), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(reply.created_on) %> - + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
diff --git a/app/views/praise_tread/praise_minus.js.erb b/app/views/praise_tread/praise_minus.js.erb index b55624930..057ecb8bd 100644 --- a/app/views/praise_tread/praise_minus.js.erb +++ b/app/views/praise_tread/praise_minus.js.erb @@ -2,7 +2,7 @@ <% if @type.to_s == 'activity' %> $('#praise_count_<%=@user_activity_id %>').html('<%= j(render :partial=> "praise_tread/praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"activity"})%>'); <% else @type.to_s == 'reply' %> - $('#reply_praise_count_<%=@user_activity_id %>').html('<%=j(render :partial=> "praise_tread/praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"reply"})%>'); + $('.reply_praise_count_<%=@user_activity_id %>').html('<%=j(render :partial=> "praise_tread/praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"reply"})%>'); <% end %> <% else %> $('#praise_tread').html('<%= j( diff --git a/app/views/praise_tread/praise_plus.js.erb b/app/views/praise_tread/praise_plus.js.erb index c06ad88e5..5edc8c4cf 100644 --- a/app/views/praise_tread/praise_plus.js.erb +++ b/app/views/praise_tread/praise_plus.js.erb @@ -2,7 +2,7 @@ <% if @type.to_s == 'activity' %> $('#praise_count_<%=@user_activity_id %>').html('<%=j(render :partial=> "praise_tread/praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"activity"})%>'); <% else @type.to_s == 'reply' %> - $('#reply_praise_count_<%=@user_activity_id %>').html('<%=j(render :partial=> "praise_tread/praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"reply"})%>'); + $('.reply_praise_count_<%=@user_activity_id %>').html('<%=j(render :partial=> "praise_tread/praise", :locals => {:activity=>@obj, :user_activity_id=>@user_activity_id,:type=>"reply"})%>'); <% end %> <% elsif @obj_type == 'Memo'%> $('#praise_tread_<%= @obj.id %>').html('<%= j( diff --git a/app/views/projects/_comment_reply_detail.html.erb b/app/views/projects/_comment_reply_detail.html.erb index f6e2b8fb3..9c29a8ae9 100644 --- a/app/views/projects/_comment_reply_detail.html.erb +++ b/app/views/projects/_comment_reply_detail.html.erb @@ -1,7 +1,7 @@
<%= link_to image_tag(url_to_avatar(comment.creator_user), :width => "33", :height => "33"), user_path(comment.creator_user.id), :alt => "用户头像" %>
-
+
<%= link_to comment.creator_user.show_name, user_path(comment.creator_user.id), :class => "content-username" %> <%= time_from_now(comment.respond_to?(:created_on) ? comment.created_on : comment.created_at) %>
@@ -16,10 +16,10 @@ <%= comment.content_detail.html_safe %> <% end %>
-
+
- - +
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> @@ -31,7 +31,7 @@ :title => l(:button_reply)) %> - +
diff --git a/app/views/projects/_history.html.erb b/app/views/projects/_history.html.erb index d9abdf47b..4c9e48391 100644 --- a/app/views/projects/_history.html.erb +++ b/app/views/projects/_history.html.erb @@ -16,7 +16,7 @@
<% ids = 'project_respond_form_'+ journal.id.to_s%> - + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>journal, :user_activity_id=>journal.id,:type=>"reply"}%> <% if journal.user == User.current|| User.current.admin? %> diff --git a/app/views/projects/_project_issue_comments_reply_detail.html.erb b/app/views/projects/_project_issue_comments_reply_detail.html.erb index 58b9f941e..e3a675fc5 100644 --- a/app/views/projects/_project_issue_comments_reply_detail.html.erb +++ b/app/views/projects/_project_issue_comments_reply_detail.html.erb @@ -1,7 +1,7 @@
<%= link_to image_tag(url_to_avatar(comment.creator_user), :width => "33", :height => "33"), user_path(comment.creator_user.id), :alt => "用户头像" %>
-
+
<%= link_to comment.creator_user.show_name, user_path(comment.creator_user.id), :class => "content-username" %> <%= time_from_now(comment.respond_to?(:created_on) ? comment.created_on : comment.created_at) %>
@@ -16,13 +16,13 @@ <%= comment.content_detail.html_safe %> <% end %>
-
+
- - +
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - + <%= link_to( l(:button_reply), {:controller => 'users' ,:action => 'reply_to_comment', :reply_id => comment.id, :type => 'Issue', :user_activity_id => user_activity_id, :parent_id => parent_id, :is_project => true}, @@ -31,7 +31,7 @@ :title => l(:button_reply)) %> - +
diff --git a/app/views/projects/_project_issue_expand_show.html.erb b/app/views/projects/_project_issue_expand_show.html.erb index 6ea9442dc..2debb7789 100644 --- a/app/views/projects/_project_issue_expand_show.html.erb +++ b/app/views/projects/_project_issue_expand_show.html.erb @@ -29,7 +29,7 @@
- + <%= render :partial => "praise_tread/praise", :locals => {:activity => comment, :user_activity_id => comment.id, :type => "reply"} %> diff --git a/app/views/projects/_project_message_replies.html.erb b/app/views/projects/_project_message_replies.html.erb index 91eec6cf5..1fefb172c 100644 --- a/app/views/projects/_project_message_replies.html.erb +++ b/app/views/projects/_project_message_replies.html.erb @@ -20,7 +20,7 @@
- + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> diff --git a/app/views/projects/_project_news_replies.html.erb b/app/views/projects/_project_news_replies.html.erb index 6b6d9e1fc..2ca86b314 100644 --- a/app/views/projects/_project_news_replies.html.erb +++ b/app/views/projects/_project_news_replies.html.erb @@ -29,7 +29,7 @@
- + <%= render :partial => "praise_tread/praise", :locals => {:activity => comment, :user_activity_id => comment.id, :type => "reply"} %> diff --git a/app/views/users/_comment_reply_detail.html.erb b/app/views/users/_comment_reply_detail.html.erb index 23382d972..12cd6874a 100644 --- a/app/views/users/_comment_reply_detail.html.erb +++ b/app/views/users/_comment_reply_detail.html.erb @@ -1,7 +1,7 @@
<%= link_to image_tag(url_to_avatar(comment.creator_user), :width => "33", :height => "33"), user_path(comment.creator_user), :alt => "用户头像" %>
-
+
<%= link_to comment.creator_user.show_name, user_path(comment.creator_user), :class => "content-username" %> <%= time_from_now(comment.respond_to?(:created_on) ? comment.created_on : comment.created_at) %>
@@ -16,16 +16,16 @@ <%= comment.content_detail.html_safe %> <% end %>
-
+
- - +
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> <% if type == 'Message' %> <% topic = comment.root %> <% if !topic.locked? && authorize_for('messages', 'reply') %> - + <%= link_to( l(:button_reply), {:controller => 'users' ,:action => 'reply_to_comment', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :parent_id => parent_id}, @@ -36,7 +36,7 @@ <% end %> <% else %> - + <%= link_to( l(:button_reply), {:controller => 'users' ,:action => 'reply_to_comment', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :parent_id => parent_id}, @@ -46,7 +46,7 @@ <% end %> - +
diff --git a/app/views/users/_message_replies.html.erb b/app/views/users/_message_replies.html.erb index 7c834f201..86f5f8220 100644 --- a/app/views/users/_message_replies.html.erb +++ b/app/views/users/_message_replies.html.erb @@ -20,7 +20,7 @@
- + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> <% if type == 'Message' %> diff --git a/app/views/users/_news_replies.html.erb b/app/views/users/_news_replies.html.erb index 8861bd5c5..f14a7557f 100644 --- a/app/views/users/_news_replies.html.erb +++ b/app/views/users/_news_replies.html.erb @@ -29,7 +29,7 @@
- + <%= render :partial => "praise_tread/praise", :locals => {:activity => comment, :user_activity_id => comment.id, :type => "reply"} %> <% if type == 'HomeworkCommon' %> diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index 2e06c1fb1..eefe52bd2 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -36,7 +36,7 @@ <%= format_time reply.created_on %>