From 8cfc89abccdb0ce3be8f319a6700fcd81c99331f Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 19 Oct 2015 16:59:26 +0800 Subject: [PATCH] small fix for preview --- app/controllers/admin/announcements_controller.rb | 2 +- app/controllers/announcements_controller.rb | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/announcements_controller.rb b/app/controllers/admin/announcements_controller.rb index 03fe0d7..41ddc11 100644 --- a/app/controllers/admin/announcements_controller.rb +++ b/app/controllers/admin/announcements_controller.rb @@ -205,7 +205,7 @@ class Admin::AnnouncementsController < OrbitAdminController bulletin.is_preview = true bulletin.save - render :text=>page_for_bulletin(bulletin) + render :text=>page_for_bulletin(bulletin) + "?preview=true" end def destroy_preview diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index 451c474..140477c 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -146,8 +146,12 @@ class AnnouncementsController < ApplicationController } end - def show_local_announcement(uid) - announcement = Bulletin.can_display.find_by(:uid => uid) + def show_local_announcement(uid, is_preview) + if is_preview + announcement = Bulletin.find_by(:uid => uid) + else + announcement = Bulletin.can_display.find_by(:uid => uid) + end url_to_edit = OrbitHelper.user_can_edit?(announcement) ? "/admin/announcements/#{announcement.id.to_s}/edit" : "" access_level = OrbitHelper.user_access_level? @@ -247,7 +251,7 @@ class AnnouncementsController < ApplicationController if OrbitHelper.is_object_from_feed?(uid) show_feed_announcement(uid) else - show_local_announcement(uid) + show_local_announcement(uid, (params["preview"] == "true" ? true : false)) end end