announcement module: versioning

This commit is contained in:
iCross 2013-06-08 01:52:22 +08:00
parent fe7393b9e2
commit 2eaa44c279
8 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,12 @@
class Panel::Announcement::BackEnd::BulletinVersionsController < OrbitBackendController
include OrbitControllerLib::DivisionForDisable
def index
@bulletin = Bulletin.find(params[:bulletin_id])
end
def show
@bulletin = Bulletin.find(params[:bulletin_id])
@version = @bulletin.versions.where(version: params[:id]).first
end
end

View File

@ -6,6 +6,7 @@ class Bulletin
include Mongoid::MultiParameterAttributes include Mongoid::MultiParameterAttributes
include Sunspot::Mongo include Sunspot::Mongo
include Impressionist::Impressionable include Impressionist::Impressionable
include Mongoid::Versioning
BelongsToCategory = :bulletin_category BelongsToCategory = :bulletin_category
include OrbitCoreLib::BelongsToCategoryMayDisable include OrbitCoreLib::BelongsToCategoryMayDisable

View File

@ -0,0 +1,25 @@
<table class="table main-list">
<thead>
<tr>
<th class="span7 select"><%= t(:name) %></th>
<th class="span1-2"><%= t(:version) %></th>
<th class="span1-2"><%= t(:update_at) %></th>
<th class="span1-2"><%= t(:last_modified) %></th>
</tr>
</thead>
<tbody>
<% @bulletin.versions.reverse.each do |version| %>
<tr class="with_action">
<td>
<%= version.title[I18n.locale.to_s] %>
<div class="quick-edit">
<%= link_to '顯示', panel_announcement_back_end_bulletin_bulletin_version_path(@bulletin, version.version) %>
</div>
</td>
<td><%= version.version %></td>
<td><%= display_date(version.updated_at) %></td>
<td><%= User.from_id(version.update_user_id).name rescue ''%></td>
</tr>
<% end %>
</tbody>
</table>

View File

@ -0,0 +1,33 @@
<ul>
<li>
<b><%= t(:name) %></b>
<%= @version.title[I18n.locale.to_s] %>
</li>
<li>
<b><%= t(:subtitle) %></b>
<%= @version.subtitle[I18n.locale.to_s] %>
</li>
<li>
<b><%= t(:text) %></b>
<%= simple_format @version.text[I18n.locale.to_s] %>
</li>
<li>
<b><%= t(:deadline) %></b>
<%= display_date(@version.deadline) if @version.deadline %>
</li>
<li>
<b><%= t(:postdate) %></b>
<%= display_date(@version.postdate) if @version.postdate %>
</li>
<li>
<b><%= t(:posted_by) %></b>
<%= User.find(@version.create_user_id).name %>
</li>
<li>
<b><%= t(:last_modified) %></b>
<%= display_date(@version.updated_at) %>
</li>
</ul>
<%= link_back %>

View File

@ -61,6 +61,7 @@
</ul> </ul>
</div> </div>
</td> </td>
<td><%= link_to bulletin.version, panel_announcement_back_end_bulletin_bulletin_versions_path(bulletin) %></td>
<td><%= display_date_time(bulletin.postdate) %></td> <td><%= display_date_time(bulletin.postdate) %></td>
<td><%= (bulletin.deadline) ? display_date_time(bulletin.deadline ): t(:no_deadline) %></td> <td><%= (bulletin.deadline) ? display_date_time(bulletin.deadline ): t(:no_deadline) %></td>
<td> <td>

View File

@ -7,6 +7,7 @@
<th class="span1-2"></th> <th class="span1-2"></th>
<th class="span1-2"></th> <th class="span1-2"></th>
<th class="span1-2"></th> <th class="span1-2"></th>
<th class="span1-2"></th>
<th class="span1-3"></th> <th class="span1-3"></th>
</tr> </tr>
</thead> </thead>

View File

@ -2,6 +2,7 @@
['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1-2', :status], ['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1-2', :status],
['category', 'bulletin_category', 'span1-2', :category], ['category', 'bulletin_category', 'span1-2', :category],
['title', 'title','span7', :title], ['title', 'title','span7', :title],
['version', 'version', 'span1-2', :version],
['start_date', 'postdate', 'span1-2', :start_date], ['start_date', 'postdate', 'span1-2', :start_date],
['end_date', 'deadline', 'span1-2', :end_date], ['end_date', 'deadline', 'span1-2', :end_date],
['tags', 'tags', 'span1-2', :tags], ['tags', 'tags', 'span1-2', :tags],

View File

@ -23,6 +23,8 @@ Rails.application.routes.draw do
end end
match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add
match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit
resources :bulletin_versions
end end
resources :bulletin_categorys do resources :bulletin_categorys do