From 2eaa44c279989f6a5ac5615e08e2703217034f90 Mon Sep 17 00:00:00 2001 From: iCross Date: Sat, 8 Jun 2013 01:52:22 +0800 Subject: [PATCH] announcement module: versioning --- .../back_end/bulletin_versions_controller.rb | 12 +++++++ .../announcement/app/models/bulletin.rb | 1 + .../back_end/bulletin_versions/index.html.erb | 25 ++++++++++++++ .../back_end/bulletin_versions/show.html.erb | 33 +++++++++++++++++++ .../back_end/bulletins/_bulletin.html.erb | 1 + .../back_end/bulletins/_bulletins.html.erb | 1 + .../back_end/bulletins/_sort_headers.html.erb | 1 + .../announcement/config/routes.rb | 2 ++ 8 files changed, 76 insertions(+) create mode 100644 vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_versions_controller.rb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_versions/index.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_versions/show.html.erb diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_versions_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_versions_controller.rb new file mode 100644 index 000000000..aa06b4fe6 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_versions_controller.rb @@ -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 diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 207b3a544..0e309518f 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -6,6 +6,7 @@ class Bulletin include Mongoid::MultiParameterAttributes include Sunspot::Mongo include Impressionist::Impressionable + include Mongoid::Versioning BelongsToCategory = :bulletin_category include OrbitCoreLib::BelongsToCategoryMayDisable diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_versions/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_versions/index.html.erb new file mode 100644 index 000000000..b80949c16 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_versions/index.html.erb @@ -0,0 +1,25 @@ + + + + + + + + + + + <% @bulletin.versions.reverse.each do |version| %> + + + + + + + <% end %> + +
<%= t(:name) %><%= t(:version) %><%= t(:update_at) %><%= t(:last_modified) %>
+ <%= version.title[I18n.locale.to_s] %> +
+ <%= link_to '顯示', panel_announcement_back_end_bulletin_bulletin_version_path(@bulletin, version.version) %> +
+
<%= version.version %><%= display_date(version.updated_at) %><%= User.from_id(version.update_user_id).name rescue ''%>
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_versions/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_versions/show.html.erb new file mode 100644 index 000000000..fa701f006 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_versions/show.html.erb @@ -0,0 +1,33 @@ + + + +<%= link_back %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb index 85b9a4bd4..0f34d5725 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb @@ -61,6 +61,7 @@ + <%= link_to bulletin.version, panel_announcement_back_end_bulletin_bulletin_versions_path(bulletin) %> <%= display_date_time(bulletin.postdate) %> <%= (bulletin.deadline) ? display_date_time(bulletin.deadline ): t(:no_deadline) %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb index 778340ec6..ee72c85f9 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb @@ -7,6 +7,7 @@ + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_sort_headers.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_sort_headers.html.erb index f93bb4cf6..4047361cf 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_sort_headers.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_sort_headers.html.erb @@ -2,6 +2,7 @@ ['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1-2', :status], ['category', 'bulletin_category', 'span1-2', :category], ['title', 'title','span7', :title], + ['version', 'version', 'span1-2', :version], ['start_date', 'postdate', 'span1-2', :start_date], ['end_date', 'deadline', 'span1-2', :end_date], ['tags', 'tags', 'span1-2', :tags], diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index adb637038..cab81a1d1 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -23,6 +23,8 @@ Rails.application.routes.draw do end 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 + + resources :bulletin_versions end resources :bulletin_categorys do