From 4f9686fc57e73dd33ea9b8d2cc777237bfd4abd0 Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 16 Dec 2013 18:37:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=95=99=E8=A8=80=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 27 +- app/views/users/show.html.erb | 488 +++++++++++++--------------- 2 files changed, 242 insertions(+), 273 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3d38ddbf8..4dfb67c0c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -388,15 +388,14 @@ class UsersController < ApplicationController end def show + pre_count = 10 #limit case params[:type] when "1" if @user == User.current activity = Activity.where('user_id = ?', User.current.id).order('id desc') - @offset, @limit = api_offset_and_limit({:limit => 10}) @activity_count = activity.count - @activity_pages = Paginator.new @activity_count, @limit, params['page'] - @offset ||= @activity_pages.offset - @activity = activity.offset(@offset).limit(@limit) + @activity_pages = Paginator.new @activity_count, pre_count, params['page'] + @activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all @state = 1 end when "2" @@ -405,28 +404,24 @@ class UsersController < ApplicationController message = JournalsForMessage.reference_message(@user.id) message += Journal.reference_message(@user.id) end - @offset, @limit = api_offset_and_limit({:limit => 10}) @activity_count = message.size - @info_pages = Paginator.new @activity_count, @limit, params['page'] - @offset ||= @info_pages.offset - + @info_pages = Paginator.new @activity_count, pre_count, params['page'] messages = message.sort {|x,y| y.created_on <=> x.created_on } - - @message = messages[@offset, @limit] + @message = messages[@info_pages.offset, @info_pages.per_page] @state = 2 else + where_condition = nil;#"act_type <> 'JournalsForMessage'" + where_condition = "act_type <> 'JournalsForMessage'" if @user == User.current watcher = User.watched_by(@user) watcher.push(User.current) - activity = Activity.where('user_id in (?)', watcher).order('id desc') + activity = Activity.where(where_condition).where('user_id in (?)', watcher).order('id desc') else - activity = Activity.where('user_id = ?', @user.id).order('id desc') + activity = Activity.where(where_condition).where('user_id = ?', @user.id).order('id desc') end - @offset, @limit = api_offset_and_limit({:limit => 10}) @activity_count = activity.count - @activity_pages = Paginator.new @activity_count, @limit, params['page'] - @offset ||= @activity_pages.offset - @activity = activity.offset(@offset).limit(@limit) + @activity_pages = Paginator.new @activity_count, pre_count, params['page'] + @activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all @state = 0 end diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index a3472f040..affbc5f83 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -4,274 +4,248 @@
- +
- + +
<% end %> - <% end %> - <% unless @state == 2%> - <% unless @activity.empty? %> -
- <% @activity.each do |e| %> - <% #next if( (e.act_type == 'JournalsForMessage') && !(User.current.id.eql?(params[:id].to_i)) ) %> - <% act = e.act %> - <% unless act.nil? %> - - - - - - - -
<%= image_tag(url_to_avatar(e.user), :class => "avatar") %> - - <% case e.act_type %> - <% when 'JournalsForMessage' %> - <% if User.current.login == @user.login %> - <% if e.user_id == act.jour.id %> - - <% else %> - - <% end %> - <% else %> - - <% end %> - - - - - - - <% if act.reward_type ==3 %> - <% if e.user == User.current%> - - <% else %> - - <% end %> - <% else %> - <% if e.user == User.current%> - - <% else %> - - <% end %> - <% end %> - - - - - - - <% if e.user == User.current%> - - <% else %> - - <% end %> - - - - - - - - <% if e.user == User.current%> - - <% else %> - - <% end %> - - - - - - - <% if e.user == User.current%> - - <% else %> - - <% end %> - - - - - - - <% if e.user == User.current%> - - <% else %> - - <% end %> - - - - - - - <% if e.user == User.current%> - - <% else %> - - <% end %> - - - - - - - <% if e.user == User.current%> - - <% else %> - - <% end %> - - - - - - - - - - -
<%= link_to("#{e.user.show_name}", user_path(e.user_id)) %> 有了留言
<%= link_to("#{e.user.show_name}", user_path(e.user_id)) %> 给 <%= link_to("#{act.jour.show_name}", user_path(act.jour.id)) %> 留言了 
<%= link_to("#{@user.show_name}", user_path(e.user_id)) %> 有了新的动态
-

- <%=textilizable act.notes %> -

