From 1e1c2109396bdcd00c092e7efc9da3b2d7bce42b Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Sat, 14 Nov 2015 14:57:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=8A=A8=E6=80=81=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 2 +- .../_org_project_activities.html.erb | 8 +- .../organizations/_org_project_issue.html.erb | 2 +- .../organizations/_project_create.html.erb | 38 +++++++ .../organizations/_project_message.html.erb | 100 ++++++++++++++++++ 5 files changed, 143 insertions(+), 7 deletions(-) create mode 100644 app/views/organizations/_project_create.html.erb create mode 100644 app/views/organizations/_project_message.html.erb diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index daf443d07..cad617e47 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -60,7 +60,7 @@ class OrganizationsController < ApplicationController @org_activities_count = OrgActivity.where('container_id =? and container_type =? ', @organization.id, 'Organization ').order('updated_at desc').count project_ids = @organization.projects.map(&:id) - @org_project_activties = ForgeActivity.where('project_id in (?)',project_ids.join(',')).page(params[:page]).per(10) + @org_project_activties = ForgeActivity.where('project_id in (?) and forge_act_type in("Issue","Message","ProjectCreateInfo")',project_ids.join(',')).order("updated_at desc").page(params[:page] || 1).per(10) @org_project_activties_count = ForgeActivity.where('project_id in (?)',project_ids.join(',')).count #@org_activities = paginateHelper @org_activities, 10 @page = params[:page] diff --git a/app/views/organizations/_org_project_activities.html.erb b/app/views/organizations/_org_project_activities.html.erb index 0a6a8fae4..b46996661 100644 --- a/app/views/organizations/_org_project_activities.html.erb +++ b/app/views/organizations/_org_project_activities.html.erb @@ -1,17 +1,15 @@ <% org_project_activties.each do |act|%> <% if act %> - - <% unless act.forge_act_type == "ProjectCreateInfo" %> <% if act %> <% case act.forge_act_type.to_s %> <% when 'Issue' %> <%= render :partial => 'organizations/org_project_issue', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> <% when 'Message' %> - <%= render :partial => 'users/project_message', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> + <%= render :partial => 'organizations/project_message', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> <% when 'ProjectCreateInfo'%> - <%= render :partial => 'users/project_create', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> + <%= render :partial => 'organizations/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %> <% end %> - <% end %><% end %> + <% end %> <% end %> <% end %> <% if org_act_count == 10 || pro_act_count == 10 %> diff --git a/app/views/organizations/_org_project_issue.html.erb b/app/views/organizations/_org_project_issue.html.erb index ed80ba7b1..573429752 100644 --- a/app/views/organizations/_org_project_issue.html.erb +++ b/app/views/organizations/_org_project_issue.html.erb @@ -120,7 +120,7 @@

<%= string %>

<% end %> <% end %> -

<%= reply.notes %>

+

<%= reply.notes.nil? ? "" : reply.notes.html_safe %>

diff --git a/app/views/organizations/_project_create.html.erb b/app/views/organizations/_project_create.html.erb new file mode 100644 index 000000000..d966d8e18 --- /dev/null +++ b/app/views/organizations/_project_create.html.erb @@ -0,0 +1,38 @@ +<% project = Project.find(activity.project_id) %> +<% user = User.find(project.user_id)%> +
+
+
+ <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_path(user), :alt => "用户头像" %> +
+
+
+ <% if user.try(:realname) == ' ' %> + <%= link_to user, user_path(user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to user.try(:realname), user_path(user), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to project.to_s+" | 项目", project_path(project.id,:host=>Setting.host_course), :class => "newsBlue ml15" %> +
+
+ <%= link_to project.name, project_path(project.id,:host=>Setting.host_course), :class => "postGrey" %> +
+
+ 创建时间:<%= format_time(project.created_on) %> +
+ +
+
+
+
\ No newline at end of file diff --git a/app/views/organizations/_project_message.html.erb b/app/views/organizations/_project_message.html.erb new file mode 100644 index 000000000..85ed08f2f --- /dev/null +++ b/app/views/organizations/_project_message.html.erb @@ -0,0 +1,100 @@ +
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> +
+
+
+ <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% 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_boards_path(activity.project), :class => "newsBlue ml15 mr5"%> + +
+
+ <% if activity.parent_id.nil? %> + <%= link_to activity.subject.to_s.html_safe, project_boards_path(activity.project,:parent_id =>activity.id, :topic_id => activity.id), :class=> "postGrey" + %> + <% else %> + <%= link_to activity.parent.subject.to_s.html_safe, project_boards_path(activity.project,:parent_id =>activity.parent_id, :topic_id => activity.id), :class=> "postGrey" + %> + <% end %> +
+
+ 时间:<%= format_time(activity.created_on) %> +
+
+
+ <% if activity.parent_id.nil? %> + <%= activity.content.to_s.html_safe%> + <% else %> + <%= activity.parent.content.to_s.html_safe%> + <% end %> +
+
+
+ + +
+
+
+
+ <% count = 0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
+
+
+
回复( + <%=count %> + )
+
<%#=format_date(activity.updated_on)%>
+ <%if count>3 %> + + <% end %> +
+ + <% activity= activity.parent_id.nil? ? activity : activity.parent %> + <% replies_all_i = 0 %> + <% if count > 0 %> +
+
    + <% activity.children.reorder("created_on desc").each do |reply| %> + + <% replies_all_i=replies_all_i+1 %> +
  • +
    + <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id), :alt => "用户头像" %> +
    +
    +
    + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> +
    +
    + <%= reply.content.html_safe %>
    +
    +
    +
  • + <% end %> +
+
+ <% end %> + + +
+
\ No newline at end of file