2.增加editor_of_documents表,记录文章编辑的作者、时间等,并显示首页的最后编辑人; 3.在首页编辑文章后,应返回首页。dev_cxt2
parent
00ac79bb34
commit
6f9c89d67b
@ -0,0 +1,4 @@
|
||||
class EditorOfDocument < ActiveRecord::Base
|
||||
belongs_to :user, :class_name => 'User', :foreign_key => 'editor_id'
|
||||
belongs_to :org_document_comment
|
||||
end
|
@ -0,0 +1,69 @@
|
||||
<div class="resources mt10" id="organization_document_<%= document.id %>">
|
||||
<div class="homepagePostBrief">
|
||||
|
||||
<div class="homepagePostDes" style="width:690px;">
|
||||
|
||||
<div class="homepagePostTitle postGrey"><%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %></div>
|
||||
|
||||
<% unless document.content.blank? %>
|
||||
<div class="homepagePostIntro" >
|
||||
<%= document.content.html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="homepagePostDate" style="float:right;">
|
||||
发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="homepagePostDate" style="float:right;">
|
||||
最后编辑:<%= User.find(EditorOfDocument.where("org_document_comment_id =?", document.id).order("created_at desc").first.editor_id).realname %>
|
||||
</div>
|
||||
<!-- <%# if defined?(home_id) %>
|
||||
<div style="float:right;">最后编辑:<%#= User.find() %></div>
|
||||
<%# end %>-->
|
||||
<% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id) || User.current.id == document.creator_id) %>
|
||||
<div class="homepagePostSetting">
|
||||
<ul>
|
||||
<li class="homepagePostSettingIcon">
|
||||
<ul class="homepagePostSettiongText">
|
||||
<li>
|
||||
<%= form_for('new_form', :url => {:controller => 'organizations', :action => 'cancel_homepage', :id => document.organization_id, :home_id => document.id}, :method => "put", :remote => true) do |f| %>
|
||||
<a href="javascript:void(0);" class="postOptionLink" onclick="$(this).parent().submit();">取消首页</a>
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to "编辑首页", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => 2), :class => "postOptionLink" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to "删除首页", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete',
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:remote => true, :class => 'postOptionLink' %>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function expand_reply(container, btnid) {
|
||||
var target = $(container);
|
||||
var btn = $(btnid);
|
||||
if (btn.data('init') == '0') {
|
||||
btn.data('init', 1);
|
||||
btn.html('收起回复');
|
||||
target.show();
|
||||
} else {
|
||||
btn.data('init', 0);
|
||||
btn.html('展开更多');
|
||||
target.hide();
|
||||
target.eq(0).show();
|
||||
target.eq(1).show();
|
||||
target.eq(2).show();
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1 @@
|
||||
window.location.href = "<%= organization_path(@org) %>";
|
@ -0,0 +1,12 @@
|
||||
class CreateOrgDocumeEditor < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :editor_of_documents do |t|
|
||||
t.integer :editor_id
|
||||
t.integer :org_document_comment_id
|
||||
t.timestamp :created_at
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
@ -0,0 +1,12 @@
|
||||
class CopyDocumentCreatedAtForEditorOfDocument < ActiveRecord::Migration
|
||||
def up
|
||||
OrgDocumentComment.all.each do |doc|
|
||||
if doc.parent.nil?
|
||||
EditorOfDocument.create(:editor_id => doc.creator_id, :org_document_comment_id => doc.id, :created_at => doc.updated_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Loading…
Reference in new issue