-
- - <% when 'Bid' %> -
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %><%= l(:label_i_new_activity) %> - <%= link_to format_activity_title("#{l(:label_active_homework)}##{act.id}:#{act.name}"), respond_path(e.act_id) %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %>  - <%= link_to format_activity_title("#{l(:label_active_homework)}##{act.id}:#{act.name}"), respond_path(e.act_id) %> <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %><%= l(:label_i_new_activity) %> - <%= link_to format_activity_title("#{l(:label_active_call)}##{act.id}:#{act.name}"), respond_path(e.act_id) %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %>  - <%= link_to format_activity_title("#{l(:label_active_call)}##{act.id}:#{act.name}"), respond_path(e.act_id) %>
-

- <%= h act.description %> -

-
<%= link_to l(:label_find_all_comments), respond_path(e.act_id) %><%= l(:label_comments_count, :count => e.act.commit)%>
- <% when 'Journal' %> - -
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to(l(:label_activity_project)+act.issue.project.name, project_path(act.issue.project.identifier))%> <%= link_to format_activity_title("#{act.issue.tracker} ##{act.issue.id}: #{act.issue.subject}"), {:controller => 'issues', :action => 'show', :id => act.issue.id, :anchor => "change-#{act.id}"} %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to( l(:label_activity_project)+act.issue.project.name, project_path(act.issue.project.identifier))%> <%= link_to format_activity_title("#{act.issue.tracker} ##{act.issue.id}: #{act.issue.subject}"), {:controller => 'issues', :action => 'show', :id => act.issue.id, :anchor => "change-#{act.id}"} %>
-

- <%= h act.notes %> -

-
- <% when 'Changeset' %> -
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to format_activity_title(act.title), {:controller => 'repositories', :action => 'revision', :id => act.repository.project, :repository_id => act.repository.identifier_param, :rev => act.identifier} %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title(act.title), {:controller => 'repositories', :action => 'revision', :id => act.repository.project, :repository_id => act.repository.identifier_param, :rev => act.identifier} %>
-

- <%= h act.long_comments %> -

-
<%= link_to l(:label_find_all_comments), {:controller => 'repositories', :action => 'revision', :id => act.repository.project, :repository_id => act.repository.identifier_param, :rev => act.identifier} %><%= l(:label_comments_count, :count => e.act.count)%>
- <% when 'Message' %> -
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to format_activity_title("#{act.board.name}: #{act.subject}"), {:controller => 'messages', :action => 'show', :board_id => act.board_id}.merge(act.parent_id.nil? ? {:id => act.id} : {:id => act.parent_id, :r => act.id, :anchor => "message-#{act.id}"}) %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title("#{act.board.name}: #{act.subject}"), {:controller => 'messages', :action => 'show', :board_id => act.board_id}.merge(act.parent_id.nil? ? {:id => act.id} : {:id => act.parent_id, :r => act.id, :anchor => "message-#{act.id}"}) %>
-

- <%= h stringCut240(act.content) %> -

-
- <% when 'Principal' %> -
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_new_user) %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_user) %>
-

- -

-
- <% when 'News' %> -
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to format_activity_title("#{l(:label_news)}: #{act.title}"), {:controller => 'news', :action => 'show', :id => act.id} %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title("#{l(:label_news)}: #{act.title}"), {:controller => 'news', :action => 'show', :id => act.id} %>
-

- <%= h act.description %> -

