From d8480ea3c62bea90db1a63c9c25b1e1fcbdcfb18 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Apr 2016 11:33:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E7=9B=AE=E5=BD=95=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sub_document_comments_controller.rb | 2 +- app/controllers/sub_domains_controller.rb | 4 +- app/models/sub_document_comment.rb | 22 +++ app/views/layouts/base_sub_domain.html.erb | 26 ++-- .../_show_sub_document.html.erb | 114 ++------------- .../sub_document_comments/index.html.erb | 4 +- app/views/sub_domains/show.html.erb | 138 +++++++++++++++++- 7 files changed, 193 insertions(+), 117 deletions(-) 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 %> + +
+ +
+
+
banner image
+
<%# 更新访问数,刷新的时候更新访问次数 %> <% update_visiti_count @organization %> <%# over %> -
-
-
- -
- -
-
-
<%= render_flash_messages %> <%= yield %> diff --git a/app/views/sub_document_comments/_show_sub_document.html.erb b/app/views/sub_document_comments/_show_sub_document.html.erb index ed1d3b230..325dd2582 100644 --- a/app/views/sub_document_comments/_show_sub_document.html.erb +++ b/app/views/sub_document_comments/_show_sub_document.html.erb @@ -7,14 +7,14 @@
<%= 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 @@
<% unless document.content.blank? %> - <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>document.id, :content=>document.content} %> + <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id => document.id, :content => document.content} %> <% end %>
- <%= 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 %> -
- -
-
- <% end %> - - - <% comments_for_doc = document.children.reorder("created_at desc") %> - <% count = document.children.count() %> + -
-
-
回复 - <%= count>0 ? "(#{count})" : "" %> - - <% if document.creator_id.to_i == User.current.id.to_i %> - - <% 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) %> - - <% if comment.creator_id.to_i == User.current.id.to_i %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - <% end %> - -
    - <% 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 +
+
+
+
您的位置:首页 > 数据资源 > 仿真数据
+
+
+

最新资讯

+ +
+ 上一页 + 1 + 2 + 3 + ... + 31 + 下一页 +
+
+
+
+ +