From 0ef84d9691df297fe179756adfbc81c704f5eef5 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 8 Oct 2015 14:41:55 +0800 Subject: [PATCH 01/28] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E7=9A=84=E2=80=9C=E9=A1=B9=E7=9B=AE=E7=BC=BA=E9=99=B7=E2=80=9D?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E2=80=9C=E9=A1=B9=E7=9B=AE=E8=BF=9B=E5=B1=95?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_project_issue.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 2c429a93f..9c0fce992 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -10,7 +10,7 @@ <% else %> <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.project.name.to_s+" | 项目缺陷", project_issues_path(activity.project), :class => "newsBlue ml15"%> + <%= link_to activity.project.name.to_s+" | 项目进展", project_issues_path(activity.project), :class => "newsBlue ml15"%>
<%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %> From c5133997faa3de250ca7abb83f555378ae909c03 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 9 Oct 2015 08:42:18 +0800 Subject: [PATCH 02/28] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E9=A1=B9=E7=9B=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_project_issue.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 9c0fce992..02d1940a6 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -10,7 +10,7 @@ <% else %> <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.project.name.to_s+" | 项目进展", project_issues_path(activity.project), :class => "newsBlue ml15"%> + <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%>
<%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %> From 0f6ea4779278965fbb80e6e292d92171a9052d94 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 9 Oct 2015 14:39:40 +0800 Subject: [PATCH 03/28] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E7=9A=84=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 2 + app/views/boards/_course_show.html.erb | 386 +++++------------------ app/views/messages/_course_show.html.erb | 241 +++++++------- app/views/users/_course_message.html.erb | 4 +- public/stylesheets/courses.css | 32 ++ 5 files changed, 253 insertions(+), 412 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 4f3f3ec0d..4f78d61f5 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -37,6 +37,7 @@ class MessagesController < ApplicationController # Show a topic and its replies def show +=begin if @course topic_id = params[:r]?params[:r]:params[:id] parent_id = params[:id] @@ -44,6 +45,7 @@ class MessagesController < ApplicationController redirect_to url return; end +=end @isReply = true page = params[:page] diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index db174f30e..1dd8c655a 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -1,313 +1,91 @@ -
-
-

+<%= javascript_include_tag "/assets/kindeditor/kindeditor", '/assets/kindeditor/pasteimg', "init_activity_KindEditor" %> + + +
+
+
<% if User.current.language == "zh"%> <%= h @board.name %> <% else %> <%= l(:project_module_boards) %> <% end %> - -

- <% if User.current.logged? %> - <%= l(:label_message_new) %> - <% end %> -
-
-
-
- -
-
- -
- -<% if !User.current.logged?%> -
- <%= l(:label_user_login_course_board) %> - <%= link_to l(:label_user_login_new), signin_path %> -
-<% end %> -

讨论区共有<%= @topic_count %>个帖子

-<% if @topics.any? %> - <% @topics.each do |topic| %> -
- <%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %> -
- <% author = topic.author.to_s %> -
- <%= link_to User.current.member_of_course?(@board.course) ? "#{topic.author.show_name}(#{topic.author.login})" : "#{topic.author}" , user_path(topic.author), - :class =>"talkmain_name fl f14",:title=>author, - :style=>'max-width:120px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;' %> -
-

  :

- -

  <%= h(topic.subject) %>

- <% if topic.course_editable_by?(User.current) %> - <%= l(:button_edit) %> - <% end %> - - <%= link_to(l(:button_delete), {:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :class => 'talk_edit fr', - :style => ' margin-right: 10px;') if topic.destroyable_by?(User.current) %> - - <% if topic.sticky? %> - <%= l(:label_board_sticky)%> - <% end %> -
+
- -
-
- <%= topic.content.html_safe %> - -
-
- - - - - <%= link_to_attachments_course topic, :author => false %> - - <%= l(:label_activity_time)%>:  <%= format_time topic.created_on %> - -
- <%= l(:button_reply) %> - -
- - -
-
- <% reply = Message.new(:subject => "RE: #{topic.subject}")%> - <% if !topic.locked? && authorize_for('messages', 'reply') %> - - <% end %> - <% replies_all = topic.children.includes(:author, :attachments, {:board => :project}). - reorder("#{Message.table_name}.created_on DESC").all %> - <% unless replies_all.empty? %> - <% replies_all_i = 0 %> -
-
    - <% replies_all.each do |message| %> - <% replies_all_i=replies_all_i+1 %> -
  • - <%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class => 'Msg_pic' %> -
    - <%= link_to User.current.member_of_course?(@board.course) ? "#{message.author.show_name}(#{message.author.login})" : "#{message.author}", user_path(message.author),:class => 'fl c_orange f14 ' %> -
    -
    - <%= textAreailizable message,:content,:attachments => message.attachments %> - -
    - -
    - <%= format_time(message.created_on) %> - <%= link_to( - - l(:button_delete), - {:controller => 'messages', :action => 'destroy', :id => message.id, :board_id => message.board_id, :is_board => 'true'}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete), - :class => ' linkBlue fr f12' - ) if message.course_destroyable_by?(User.current) %> - <%= link_to( - l(:button_reply), - 'javascript:;', - :nhname =>'showbtn_child_reply', - :class => ' linkBlue fr f12', - :style => 'margin-right: 10px;', - 'data-topic-id' =>message.id, - :title => l(:button_reply)) if !topic.locked? && authorize_for('messages', 'reply') %> -
    -
    - -
  • - <% end %> -
-
- <%if topic.replies_count>2 %> - - <% end %> - <% end %> -
-
-
- - <% end %> -<% else %> -

<%= l(:label_no_data) %>

-<% end %> -
    - <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> - <%= pagination_links_full @topic_pages, @topic_count, :per_page_links => false, :remote => false, :flag => true %> -
-<%# other_formats_links do |f| %> -<%#= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> -<%# end %> - -<% html_title @board.name %> - -<% content_for :header_tags do %> - <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@course}: #{@board}") %> -<% end %> -
-
- \ No newline at end of file + + <% if topic %> + <%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id} %> + <% end %> + <% end %> + <% end %> + + + \ No newline at end of file diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index 2d433d969..6106ee912 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -1,117 +1,146 @@ -
-

- <%= l(:label_board) %> -

