diff --git a/app/controllers/sub_document_comments_controller.rb b/app/controllers/sub_document_comments_controller.rb
index 2ff07a533..4dfa6658f 100644
--- a/app/controllers/sub_document_comments_controller.rb
+++ b/app/controllers/sub_document_comments_controller.rb
@@ -37,7 +37,7 @@ class SubDocumentCommentsController < ApplicationController
end
def show
- @document = OrgDocumentComment.find(params[:id])
+ @document = SubDocumentComment.find(params[:id])
end
def index
diff --git a/app/controllers/sub_domains_controller.rb b/app/controllers/sub_domains_controller.rb
index 9e614cdde..450f6f32a 100644
--- a/app/controllers/sub_domains_controller.rb
+++ b/app/controllers/sub_domains_controller.rb
@@ -24,7 +24,6 @@ class SubDomainsController < ApplicationController
def show
@subfield_content = @organization.org_subfields.order("priority")
- @subdomain = SubDomain.find(params[:id])
render layout: 'base_sub_domain'
end
@@ -37,5 +36,8 @@ class SubDomainsController < ApplicationController
@subfield = OrgSubfield.find(params[:org_subfield_id])
@subdomain = SubDomain.find(params[:id])
@organization = @subfield.organization
+ rescue ActiveRecord::RecordNotFound
+ # source_subdomain not found
+ render_404
end
end
diff --git a/app/models/sub_document_comment.rb b/app/models/sub_document_comment.rb
index a9f7bdbdc..924c6e8ad 100644
--- a/app/models/sub_document_comment.rb
+++ b/app/models/sub_document_comment.rb
@@ -7,4 +7,26 @@ class SubDocumentComment < ActiveRecord::Base
belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id'
acts_as_tree :order => "#{SubDocumentComment.table_name}.sticky asc, #{SubDocumentComment.table_name}.created_at desc"
acts_as_attachable
+ has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy
+ after_create :document_save_as_sub_activity
+ after_update :update_activity
+
+ #动态的更新
+ private
+ def update_activity
+ org_activity = OrgActivity.where("org_act_type='SubDocumentComment' and org_act_id =?", id).first
+ if org_activity
+ org_activity.updated_at = Time.now
+ org_activity.save
+ end
+ end
+
+ def document_save_as_sub_activity
+ if(self.parent().nil?)
+ self.org_acts << OrgActivity.new(:user_id => User.current.id, :container_id => self.sub_domain.id, :container_type => 'SubDomain')
+ else
+ act = OrgActivity.where("org_act_type='SubDocumentComment' and org_act_id =?", self.root.id).first
+ act.update_attributes(:updated_at => self.updated_at)
+ end
+ end
end
diff --git a/app/views/layouts/base_sub_domain.html.erb b/app/views/layouts/base_sub_domain.html.erb
index c0b98d0e3..c6eec5c30 100644
--- a/app/views/layouts/base_sub_domain.html.erb
+++ b/app/views/layouts/base_sub_domain.html.erb
@@ -125,22 +125,30 @@
<% end %>
+
+
<%= link_to User.find(document.creator_id), user_url_in_org(document.creator.id), :class => "newsBlue mr15" %>
- TO <%= link_to document.sub_domain.name, organization_sub_domains_path(document.organization), :class => "newsBlue" %>
+ TO <%= link_to document.sub_domain.name, org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id=> @org_subfield.id, :sub_domain_id => document.sub_domain.id), :class => "newsBlue" %>
|
- <%= document.org_subfield_id.nil? ? "组织文章" :"#{OrgSubfield.find(document.org_subfield_id).name}" %>
- <% if document.organization.home_id == document.id %>
- 已设为首页
- <% end %>
+ <%= document.sub_domain.name %>
+ <%# if document.organization.home_id == document.id %>
+
+ <%# end %>
-
<%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %>
+
发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %>
@@ -23,116 +23,24 @@
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => document} %>
+ <%#= render :partial=>"attachments/activity_attach", :locals=>{:activity => document} %>
- <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id)) || User.current.id == document.creator_id %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %>▪
-
- <% if document.creator_id.to_i == User.current.id.to_i %>
- 赞<%= get_praise_num(document) > 0 ? "(#{get_praise_num(document)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>document, :user_activity_id=>document.id,:type=>"activity"}%>
- <% end %>
-
-
- <% if count > 3 %>
-
- <% end %>
-
-
-
- <% reply_id = 0 %>
- <% comments_for_doc.each do |comment| %>
- <% reply_id += 1 %>
- -
-
<%= link_to image_tag(url_to_avatar(User.find(comment.creator_id)), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_id) %>
-
-
- <%= link_to User.find(comment.creator_id), user_url_in_org(comment.creator_id), :class => "newsBlue mr10 f14" %>
- <%= format_activity_day(comment.created_at) %> <%= format_time(comment.created_at, false) %>
-
-
- <% unless comment.content.blank? %>
-
<%= comment.content.html_safe %>
- <% end %>
-
-
-
- <% end %>
-
-
-
-
- <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像"), user_url_in_org(User.current.id) %>
-
-
-
- <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id, :act_id => act.id, :flag => flag), :method => "post", :remote => true) do |f| %>
-
-
-
-
发送
-
-
-
- <% end %>
-
-
-
-
+
-->
- <%= render :partial => 'organizations/show_org_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first, :flag => 0} %>
+ <%= render :partial => 'sub_document_comments/show_sub_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='SubDocumentComment'and org_act_id=?", document.id).first, :flag => 0} %>
<% end %>
<% end %>
\ No newline at end of file
diff --git a/app/views/sub_domains/show.html.erb b/app/views/sub_domains/show.html.erb
index 1435c13e5..d91c79bdb 100644
--- a/app/views/sub_domains/show.html.erb
+++ b/app/views/sub_domains/show.html.erb
@@ -1 +1,137 @@
-666666666666666
\ No newline at end of file
+