-
<%= link_to l(:label_find_all_comments), {:controller => 'news', :action => 'show', :id => act.id} %><%= l(:label_comments_count, :count => e.act.comments_count)%>
- <% when 'Issue' %> - -
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to(l(:label_activity_project)+act.project.name, project_path(act.project.identifier))%> <%= link_to format_activity_title("#{act.tracker.name} ##{act.id} (#{act.status}): #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to(l(:label_activity_project)+act.project.name, project_path(act.project.identifier))%> <%= link_to format_activity_title("#{act.tracker.name} ##{act.id} (#{act.status}): #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %>
-

- <%= textilizable act.description %> -

-
<%= link_to l(:label_find_all_comments), {:controller => 'issues', :action => 'show', :id => act.id} %><%= l(:label_comments_count, :count => e.act.journals.count)%>
- <% end %> -
<% if e.act_type == 'Changeset' %> - <%= format_time(e.act.committed_on) %> - <% else %> - <%= l :label_update_time %>: <%= format_time(e.act.created_on) %> - <% end %>
-
- <% end %> - - <% end %> -
- -<% else %> - <% if @user == User.current %> - <%= l(:label_user_activities) %> - <% else %> -

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

- <% end %> <% end %> + +<% unless @state == 2%> + <% unless @activity.empty? %> +
+ <% @activity.each do |e| %> + <% act = e.act %> + <% unless act.nil? %> + + + + + +
<%= image_tag(url_to_avatar(e.user), :class => "avatar") %> + +<% case e.act_type %> +<% when 'JournalsForMessage' %> + <% if User.current.login == @user.login %> + <% if e.user_id == act.jour.id %> + + <% else %> + + <% end %> + <% else %> + + <% end %> + + + +<% when 'Bid' %> + + <% if act.reward_type ==3 %> + <% if e.user == User.current%> + + <% else %> + + <% end %> + <% else %> + <% if e.user == User.current%> + + <% else %> + + <% end %> + <% end %> + + + + + +<% when 'Journal' %> + + <% if e.user == User.current%> + + <% else %> + + <% end %> + + + + + +<% when 'Changeset' %> + + <% if e.user == User.current%> + + <% else %> + + <% end %> + + + + + +<% when 'Message' %> + + <% if e.user == User.current%> + + <% else %> + + <% end %> + + + + + +<% when 'Principal' %> + + <% if e.user == User.current%> + + <% else %> + + <% end %> + + + + + +<% when 'News' %> + + <% if e.user == User.current%> + + <% else %> + + <% end %> + + + + + +<% when 'Issue' %> + + <% if e.user == User.current%> + + <% else %> + + <% end %> + + + + + +<% end %> +
<%= link_to("#{e.user.show_name}", user_path(e.user_id)) %> 有了留言
<%= link_to("#{e.user.show_name}", user_path(e.user_id)) %> 给 <%= link_to("#{act.jour.show_name}", user_path(act.jour.id)) %> 留言了 
<%= link_to("#{@user.show_name}", user_path(e.user_id)) %> 有了新的动态

<%=textilizable act.notes %>

+
+ <%=(l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %> +
+
+
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %><%= l(:label_i_new_activity) %> <%= link_to format_activity_title("#{l(:label_active_homework)}##{act.id}:#{act.name}"), respond_path(e.act_id) %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %>  <%= link_to format_activity_title("#{l(:label_active_homework)}##{act.id}:#{act.name}"), respond_path(e.act_id) %> <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %><%= l(:label_i_new_activity) %> <%= link_to format_activity_title("#{l(:label_active_call)}##{act.id}:#{act.name}"), respond_path(e.act_id) %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %>  <%= link_to format_activity_title("#{l(:label_active_call)}##{act.id}:#{act.name}"), respond_path(e.act_id) %>

<%= h act.description %>

+
+ <%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %> +
+
<%= link_to l(:label_find_all_comments), respond_path(e.act_id) %><%= l(:label_comments_count, :count => e.act.commit)%>
+
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to(l(:label_activity_project)+act.issue.project.name, project_path(act.issue.project.identifier))%> <%= link_to format_activity_title("#{act.issue.tracker} ##{act.issue.id}: #{act.issue.subject}"), {:controller => 'issues', :action => 'show', :id => act.issue.id, :anchor => "change-#{act.id}"} %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to( l(:label_activity_project)+act.issue.project.name, project_path(act.issue.project.identifier))%> <%= link_to format_activity_title("#{act.issue.tracker} ##{act.issue.id}: #{act.issue.subject}"), {:controller => 'issues', :action => 'show', :id => act.issue.id, :anchor => "change-#{act.id}"} %>

<%= h act.notes %>

+
+ <%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %> +
+
+
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to format_activity_title(act.title), {:controller => 'repositories', :action => 'revision', :id => act.repository.project, :repository_id => act.repository.identifier_param, :rev => act.identifier} %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title(act.title), {:controller => 'repositories', :action => 'revision', :id => act.repository.project, :repository_id => act.repository.identifier_param, :rev => act.identifier} %>

<%= h act.long_comments %>

+
+ <%= format_time(e.act.committed_on) %> +
+
<%= link_to l(:label_find_all_comments), {:controller => 'repositories', :action => 'revision', :id => act.repository.project, :repository_id => act.repository.identifier_param, :rev => act.identifier} %><%= l(:label_comments_count, :count => e.act.count)%>
+
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to format_activity_title("#{act.board.name}: #{act.subject}"), {:controller => 'messages', :action => 'show', :board_id => act.board_id}.merge(act.parent_id.nil? ? {:id => act.id} : {:id => act.parent_id, :r => act.id, :anchor => "message-#{act.id}"}) %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title("#{act.board.name}: #{act.subject}"), {:controller => 'messages', :action => 'show', :board_id => act.board_id}.merge(act.parent_id.nil? ? {:id => act.id} : {:id => act.parent_id, :r => act.id, :anchor => "message-#{act.id}"}) %>

<%= h stringCut240(act.content) %>

+
+ <%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %> +
+
+
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_new_user) %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_user) %>

