diff --git a/app/controllers/admin/announcements_controller.rb b/app/controllers/admin/announcements_controller.rb index 67f2b1d..c1d2a0f 100644 --- a/app/controllers/admin/announcements_controller.rb +++ b/app/controllers/admin/announcements_controller.rb @@ -41,7 +41,7 @@ class Admin::AnnouncementsController < OrbitAdminController bulletin.update_user_id = current_user.id bulletin.save build_email(bulletin) - redirect_to "/admin/announcements" + redirect_to params['referer_url'] end def edit @@ -50,9 +50,9 @@ class Admin::AnnouncementsController < OrbitAdminController @categories = @module_app.categories.enabled @statuses = [] @bulletin.email_sentdate = Time.now if @bulletin.email_sent == false - else - render_401 - end + else + render_401 + end end def update @@ -70,7 +70,7 @@ class Admin::AnnouncementsController < OrbitAdminController bulletin.update_attributes(bulletin_params) bulletin.save build_email(bulletin) - redirect_to "/admin/announcements" + redirect_to params['referer_url'] end def destroy diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index 4ab1ac5..9280860 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -60,9 +60,10 @@ class AnnouncementsController < ApplicationController def show params = OrbitHelper.params - announcement = Bulletin.can_display.find_by(:uid=>params[:uid]) + url_to_edit = OrbitHelper.user_can_edit?(announcement) ? "/admin/announcements/#{announcement.id.to_s}/edit" : "" + tags = announcement.tags.map{|tag| { "tag" => tag.name , "url" => OrbitHelper.page_for_tag(tag) @@ -81,7 +82,8 @@ class AnnouncementsController < ApplicationController "body" =>announcement.text, "image" => announcement.image.url }, - "impressionist" => (announcement.is_preview ? nil : announcement) + "impressionist" => (announcement.is_preview ? nil : announcement), + "url_to_edit"=>url_to_edit } end diff --git a/app/views/admin/announcements/_form.html.erb b/app/views/admin/announcements/_form.html.erb index ef4cd52..9623791 100644 --- a/app/views/admin/announcements/_form.html.erb +++ b/app/views/admin/announcements/_form.html.erb @@ -287,6 +287,7 @@