-
+<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor","forum" %> + + + +
+
+
+ <%= link_to image_tag(url_to_avatar(@topic.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@topic.author) %> +
+
+ <% if @topic.author.id == User.current.id%> +
+
    +
  • +
      +
    • + <%= link_to( + l(:button_edit), + {:action => 'edit', :id => @topic}, + :class => 'postOptionLink' + ) if @message.course_editable_by?(User.current) %> +
    • +
    • + <%= link_to( + l(:button_delete), + {:action => 'destroy', :id => @topic}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'postOptionLink' + ) if @message.course_destroyable_by?(User.current) %> +
    • +
    +
  • +
+
+ <%end%> + +
+ +
+ <%= link_to @topic.author.name, user_path(@topic.author), :class => "linkBlue2", :target=> "_blank"%>
+
<%= format_date( @topic.created_on)%>
+
+
+ <%= @topic.content.html_safe%> +
+
+
+ <%= link_to_attachments_course @topic, :author => false %> +
+
+
- <%= link_to( - l(:button_delete), - {:action => 'destroy', :id => @topic}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :class => 'talk_edit fr' - ) if @message.course_destroyable_by?(User.current) %> - <%= link_to( - l(:button_edit), - {:action => 'edit', :id => @topic}, - :class => 'talk_edit fr' - ) if @message.course_editable_by?(User.current) %> -
-
<%= @topic.content.html_safe %>
-
<%= link_to_attachments_course @topic, :author => false %>
- -
- <% if User.current.logged? %> - <%= toggle_link l(:button_reply), "reply", :focus => 'message_subject',:class => 'talk_edit fr' %> - <% else %> - <%= link_to l(:button_reply), signin_path,:class => 'talk_edit fr' %> - <% end %> - <%= link_to( - l(:button_quote), - {:action => 'quote', :id => @topic}, - :remote => true, - :method => 'get', - :class => 'talk_edit fr', - :remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %>
-
-<% unless @replies.empty? %> - <% reply_count = 0 %> - <% @replies.each do |message| %> -
"> -
<%= link_to image_tag(url_to_avatar(message.author), :width => '46',:height => '46'), user_path(message.author) %>
-
-
- <%= link_to_user_header message.author,false,:class => 'c_blue fb fl mb10 ' %> - <%= format_time(message.created_on) %> -
-

<%= textAreailizable message,:content,:attachments => message.attachments %>

- <%= link_to_attachments_course message, :author => false %> +
+ <% unless @replies.empty? %> +
+
回复(<%=@reply_count %>)
+
+
+ <% if @reply_count > 2%> + 点击展开更多回复 + <% end %> +
+
+
+ <% @replies.each_with_index do |reply,i| %> +
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
-
- <%= link_to( - l(:button_quote), - {:action => 'quote', :id => message}, - :remote => true, - :method => 'get', - :title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %> - <%= link_to( - #image_tag('edit.png'), - l(:button_edit), - {:action => 'edit', :id => message}, - :title => l(:button_edit) - ) if message.course_editable_by?(User.current) %> - <%= link_to( - #image_tag('delete.png'), - l(:button_delete), - {:action => 'destroy', :id => message}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete) - ) if message.course_destroyable_by?(User.current) %> +
+
<%= reply.author.name%><%= format_date(reply.created_on) %>
+
<%= reply.content.html_safe%>
-
-
- <% end %> -<% end %> -<% if !@topic.locked? && authorize_for_course('messages', 'reply') %> - -<% end %> -
-
    - <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> -
-<% html_title @topic.subject %> + <% end %> +
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => @topic.id, :is_board => 'false'},:method => "post", :remote => true) do |f|%> + + +
+ +
+

+ <% end%> +
+
+
+
+
+
+
\ No newline at end of file diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb index 8ec605567..9ce308014 100644 --- a/app/views/users/_course_message.html.erb +++ b/app/views/users/_course_message.html.erb @@ -15,9 +15,9 @@
<% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.id, :topic_id => activity.id,:host=> Setting.host_course), :class=> "postGrey" %> + <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %> <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.parent_id, :topic_id => activity.id,:host=> Setting.host_course), :class=> "postGrey"%> + <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey"%> <% end %>
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 328570345..81700a106 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1040,3 +1040,35 @@ a:hover.c_grey{ color:#333;} a.postOptionLink {color:#616060; display:block; width:55px; padding:0px 15px;} a.postOptionLink:hover {color:#ffffff; background-color:#15bccf;} +/*讨论区内部样式*/ +.postDetailContainer {padding:15px; border:1px solid #dddddd; background-color:#ffffff;} +.postlabel {background-color:#edf1f2; color:#888888; padding:2px 5px; float:left; margin-bottom:5px;} +.postRightContainer {width:718px; border:1px solid #dddddd; padding:15px; background-color:#ffffff; float:left; margin-bottom:10px;} +.postDetailBanner {height:30px; width:720px; border-bottom:1px solid #efefef;} +.postDetailRow {width:720px; border-bottom:1px solid #efefef; padding:15px 0;} +.postDetailPortrait {width:50px; height:50px; float:left; margin-right:15px;} +.postDetailWrap {width:580px; float:left;} +.postDetailTitle {width:580px; max-width:580px; margin-bottom:5px;} +.postDetailDes {width:580px; max-width:580px; margin-bottom:6px; color:#888888;display:block;overflow:hidden;word-break:keep-all;text-overflow:ellipsis;} +.postDetailDes p,div,em{word-break: break-all;word-wrap: break-word;} +.postDetailCreater {color:#888888; font-size:12px; float:left; margin-right:25px;} +.postDetailDate {color:#888888; font-size:12px; float:left;} +.postDetailReply { margin-top:28px; color:#888888; float:right;} +a.postReplyIcon {background:url(images/post_image_list.png) -40px 2px no-repeat; width:18px; height:18px; float:left;} +a.postReplyIcon:hover {background:url(images/post_image_list.png) -40px -29px no-repeat;} +.postDetailInput {width:713px; height:28px; border:1px solid #d9d9d9; outline:none !important;} +.postAttIcon {background:url(images/post_image_list.png) 0px -91px no-repeat; width:16px; height:16px; padding-left:20px;} +.postAttIcon:hover {background:url(images/post_image_list.png) 0px -113px no-repeat;} +.postThemeContainer {width:720px;} +.postThemeWrap {width:655px; float:left;position: relative} +.postLikeIcon {background:url(images/post_image_list.png) 0px -42px no-repeat ;float:right; padding-left:18px; margin-top:3px;} +.postLikeIcon:hover {background:url(images/post_image_list.png) 0px -64px no-repeat ;} +a.AnnexBtn{ background: url(images/homepage_icon2.png) 0px -343px no-repeat !important; width:70px; height:20px; display:block; padding-left:20px; color:#888888;} +a:hover.AnnexBtn{background: url(images/homepage_icon2.png) -90px -343px no-repeat !important; color:#3598db;} +.postEdit {background:url(images/post_image_list.png) 0px -94px no-repeat; width:18px; height:18px; display:block; float:left;} +.postDelete {background:url(images/post_image_list.png) -42px -93px no-repeat; width:18px; height:18px; display:block; float:right;} +.pageBanner {width:968px; margin:0px auto; border:1px solid #dddddd; background-color: #FFF; padding: 10px 15px; float:left;} +.homepagePostReplyInput {width:543px; height:33px; max-width:543px; max-height:33px; border:1px solid #d9d9d9; outline:none;} +.postRouteContainer {padding:10px 15px; background-color:#ffffff; border:1px solid #dddddd; margin-top:10px; font-size:14px;} +a.postRouteLink {font-weight:bold; color:#484848;} +a.postRouteLink:hover {text-decoration:underline;} From ebb7ed1f1a1000b4265b54fcf6477b0bf5070e41 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 12 Oct 2015 17:19:55 +0800 Subject: [PATCH 04/28] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E5=8D=95?= =?UTF-8?q?=E4=B8=AA=E5=B8=96=E5=AD=90=E9=A1=B5=E9=9D=A2=E7=9A=84=E4=BA=8C?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/boards_controller.rb | 121 ++++++++++--------- app/views/boards/_course_show.html.erb | 28 ++--- app/views/boards/show.html.erb | 17 ++- app/views/boards/show.js.erb | 1 + app/views/messages/_course_show.html.erb | 75 +++++++++--- app/views/messages/_course_show_old.html.erb | 117 ++++++++++++++++++ app/views/messages/_form_course.html.erb | 28 +++-- app/views/messages/_reply_message.html.erb | 34 ++++++ app/views/messages/quote.js.erb | 12 +- config/routes.rb | 7 +- public/stylesheets/courses.css | 5 +- public/stylesheets/new_user.css | 2 +- public/stylesheets/public.css | 2 +- 13 files changed, 331 insertions(+), 118 deletions(-) create mode 100644 app/views/boards/show.js.erb create mode 100644 app/views/messages/_course_show_old.html.erb create mode 100644 app/views/messages/_reply_message.html.erb diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 434ea4470..62f39c04e 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -90,65 +90,66 @@ class BoardsController < ApplicationController end end end + + sort_init 'updated_on', 'desc' + sort_update 'created_on' => "#{Message.table_name}.created_on", + 'replies' => "#{Message.table_name}.replies_count", + 'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)" + + @topic_count = @board ? @board.topics.count : 0 + if @project + @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] + #现在发布帖子的时候置顶功能已经没有了。所以取消这个置顶排序 #{Message.table_name}.sticky DESC, + @topics = @board.topics. + reorder("#{Message.table_name}.created_on desc"). + includes(:last_reply). + limit(@topic_pages.per_page). + offset(@topic_pages.offset). + + preload(:author, {:last_reply => :author}). + all + elsif @course + # + # board_topics = @board ? @board.topics.reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc"). + # includes(:last_reply). + # # limit(@topic_pages.per_page). + # # offset(@topic_pages.offset). + # + # preload(:author, {:last_reply => :author}). + # all : [] + # @topics = paginateHelper board_topics,10 + if (@board) + limit = 10; + #pageno = params[:page]; + #if(pageno == nil || pageno=='') + # dw_topic = nil; + # if( params[:parent_id]!=nil && params[:parent_id]!='' ) + # dw_topic = @board.topics.where(id:params[:parent_id]).first(); + # end + # if( dw_topic != nil ) + # dw_count = @board.topics.where('(sticky>?) or (sticky=? and created_on>?)',dw_topic.sticky,dw_topic.sticky,dw_topic.created_on).count(); + # dw_count = dw_count+1; + # pageno = dw_count%10==0 ? (dw_count/limit) : (dw_count/limit+1) + # end + #end + #if(pageno == nil || pageno=='') + # pageno=1; + #end + @topic_count = @board.topics.count(); + @topic_pages = (params[:page] ? params[:page].to_i + 1 : 0) *10 + @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc"). + limit(limit).offset(@topic_pages).includes(:last_reply). + preload(:author, {:last_reply => :author}).all(); + else + @topics = []; + end + end + + @message = Message.new(:board => @board) + #modify by nwb respond_to do |format| format.js format.html { - sort_init 'updated_on', 'desc' - sort_update 'created_on' => "#{Message.table_name}.created_on", - 'replies' => "#{Message.table_name}.replies_count", - 'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)" - - @topic_count = @board ? @board.topics.count : 0 - if @project - @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] - #现在发布帖子的时候置顶功能已经没有了。所以取消这个置顶排序 #{Message.table_name}.sticky DESC, - @topics = @board.topics. - reorder("#{Message.table_name}.created_on desc"). - includes(:last_reply). - limit(@topic_pages.per_page). - offset(@topic_pages.offset). - - preload(:author, {:last_reply => :author}). - all - elsif @course - # - # board_topics = @board ? @board.topics.reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc"). - # includes(:last_reply). - # # limit(@topic_pages.per_page). - # # offset(@topic_pages.offset). - # - # preload(:author, {:last_reply => :author}). - # all : [] - # @topics = paginateHelper board_topics,10 - if( @board ) - limit = 10; - pageno = params[:page]; - if(pageno == nil || pageno=='') - dw_topic = nil; - if( params[:parent_id]!=nil && params[:parent_id]!='' ) - dw_topic = @board.topics.where(id:params[:parent_id]).first(); - end - if( dw_topic != nil ) - dw_count = @board.topics.where('(sticky>?) or (sticky=? and created_on>?)',dw_topic.sticky,dw_topic.sticky,dw_topic.created_on).count(); - dw_count = dw_count+1; - pageno = dw_count%10==0 ? (dw_count/limit) : (dw_count/limit+1) - end - end - if(pageno == nil || pageno=='') - pageno=1; - end - @topic_count = @board.topics.count(); - @topic_pages = Paginator.new @topic_count, limit, pageno - @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc"). - limit(limit).offset(@topic_pages.offset).includes(:last_reply). - preload(:author, {:last_reply => :author}).all(); - else - @topics = []; - end - end - - @message = Message.new(:board => @board) - #modify by nwb if @project render :action => 'show', :layout => 'base_projects' elsif @course @@ -158,10 +159,10 @@ class BoardsController < ApplicationController } format.atom { @messages = @board.messages. - reorder('created_on DESC'). - includes(:author, :board). - limit(Setting.feeds_limit.to_i). - all + reorder('created_on DESC'). + includes(:author, :board). + limit(Setting.feeds_limit.to_i). + all if @project render_feed(@messages, :title => "#{@project}: #{@board}") elsif @course diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 1dd8c655a..871aa7e39 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -17,18 +17,9 @@ $("#Container").css("width","1000px"); }); -
-
-
- <% if User.current.language == "zh"%> - <%= h @board.name %> - <% else %> - <%= l(:project_module_boards) %> - <% end %> -
-
- <% @topics.each do |topic| if @topics %> + <% if topics%> + <% topics.each do |topic| %> diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index a9c0e9101..6005f9258 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -30,11 +30,20 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> <%#= javascript_include_tag "/assets/kindeditor/kindeditor-min" %> -<% if @project %> + + + <% if @project %> <%= render :partial => 'project_show', locals: {project: @project} %> -<% elsif @course %> - <%= render :partial => 'course_show', locals: {course: @course} %> -<% end %> + <% elsif @course %> +
+
+
+ 课程讨论区 +
+
+ <%= render :partial => 'course_show', :locals => {:topics => @topics, :page => 0} %> +
+ <% end %>
@@ -107,15 +88,15 @@
回复(<%=@reply_count %>)
-
- <% if @reply_count > 2%> - 点击展开更多回复 - <% end %> -
+
<% @replies.each_with_index do |reply,i| %> -
+
<%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
@@ -169,23 +150,5 @@
- -
\ No newline at end of file diff --git a/app/views/messages/_reply_message.html.erb b/app/views/messages/_reply_message.html.erb index 10fbee6e8..3e9550ee2 100644 --- a/app/views/messages/_reply_message.html.erb +++ b/app/views/messages/_reply_message.html.erb @@ -1,4 +1,3 @@ - - - -
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
- <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => reply.id,},:method => "post", :remote => true) do |f|%> + <%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'new_form'} do |f| %> diff --git a/app/views/messages/quote.js.erb b/app/views/messages/quote.js.erb index 965c458e9..78ba0c142 100644 --- a/app/views/messages/quote.js.erb +++ b/app/views/messages/quote.js.erb @@ -6,7 +6,11 @@ $('#quote_quote').html("<%#= raw escape_javascript(@temp.content.html_safe) %>") showAndScrollTo("reply", "message_content"); $('#message_content').scrollTop = $('#message_content').scrollHeight - $('#message_content').clientHeight; $("img").removeAttr("align");*/ -$("#reply_message_<%= @message.id%>").replaceWith("<%= escape_javascript(render :partial => 'reply_message', :locals => {:reply => @message,:temp =>@temp,:subject =>@subject}) %>"); -$(function(){ - init_activity_KindEditor_data(<%= @message.id%>,null,"87%"); -}); \ No newline at end of file +if($("#reply_message_<%= @message.id%>").length > 0) { + $("#reply_message_<%= @message.id%>").replaceWith("<%= escape_javascript(render :partial => 'reply_message', :locals => {:reply => @message,:temp =>@temp,:subject =>@subject}) %>"); + $(function(){ + init_activity_KindEditor_data(<%= @message.id%>,null,"85%"); + }); +}else if($("#reply_to_message_<%= @message.id%>").length >0) { + $("#reply_to_message_<%= @message.id%>").replaceWith("

"); +} \ No newline at end of file diff --git a/public/javascripts/init_activity_KindEditor.js b/public/javascripts/init_activity_KindEditor.js index decbbb341..db871e723 100644 --- a/public/javascripts/init_activity_KindEditor.js +++ b/public/javascripts/init_activity_KindEditor.js @@ -5,7 +5,7 @@ function init_editor(params){ var paramsWidth = params.width == undefined ? "100%" : params.width; var editor = params.kindutil.create(params.textarea, { - resizeType : 1,minWidth:"1px",width:"95%", + resizeType : 1,minWidth:"1px",width:"94%", height:"33px",// == undefined ? "30px":paramsHeight+"px", minHeight:"33px",// == undefined ? "30px":paramsHeight+"px", items:['emoticons'], @@ -25,7 +25,7 @@ function init_editor(params){ $('#reply_image_' + id).addClass('imageFuzzy'); if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(this.edit.html())){ params.submit_btn.hide(); - this.resize("95%", null); + this.resize("94%", null); }else if(edit.html().val().trim() != ""){ params.submit_btn.show(); } @@ -157,5 +157,6 @@ function init_activity_KindEditor_data(id){ }); }); - $(".ke-edit").css("height","33px"); + div_form = $("div[nhname='new_message_" + id + "']"); + $(".ke-edit", div_form).css("height","33px"); } \ No newline at end of file diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 54416e7f4..2da36a991 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1074,4 +1074,4 @@ a.postRouteLink {font-weight:bold; color:#484848;} a.postRouteLink:hover {text-decoration:underline;} .ReplyToMessageContainer {border-bottom:1px solid #e3e3e3; width:632px; margin:0px auto; margin-top:15px; min-height:60px;} -.ReplyToMessageInputContainer {width:282px; float:left;} \ No newline at end of file +.ReplyToMessageInputContainer {width:582px; float:left;} \ No newline at end of file From 53a7b1dda423f587e011e8dc26375520b63af4f9 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 13 Oct 2015 11:03:56 +0800 Subject: [PATCH 06/28] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E5=8A=A8=E6=80=81=E6=8C=89=E6=9C=80=E5=90=8E=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=97=B6=E9=97=B4=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/boards_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 62f39c04e..09a0fc342 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -137,7 +137,7 @@ class BoardsController < ApplicationController #end @topic_count = @board.topics.count(); @topic_pages = (params[:page] ? params[:page].to_i + 1 : 0) *10 - @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc"). + @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) desc"). limit(limit).offset(@topic_pages).includes(:last_reply). preload(:author, {:last_reply => :author}).all(); else From d006c2691b5eef53a4b4fca0d32c9386265cd429 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 13 Oct 2015 13:54:31 +0800 Subject: [PATCH 07/28] =?UTF-8?q?issue=E6=A8=A1=E5=9D=97=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E9=97=AE=E9=A2=98=E6=97=B6=EF=BC=8C=E7=BB=99?= =?UTF-8?q?=E5=87=BA=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF=E2=80=9C=E8=AF=B7?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E9=97=AE=E9=A2=98=E5=90=8D=E7=A7=B0=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 670f5c51a..29c038226 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -47,7 +47,7 @@ <%= form_tag({:controller => 'issues', :action => 'index', :project_id => @project},:remote=>'true', :method => :get,:id=>"issue_query_form", :class => 'query_form') do %> <%= hidden_field_tag 'set_filter', '1' %> From b9b7f6fa9e501e7d6b36070b83fab6358107068f Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 13 Oct 2015 16:51:44 +0800 Subject: [PATCH 08/28] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E7=95=99=E8=A8=80=E5=8A=A8=E6=80=81=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 6 ++ app/models/principal_activity.rb | 34 ++++++ app/models/user.rb | 6 ++ .../users/_course_journalsformessage.html.erb | 6 +- .../users/_user_journalsformessage.html.erb | 101 ++++++++++++++++++ ...51013081912_create_principal_activities.rb | 12 +++ db/schema.rb | 25 +++-- spec/factories/principal_activities.rb | 10 ++ spec/models/principal_activity_spec.rb | 5 + 9 files changed, 191 insertions(+), 14 deletions(-) create mode 100644 app/models/principal_activity.rb create mode 100644 app/views/users/_user_journalsformessage.html.erb create mode 100644 db/migrate/20151013081912_create_principal_activities.rb create mode 100644 spec/factories/principal_activities.rb create mode 100644 spec/models/principal_activity_spec.rb diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index dde34abfd..72ef9ee88 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -56,6 +56,7 @@ class JournalsForMessage < ActiveRecord::Base acts_as_attachable has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + has_many :principal_acts, :class_name => 'PrincipalActivity',:as =>:principal_act ,:dependent => :destroy # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy # 消息关联 @@ -133,6 +134,11 @@ class JournalsForMessage < ActiveRecord::Base end end + #用户动态公共表记录 + def act_as_principal_activity + self.principal_acts << PrincipalActivity.new(:user_id => self.id,:principal_id => self.id) + end + def reset_counters! self.class.reset_counters!(self) end diff --git a/app/models/principal_activity.rb b/app/models/principal_activity.rb new file mode 100644 index 000000000..877492d91 --- /dev/null +++ b/app/models/principal_activity.rb @@ -0,0 +1,34 @@ +class PrincipalActivity < ActiveRecord::Base + attr_accessible :principal_act_id, :principal_act_type, :principal_id, :user_id + #虚拟关联 + belongs_to :principal_act ,:polymorphic => true + belongs_to :user + validates :user_id,presence: true + validates :principal_id,presence: true + validates :principal_act_id,presence: true + validates :principal_act_type, presence: true + has_many :user_acts, :class_name => 'UserAcivity',:as =>:act + after_save :add_user_activity + before_destroy :destroy_user_activity + + #在个人动态里面增加当前动态 + def add_user_activity + user_activity = UserActivity.where("act_type = '#{self.principal_act_type.to_s}' and act_id = '#{self.principal_act_id}'").first + if user_activity + user_activity.save + else + user_activity = UserActivity.new + user_activity.act_id = self.principal_act_id + user_activity.act_type = self.principal_act_type + user_activity.container_type = "Principal" + user_activity.container_id = self.principal_id + user_activity.user_id = self.user_id + user_activity.save + end + end + + def destroy_user_activity + user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'") + user_activity.destroy_all + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 0ed8aeda0..e1dc45669 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -114,6 +114,7 @@ class User < Principal has_many :students_for_courses #has_many :courses, :through => :students_for_courses, :source => :project has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + has_many :principal_acts, :class_name => 'PrincipalActivity',:as =>:principal_act ,:dependent => :destroy has_many :file_commit, :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Project' or container_type = 'Version'" #### # added by bai @@ -1006,6 +1007,11 @@ class User < Principal self.acts << Activity.new(:user_id => self.id) end + #用户动态公共表记录 + def act_as_principal_activity + self.principal_acts << PrincipalActivity.new(:user_id => self.id,:principal_id => self.id) + end + # 注册用户的时候消息默认点击时间为用户创建时间 def add_onclick_time if OnclickTime.where("user_id =?" , self.id).first.nil? diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb index aab26c20b..ac4652a32 100644 --- a/app/views/users/_course_journalsformessage.html.erb +++ b/app/views/users/_course_journalsformessage.html.erb @@ -5,7 +5,7 @@
- <% if @ctivity.try(:user).try(:realname) == ' ' %> + <% if activity.try(:user).try(:realname) == ' ' %> <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %> <% else %> <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %> @@ -30,7 +30,7 @@
-
+
回复(<%= count %>)
@@ -84,7 +84,7 @@ <% end %> <%= format_time reply.created_on %>
-
+
<%= reply.notes.html_safe %>
diff --git a/app/views/users/_user_journalsformessage.html.erb b/app/views/users/_user_journalsformessage.html.erb new file mode 100644 index 000000000..1e925d7c4 --- /dev/null +++ b/app/views/users/_user_journalsformessage.html.erb @@ -0,0 +1,101 @@ +
+
+
+ <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %> +
+
+
+ <% if activity.try(:user).try(:realname) == ' ' %> + <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %> + <% end %> TO + <% if @user.try(:realname) == ' '%> + <% name = @user.login.to_s %> + <% else %> + <% name = @user.try(:realname).to_s %> + <% end %> + <%= link_to name+"("+@user.login.to_s+")的留言", feedback_path(@user, :host=> Setting.host_user), :class => "newsBlue ml15" %> +
+
+ <% if activity.parent %> + <%= link_to activity.parent.notes.html_safe, feedback_path(@user, :host=> Setting.host_user), :class => "postGrey" %> + <% else %> + <%= link_to activity.notes.html_safe, feedback_path(@user, :host=> Setting.host_user), :class => "postGrey" %> + <% end %> +
+
+ 留言时间:<%= format_time(activity.created_on) %> +
+
+
+
+ <% count=fetch_user_leaveWord_reply(activity).count %> +
+
+
+
+ 回复(<%= count %>) +
+
+ <%if count>2 %> + + <% end %> +
+ + <% replies_all_i = 0 %> + <% if count > 0 %> +
+
    + <% fetch_user_leaveWord_reply(activity).reorder("created_on desc").each do |comment| %> + <% replies_all_i = replies_all_i + 1 %> +
  • +
    + <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %> +
    +
    +
    + <% if comment.try(:user).try(:realname) == ' ' %> + <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(comment.created_on) %> +
    +
    + <%= comment.notes.html_safe %>
    + <% end %> +
    +
    +
  • +