+
+ <%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %> +
+
+
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to format_activity_title("#{l(:label_news)}: #{act.title}"), {:controller => 'news', :action => 'show', :id => act.id} %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to format_activity_title("#{l(:label_news)}: #{act.title}"), {:controller => 'news', :action => 'show', :id => act.id} %>

<%= h act.description %>

+
+ <%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %> +
+
<%= link_to l(:label_find_all_comments), {:controller => 'news', :action => 'show', :id => act.id} %><%= l(:label_comments_count, :count => e.act.comments_count)%>
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_i_new_activity) %> <%= link_to(l(:label_activity_project)+act.project.name, project_path(act.project.identifier))%> <%= link_to format_activity_title("#{act.tracker.name} ##{act.id} (#{act.status}): #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %><%= link_to(h(e.user), user_path(e.user_id)) %> <%= l(:label_new_activity) %> <%= link_to(l(:label_activity_project)+act.project.name, project_path(act.project.identifier))%> <%= link_to format_activity_title("#{act.tracker.name} ##{act.id} (#{act.status}): #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %>

<%= textilizable act.description %>

+
+ <%= (l(:label_update_time).to_s << ':' << format_time(e.act.created_on)).to_s %> +
+
<%= link_to l(:label_find_all_comments), {:controller => 'issues', :action => 'show', :id => act.id} %><%= l(:label_comments_count, :count => e.act.journals.count)%>
+
+
+ <% end %> + + <% end %> +
+ + <% else %> + <% if @user == User.current %> + <%= l(:label_user_activities) %> + <% else %> +

+ <%= l(:label_user_activities_other) %> +

+ <% end %> + <% end %> + <% else %> - -<% unless @message.empty? %> -
- <% @message.each do |e| -%> - - - - - + +
<%= image_tag(url_to_avatar(e.user), :class => "avatar") %> - - - + + + + + + + + +
<%= link_to(h(e.user), user_path(e.user)) %> - <% if e.instance_of?(JournalsForMessage)%> - <% if e.reply_id == User.current.id%> - <%if e.jour_type == 'Bid'%> - <%= l(:label_in_bids)%><%= link_to(e.jour.name, respond_path(e.jour))%> <%= l(:label_quote_my_words) %> + <% unless @message.empty? %> +
+ <% @message.each do |e| -%> + + + + - -
<%= image_tag(url_to_avatar(e.user), :class => "avatar") %> + + + - - - - - - - - - -
<%= link_to(h(e.user), user_path(e.user)) %> + <% if e.instance_of?(JournalsForMessage)%> + <% if e.reply_id == User.current.id%> + <%if e.jour_type == 'Bid'%> + <%= l(:label_in_bids)%><%= link_to(e.jour.name, respond_path(e.jour))%> <%= l(:label_quote_my_words) %> + <% else %> + <%= l(:label_in_users)%><%= link_to(e.jour.firstname, feedback_path(e.jour))%> <%= l(:label_quote_my_words) %> + <% end %> <% else %> - <%= l(:label_in_users)%><%= link_to(e.jour.firstname, feedback_path(e.jour))%> <%= l(:label_quote_my_words) %> + <%= l(:label_about_requirement) %><%= link_to(e.jour.name, respond_path(e.jour_id))%> <%= l(:label_have_respond) %> <% end %> <% else %> - <%= l(:label_about_requirement) %><%= link_to(e.jour.name, respond_path(e.jour_id))%> <%= l(:label_have_respond) %> - <% end %> - <% else %> - <% if e.journal_reply.nil? || e.journal_reply.reply_id != User.current.id %> - <%= l(:label_about_issue) %><%= link_to(e.issue.subject, issue_path(e.journalized_id))%><%= l(:label_have_respond) %> + <% if e.journal_reply.nil? || e.journal_reply.reply_id != User.current.id %> + <%= l(:label_about_issue) %><%= link_to(e.issue.subject, issue_path(e.journalized_id))%><%= l(:label_have_respond) %> - <% else %> - <%= l(:label_in_issues)%><%= link_to(e.issue.subject, issue_path(e.issue))%><%= l(:label_quote_my_words) %> - <% end %> - <% end %>
-

- <%= textilizable e.notes %> -

<%= format_time e.created_on %>
+ <% else %> + <%= l(:label_in_issues)%><%= link_to(e.issue.subject, issue_path(e.issue))%><%= l(:label_quote_my_words) %> + <% end %> + <% end %> +

<%= textilizable e.notes %>

<%= format_time e.created_on %>
+
+ <% end %> +
+ + + + <% else %> +

<%= l(:label_no_user_respond_you) %>

<% end %> - - -<% else %> -

<%= l(:label_no_user_respond_you) %>

-<% end %> <% end %>