small fix for preview

This commit is contained in:
Harry Bomrah 2015-10-19 16:59:26 +08:00
parent 17a0e4b4ce
commit 8cfc89abcc
2 changed files with 8 additions and 4 deletions

View File

@ -205,7 +205,7 @@ class Admin::AnnouncementsController < OrbitAdminController
bulletin.is_preview = true bulletin.is_preview = true
bulletin.save bulletin.save
render :text=>page_for_bulletin(bulletin) render :text=>page_for_bulletin(bulletin) + "?preview=true"
end end
def destroy_preview def destroy_preview

View File

@ -146,8 +146,12 @@ class AnnouncementsController < ApplicationController
} }
end end
def show_local_announcement(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) announcement = Bulletin.can_display.find_by(:uid => uid)
end
url_to_edit = OrbitHelper.user_can_edit?(announcement) ? "/admin/announcements/#{announcement.id.to_s}/edit" : "" url_to_edit = OrbitHelper.user_can_edit?(announcement) ? "/admin/announcements/#{announcement.id.to_s}/edit" : ""
access_level = OrbitHelper.user_access_level? access_level = OrbitHelper.user_access_level?
@ -247,7 +251,7 @@ class AnnouncementsController < ApplicationController
if OrbitHelper.is_object_from_feed?(uid) if OrbitHelper.is_object_from_feed?(uid)
show_feed_announcement(uid) show_feed_announcement(uid)
else else
show_local_announcement(uid) show_local_announcement(uid, (params["preview"] == "true" ? true : false))
end end
end end