+
+ <% end %> + +
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id},:method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %> + <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %> + <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %> + <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %> + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> + +
+ +
+

+ <% end%> +
+
+
+
+
+
+
\ No newline at end of file diff --git a/db/migrate/20151013081912_create_principal_activities.rb b/db/migrate/20151013081912_create_principal_activities.rb new file mode 100644 index 000000000..f688ed807 --- /dev/null +++ b/db/migrate/20151013081912_create_principal_activities.rb @@ -0,0 +1,12 @@ +class CreatePrincipalActivities < ActiveRecord::Migration + def change + create_table :principal_activities do |t| + t.integer :user_id + t.integer :principal_id + t.integer :principal_act_id + t.string :principal_act_type + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index abc7017e6..b03813032 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 => 20150917022239) do +ActiveRecord::Schema.define(:version => 20151013081912) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -575,6 +575,8 @@ ActiveRecord::Schema.define(:version => 20150917022239) do t.integer "viewed" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.string "secret_key" + t.integer "status" end create_table "forums", :force => true do |t| @@ -783,16 +785,6 @@ ActiveRecord::Schema.define(:version => 20150917022239) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" @@ -911,6 +903,7 @@ ActiveRecord::Schema.define(:version => 20150917022239) do t.datetime "updated_on", :null => false t.boolean "locked", :default => false t.integer "sticky", :default => 0 + t.integer "reply_id" end add_index "messages", ["author_id"], :name => "index_messages_on_author_id" @@ -1093,6 +1086,15 @@ ActiveRecord::Schema.define(:version => 20150917022239) do t.datetime "updated_at", :null => false end + create_table "principal_activities", :force => true do |t| + t.integer "user_id" + t.integer "principal_id" + t.integer "principal_act_id" + t.string "principal_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "project_infos", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -1376,6 +1378,7 @@ ActiveRecord::Schema.define(:version => 20150917022239) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.text "description" + t.string "subject" end create_table "taggings", :force => true do |t| diff --git a/spec/factories/principal_activities.rb b/spec/factories/principal_activities.rb new file mode 100644 index 000000000..58e52fa17 --- /dev/null +++ b/spec/factories/principal_activities.rb @@ -0,0 +1,10 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :principal_activity do + user_id 1 + principal_id 1 + principal_act_id 1 + principal_act_type "MyString" + end +end diff --git a/spec/models/principal_activity_spec.rb b/spec/models/principal_activity_spec.rb new file mode 100644 index 000000000..3ae176e25 --- /dev/null +++ b/spec/models/principal_activity_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe PrincipalActivity, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 8abc97ae84ea7a5a3b262f41e9f3264b73b548c2 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 14 Oct 2015 11:38:16 +0800 Subject: [PATCH 09/28] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=AA=E4=BA=BA=E7=95=99=E8=A8=80=E5=8A=A8?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 7 ++- app/controllers/words_controller.rb | 3 +- app/models/journals_for_message.rb | 8 +++- app/models/principal_activity.rb | 2 +- app/models/user.rb | 2 +- app/views/users/_user_activities.html.erb | 7 +++ .../users/_user_journalsformessage.html.erb | 22 ++++------ app/views/users/show.html.erb | 1 + app/views/words/create_reply.js.erb | 6 ++- ...0151013091057_update_principal_activity.rb | 15 +++++++ ...13092356_update_principal_activity_time.rb | 43 +++++++++++++++++++ ...4013243_update_user_activity_updated_at.rb | 16 +++++++ db/schema.rb | 2 +- public/stylesheets/new_user.css | 1 + 14 files changed, 113 insertions(+), 22 deletions(-) create mode 100644 db/migrate/20151013091057_update_principal_activity.rb create mode 100644 db/migrate/20151013092356_update_principal_activity_time.rb create mode 100644 db/migrate/20151014013243_update_user_activity_updated_at.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3de491421..90fdbe837 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -883,6 +883,7 @@ class UsersController < ApplicationController user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" course_types = "('Message','News','HomeworkCommon','Poll')" project_types = "('Message','Issue')" + principal_types = "JournalsForMessage" if params[:type].present? case params[:type] when "course_homework" @@ -897,13 +898,15 @@ class UsersController < ApplicationController @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Issue'").order('updated_at desc').limit(10).offset(@page * 10) when "project_message" @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page * 10) + when "user_journals" + @user_activities = UserActivity.where("container_type = 'Principal' and act_type= 'JournalsForMessage' and container_id = #{@user.id}").order('updated_at desc').limit(10).offset(@page * 10) when "current_user" @user_activities = UserActivity.where("user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))").order('updated_at desc').limit(10).offset(@page * 10) else - @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").order('updated_at desc').limit(10).offset(@page * 10) + @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10) end else - @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").order('updated_at desc').limit(10).offset(@page * 10) + @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10) end # @user_activities = paginateHelper @user_activities,500 @type = params[:type] diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index a59f507df..6304055ed 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -76,7 +76,8 @@ class WordsController < ApplicationController # render 'test/index' # } format.js { - @user_activity_id = params[:user_activity_id] if + @reply_type = params[:reply_type] + @user_activity_id = params[:user_activity_id] @activity = JournalsForMessage.find(parent_id) } end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 72ef9ee88..faab129a6 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -64,7 +64,7 @@ class JournalsForMessage < ActiveRecord::Base has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :dependent => :destroy validates :notes, presence: true, if: :is_homework_jour? - after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message + after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message, :act_as_principal_activity after_create :reset_counters! after_destroy :reset_counters! after_save :be_user_score @@ -136,7 +136,11 @@ class JournalsForMessage < ActiveRecord::Base #用户动态公共表记录 def act_as_principal_activity - self.principal_acts << PrincipalActivity.new(:user_id => self.id,:principal_id => self.id) + if self.jour_type == 'Principal' + unless self.user_id == self.jour.id && self.user_id != self.reply_id && self.reply_id != 0 + self.principal_acts << PrincipalActivity.new(:user_id => self.user_id, :principal_id => self.jour_id) + end + end end def reset_counters! diff --git a/app/models/principal_activity.rb b/app/models/principal_activity.rb index 877492d91..bdd7cd60e 100644 --- a/app/models/principal_activity.rb +++ b/app/models/principal_activity.rb @@ -28,7 +28,7 @@ class PrincipalActivity < ActiveRecord::Base end def destroy_user_activity - user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'") + user_activity = UserActivity.where("act_type = '#{self.principal_act_type.to_s}' and act_id = '#{self.principal_act_id}'") user_activity.destroy_all end end diff --git a/app/models/user.rb b/app/models/user.rb index e1dc45669..d66785460 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -212,7 +212,7 @@ class User < Principal before_save :update_hashed_password before_destroy :remove_references_before_destroy # added by fq - after_create :act_as_activity, :add_onclick_time + after_create :act_as_activity, :add_onclick_time, :act_as_principal_activity # end # 更新邮箱用户或用户名的同事,同步更新邀请信息 after_update :update_invite_list diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 29752121f..2f10e6f1c 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -83,6 +83,13 @@ <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> <% end %> <% end %> + <% when 'Principal' %> + <% if act %> + <% case user_activity.act_type.to_s %> + <% when 'JournalsForMessage' %> + <%= render :partial => 'user_journalsformessage', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> + <% end %> + <% end %> <% end %> <% end %> <% end %> diff --git a/app/views/users/_user_journalsformessage.html.erb b/app/views/users/_user_journalsformessage.html.erb index 1e925d7c4..691911008 100644 --- a/app/views/users/_user_journalsformessage.html.erb +++ b/app/views/users/_user_journalsformessage.html.erb @@ -5,23 +5,17 @@
- <% if activity.try(:user).try(:realname) == ' ' %> - <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %> - <% end %> TO - <% if @user.try(:realname) == ' '%> - <% name = @user.login.to_s %> - <% else %> - <% name = @user.try(:realname).to_s %> + <%= link_to activity.user.show_name, user_path(activity.user_id), :class => "newsBlue mr15" %> + TO + <% if activity.jour %> + <%= link_to activity.jour.show_name+"("+(activity.jour.login ? activity.jour.login : activity.jour.show_name ).to_s+")的留言", feedback_path(activity.jour, :host=> Setting.host_user), :class => "newsBlue ml15" %> <% end %> - <%= link_to name+"("+@user.login.to_s+")的留言", feedback_path(@user, :host=> Setting.host_user), :class => "newsBlue ml15" %>
<% if activity.parent %> - <%= link_to activity.parent.notes.html_safe, feedback_path(@user, :host=> Setting.host_user), :class => "postGrey" %> + <%= link_to activity.parent.notes.html_safe, feedback_path(activity.jour, :host=> Setting.host_user), :class => "postGrey" %> <% else %> - <%= link_to activity.notes.html_safe, feedback_path(@user, :host=> Setting.host_user), :class => "postGrey" %> + <%= link_to activity.notes.html_safe, feedback_path(activity.jour, :host=> Setting.host_user), :class => "postGrey" %> <% end %>
@@ -67,7 +61,8 @@ <%= format_time(comment.created_on) %>
- <%= comment.notes.html_safe %>
+ <%= comment.notes.html_safe %> +
<% end %>
@@ -86,6 +81,7 @@ <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %> <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %> <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> + <%= hidden_field_tag 'reply_type',params[:reply_type],:value =>'user' %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index de166b4e7..fc87bd3a0 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -29,6 +29,7 @@
    • 更多
    • +
    • <%= link_to "留言动态", {:controller => "users", :action => "show", :type => "user_journals"}, :class =>"homepagePostTypeMessage postTypeGrey"%>
    • <%= link_to "我的动态", {:controller => "users", :action => "show", :type => "current_user"}, :class =>"homepagePostTypeMine postTypeGrey"%>
    • <%= link_to "全部动态", {:controller => "users", :action => "show", :type => nil}, :class =>"homepagePostTypeAll postTypeGrey"%>
    diff --git a/app/views/words/create_reply.js.erb b/app/views/words/create_reply.js.erb index d91ce08ce..db645f011 100644 --- a/app/views/words/create_reply.js.erb +++ b/app/views/words/create_reply.js.erb @@ -1,6 +1,10 @@ <% if @save_succ %> <% if @user_activity_id %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); + <% if @reply_type == 'user' %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); + <% else %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); + <% end %> init_activity_KindEditor_data('<%= @user_activity_id%>', "", "87%"); <% else %> <% if !@jfm.nil? && @jfm.jour_type == 'Principal' %> diff --git a/db/migrate/20151013091057_update_principal_activity.rb b/db/migrate/20151013091057_update_principal_activity.rb new file mode 100644 index 000000000..bfcf9ccd9 --- /dev/null +++ b/db/migrate/20151013091057_update_principal_activity.rb @@ -0,0 +1,15 @@ +class UpdatePrincipalActivity < ActiveRecord::Migration + def up + User.all.each do |user| + transaction do + user.principal_acts << PrincipalActivity.new(:user_id => user.id,:principal_id => user.id) + user.journals_for_messages.each do |jour| + jour.principal_acts << PrincipalActivity.new(:user_id => jour.user_id,:principal_id => user.id) + end + end + end + end + + def down + end +end diff --git a/db/migrate/20151013092356_update_principal_activity_time.rb b/db/migrate/20151013092356_update_principal_activity_time.rb new file mode 100644 index 000000000..8c1e5bd79 --- /dev/null +++ b/db/migrate/20151013092356_update_principal_activity_time.rb @@ -0,0 +1,43 @@ +class UpdatePrincipalActivityTime < ActiveRecord::Migration + def up + count = PrincipalActivity.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + PrincipalActivity.page(i).per(30).each do |activity| + if activity.principal_act + if activity.principal_act.respond_to?("created_on") + activity.created_at = activity.principal_act.created_on + activity.updated_at = activity.principal_act.created_on + elsif activity.principal_act.respond_to?("created_at") + activity.created_at = activity.principal_act.created_at + activity.updated_at = activity.principal_act.created_at + end + activity.save + + user_activity = UserActivity.where("act_type = '#{activity.principal_act_type.to_s}' and act_id = '#{activity.principal_act_id}'").first + user_activity.created_at = activity.created_at + user_activity.updated_at = activity.created_at + if user_activity.act_type == 'JournalsForMessage' + if user_activity.act + unless user_activity.act.m_parent_id.nil? + parent_act = UserActivity.where("act_id = #{user_activity.act.m_parent_id} and act_type='JournalsForMessage' and container_type='Principal'").first + if parent_act + parent_act.created_at = user_activity.act.parent.children.maximum("created_on") + parent_act.save + user_activity.destroy + end + end + else + user_activity.destroy + end + end + user_activity.save + end + end + end + end + end + + def down + end +end diff --git a/db/migrate/20151014013243_update_user_activity_updated_at.rb b/db/migrate/20151014013243_update_user_activity_updated_at.rb new file mode 100644 index 000000000..6678e07e1 --- /dev/null +++ b/db/migrate/20151014013243_update_user_activity_updated_at.rb @@ -0,0 +1,16 @@ +class UpdateUserActivityUpdatedAt < ActiveRecord::Migration + def up + count = UserActivity.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + UserActivity.page(i).per(30).each do |activity| + activity.updated_at = activity.created_at + activity.save + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index b03813032..3c1271dfb 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 => 20151013081912) do +ActiveRecord::Schema.define(:version => 20151014013243) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index bb556240a..9d45ff753 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -624,6 +624,7 @@ a.homepagePostTypeQuiz {background:url(../images/homepage_icon.png) -90px -124px a.homepagePostTypeQuestion {background:url(../images/homepage_icon.png) -10px -273px no-repeat; padding-left:23px;} a.homepagePostTypeMine {background:url(../images/homepage_icon.png) -187px -277px no-repeat; padding-left:23px;} a.homepagePostTypeAll {background:url(../images/homepage_icon.png) -185px -308px no-repeat; padding-left:23px;} +a.homepagePostTypeMessage {background:url(images/homepage_icon.png) -3px -518px no-repeat; padding-left:23px;} .homepagePostTypeMore {width:180px; border-top:1px dashed #dddddd; margin-top:5px;} .w100 {width:100px;} a.homepageTypeUnread {background:url(../images/homepage_icon.png) -6px -579px no-repeat; padding-left:23px;} From 20ff1430fc6be8eced2f6c7e7b20316ff3ff44cd Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 14 Oct 2015 14:19:59 +0800 Subject: [PATCH 10/28] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=98=BE=E7=A4=BA3=E4=B8=AA=EF=BC=8C?= =?UTF-8?q?=E2=80=9C=E6=94=B6=E8=B5=B7=E5=9B=9E=E5=A4=8D=E2=80=9D=E3=80=81?= =?UTF-8?q?=E2=80=9C=E5=B1=95=E5=BC=80=E6=9B=B4=E5=A4=9A=E2=80=9D=E5=90=8E?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=9B=9E=E5=A4=8D=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/boards/_course_show.html.erb | 5 +++-- app/views/boards/_project_show.html.erb | 4 ++-- app/views/courses/_course_activity.html.erb | 5 +++-- app/views/memos/show.html.erb | 5 +++-- app/views/messages/_course_show.html.erb | 5 +++-- app/views/users/_course_journalsformessage.html.erb | 4 ++-- app/views/users/_course_message.html.erb | 4 ++-- app/views/users/_course_news.html.erb | 4 ++-- app/views/users/_project_issue.html.erb | 4 ++-- app/views/users/_project_message.html.erb | 4 ++-- app/views/users/_user_activities.html.erb | 5 +++-- app/views/users/_user_journalsformessage.html.erb | 4 ++-- 12 files changed, 29 insertions(+), 24 deletions(-) diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 871aa7e39..783531027 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -26,14 +26,15 @@ var btn = $(btnid); if (btn.data('init') == '0') { btn.data('init', 1); - btn.html('收起回复(' + btn.data('count') + ')'); + btn.html('收起回复'); target.show(); } else { btn.data('init', 0); - btn.html('展开更多(' + btn.data('count') + ')'); + btn.html('展开更多'); target.hide(); target.eq(0).show(); target.eq(1).show(); + target.eq(2).show(); } } diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index 4f022261f..84e25974a 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -209,11 +209,11 @@ btn.click(function(){ if($(this).data('init')=='0'){ $(this).data('init',1); - $(this).html('收起回复('+$(this).data('count')+')'); + $(this).html('收起回复'); target.show(); }else{ $(this).data('init',0); - $(this).html('展开回复('+$(this).data('count')+')'); + $(this).html('展开回复'+$(this).data('count')+')'); target.hide(); target.eq(0).show(); target.eq(1).show(); diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb index 44b72868d..74856197e 100644 --- a/app/views/courses/_course_activity.html.erb +++ b/app/views/courses/_course_activity.html.erb @@ -56,14 +56,15 @@ var btn = $(btnid); if (btn.data('init') == '0') { btn.data('init', 1); - btn.html('收起回复(' + btn.data('count') + ')'); + btn.html('收起回复'); target.show(); } else { btn.data('init', 0); - btn.html('展开更多(' + btn.data('count') + ')'); + btn.html('展开更多'); target.hide(); target.eq(0).show(); target.eq(1).show(); + target.eq(2).show(); } } diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index d6acabd9e..53b972025 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -17,14 +17,15 @@ var btn = $(btnid); if(btn.data('init')=='0'){ btn.data('init',1); - btn.html('收起回复('+btn.data('count')+')'); + btn.html('收起回复'); target.show(); }else{ btn.data('init',0); - btn.html('展开更多('+btn.data('count')+')'); + btn.html('展开更多'); target.hide(); target.eq(0).show(); target.eq(1).show(); + target.eq(2).show(); } } $(function() { diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index 1c603caf6..f9822f70c 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -12,14 +12,15 @@ var btn = $(btnid); if(btn.data('init')=='0'){ btn.data('init',1); - btn.html('收起回复('+btn.data('count')+')'); + btn.html('收起回复'); target.show(); }else{ btn.data('init',0); - btn.html('展开更多('+btn.data('count')+')'); + btn.html('展开更多'); target.hide(); target.eq(0).show(); target.eq(1).show(); + target.eq(2).show(); } } $(function() { diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb index ac4652a32..93e7f0c29 100644 --- a/app/views/users/_course_journalsformessage.html.erb +++ b/app/views/users/_course_journalsformessage.html.erb @@ -34,7 +34,7 @@ 回复(<%= count %>)
  • - <%if count>2 %> + <%if count>3 %>
    <%#=format_date(activity.updated_on)%>
    - <%if count > 2 %> + <%if count > 3 %>
    <%#= format_date(activity.updated_on) %>
    - <%if count>2 %> + <%if count>3 %>
    展开更多 @@ -47,7 +47,7 @@
    - <%if count>2 %> + <%if count>3 %>
    展开更多 @@ -47,7 +47,7 @@
      <% fetch_user_leaveWord_reply(activity).reorder("created_on desc").each do |comment| %> <% replies_all_i = replies_all_i + 1 %> -
    • +
    • <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
      From 69ad8495c794bcd05ebc8b519c468b69eccea9a6 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 14 Oct 2015 17:28:13 +0800 Subject: [PATCH 11/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=B8=AD=EF=BC=8C=E8=AF=84=E9=98=85=E4=BA=86?= =?UTF-8?q?=E6=9F=90=E4=BD=9C=E8=AF=84=E7=9A=84=E6=B6=88=E6=81=AF=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_message_course.html.erb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 1b9b175ea..ba1806d69 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -281,9 +281,15 @@ :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %>
    • <% end %>
    • <%= time_tag(ma.created_at).html_safe %>
    • From a45722b0f5cf3f476f6fff6aa049ff1fd85b5c64 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 15 Oct 2015 09:11:26 +0800 Subject: [PATCH 12/28] =?UTF-8?q?=E4=B8=80=E4=B8=AA=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=8F=AA=E8=83=BD=E5=BB=BA=E4=B8=80=E4=B8=AA=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settings/_new_repositories.html.erb | 169 +++++++++--------- 1 file changed, 87 insertions(+), 82 deletions(-) diff --git a/app/views/projects/settings/_new_repositories.html.erb b/app/views/projects/settings/_new_repositories.html.erb index 410bd8c32..0859e5e19 100644 --- a/app/views/projects/settings/_new_repositories.html.erb +++ b/app/views/projects/settings/_new_repositories.html.erb @@ -8,93 +8,98 @@ <% project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT %> <% ip = RepositoriesHelper::REPO_IP_ADDRESS %> <% if @project.repositories.any? %> - - - - - - - - - - - <% @project.repositories.sort.each do |repository| %> - - - - - <%if repository.scm_name=="Git"%> - + + + + + + + + + <% @project.repositories.sort.each do |repository| %> + + + + + <%if repository.scm_name=="Git"%> + - <%else %> - - <% end %> - - - - <% end %> + <%else %> + + <% end %> + + + + <% end %> + +
      <%= l(:field_identifier) %> <%= l(:field_repository_is_default) %><%= l(:label_scm) %> <%= l(:label_repository_path) %>
      - <%= link_to truncate(repository.identifier), ({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => repository.identifier_param} if repository.identifier.present?) %> <%= checked_image repository.is_default? %><%=h repository.scm_name %> +
      <%= l(:field_identifier) %> <%= l(:field_repository_is_default) %><%= l(:label_scm) %> <%= l(:label_repository_path) %>
      + <%= link_to truncate(repository.identifier), ({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => repository.identifier_param} if repository.identifier.present?) %> <%= checked_image repository.is_default? %><%=h repository.scm_name %> <%=truncate( 'http://' << repository.login.to_s << '_'<< repository.identifier.to_s << '@'<< ip.to_s << h( repository.url.slice(project_path_cut, repository.url.length)),:length=>20)%><%=h truncate(repository.url,:length=>10) %> - <% if repository.scm_name=="Git"%> - <%if User.current.allowed_to?(:manage_repository, @project) %> - <%= link_to(l(:label_user_plural), committers_repository_path(repository)) %> - <% end %> - <% end %> - - <% if repository.login.to_s==User.current.login.to_s %> - <%= delete_new_link repository_path(repository) %> - <% end %>
      <%=h truncate(repository.url,:length=>10) %> + <% if repository.scm_name=="Git"%> + <%if User.current.allowed_to?(:manage_repository, @project) %> + <%= link_to(l(:label_user_plural), committers_repository_path(repository)) %> + <% end %> + <% end %> + + <% if repository.login.to_s==User.current.login.to_s %> + <%= delete_new_link repository_path(repository) %> + <% end %>
      <% else %> -

      <%= l(:label_no_data) %>

      +

      <%= l(:label_repository_no_data) %>

      <% end %> - - - - - <% course_tag = @project.project_type %> - <% if User.current.allowed_to?(:manage_repository, @project) %> - - <%= link_to l(:label_repository_new_repos),"#" , :onclick=>"pro_st_show_ku();", :class => 'c_blue fl' %>

      - <% end %> -
      -
      +<%# 新建版本库 %> +<% if @project.repositories.count == 0 %> + + + <% course_tag = @project.project_type %> + <% if User.current.allowed_to?(:manage_repository, @project) %> + + <%= link_to l(:label_repository_new_repos),"#" , :onclick=>"pro_st_show_ku();", :class => 'c_blue fl' %>

      + <% end %> +
      +
      -<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post",:autocomplete=>'off'} do |f| %> -
      -
        -
      • - - <%= select_tag('repository_scm', - options_for_select(["Git"],@repository.class.name.demodulize), - :data => {:remote => true, :method => 'get'})%> - <% if @repository && ! @repository.class.scm_available %> - <%= l(:text_scm_command_not_available) %> - <% end %> -
      • + <%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post",:autocomplete=>'off'} do |f| %> +
        +
          +
        • + + <%= select_tag('repository_scm', + options_for_select(["Git"],@repository.class.name.demodulize), + :data => {:remote => true, :method => 'get'})%> + <% if @repository && ! @repository.class.scm_available %> + <%= l(:text_scm_command_not_available) %> + <% end %> +
        • - <% unless judge_main_repository(@project) %> -
        • - - <%= f.check_box :is_default, :label => "", :no_label => true %>

          -
        • + <% unless judge_main_repository(@project) %> +
        • + + <%= f.check_box :is_default, :label => "", :no_label => true %>

          +
        • + <% end %> +
        • + + + + <%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>"", :no_label => true %> + <% unless @repository.identifier_frozen? %> + <%=l(:text_length_between,:min=>1,:max=>254)< + <% end %> +
        • +
        • + + <%= f.password_field :upassword, :label=> "", :no_label => true%> + <%= l(:label_upassword_info)%> +
        • +
          +
        + <%=l(:button_save)%> + <%=l(:button_cancel)%> +
        <% end %> -
      • - - - - <%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>"", :no_label => true %> - <% unless @repository.identifier_frozen? %> - <%=l(:text_length_between,:min=>1,:max=>254)< - <% end %> -
      • -
      • - - <%= f.password_field :upassword, :label=> "", :no_label => true%> - <%= l(:label_upassword_info)%> -
      • -
        -
      - <%=l(:button_save)%> - <%=l(:button_cancel)%> -
      + <% end %> + From 939906388630615c8bffce2ba5038c76d5355e57 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 15 Oct 2015 09:18:56 +0800 Subject: [PATCH 13/28] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=BA=93=E6=8E=A7=E5=88=B6=E5=B1=82=E5=8F=8A=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 21 +++++++++++++-------- config/locales/commons/zh.yml | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 126b269bb..f2f10d5b6 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -46,16 +46,21 @@ class RepositoriesController < ApplicationController rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed def new - scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first - @repository = Repository.factory(scm) - @repository.is_default = @project.repository.nil? - @repository.project = @project - @course_tag = params[:course] - if @course_tag == 1 - render :layout => 'base_courses' + if @project.repositories.count == 0 + scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first + @repository = Repository.factory(scm) + @repository.is_default = @project.repository.nil? + @repository.project = @project + @course_tag = params[:course] + if @course_tag == 1 + render :layout => 'base_courses' + else + render :layout => 'base_projects' + end else - render :layout => 'base_projects' + render_403 end + end diff --git a/config/locales/commons/zh.yml b/config/locales/commons/zh.yml index 7cbb223c6..61bad2a00 100644 --- a/config/locales/commons/zh.yml +++ b/config/locales/commons/zh.yml @@ -199,7 +199,8 @@ zh: label_descripition_blank: 描述不能为空 label_subject_empty: 主题不能为空 - label_no_data: 没有任何数据可供显示 + label_no_data: 没有任何数据可供显示 + label_repository_no_data: 您还没有创建版本库,每个项目只允许创建一个版本库! # 项目、课程、用户公用 label_settings: 配置 label_information_plural: 信息 From b261eed24cfe13c7211d6a80c8e09b0670064ae1 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 15 Oct 2015 09:56:05 +0800 Subject: [PATCH 14/28] =?UTF-8?q?=E6=8F=90=E5=8F=96=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E8=AF=84=E5=88=86=E6=B6=88=E6=81=AF=E7=9A=84=E8=AF=84=E5=88=86?= =?UTF-8?q?=E5=8F=8A=E8=AF=84=E8=AF=AD=EF=BC=8C=E7=94=A8=E9=80=82=E5=BD=93?= =?UTF-8?q?=E7=9A=84=E6=A0=B7=E5=BC=8F=E6=98=BE=E7=A4=BA=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_message_course.html.erb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index ba1806d69..9c426f495 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -283,7 +283,14 @@