Add link_to_edit for frontend

This commit is contained in:
manson 2014-08-05 14:37:33 +08:00
parent 9fc4bffff3
commit 8467dd3189
3 changed files with 10 additions and 7 deletions

View File

@ -41,7 +41,7 @@ class Admin::AnnouncementsController < OrbitAdminController
bulletin.update_user_id = current_user.id bulletin.update_user_id = current_user.id
bulletin.save bulletin.save
build_email(bulletin) build_email(bulletin)
redirect_to "/admin/announcements" redirect_to params['referer_url']
end end
def edit def edit
@ -50,9 +50,9 @@ class Admin::AnnouncementsController < OrbitAdminController
@categories = @module_app.categories.enabled @categories = @module_app.categories.enabled
@statuses = [] @statuses = []
@bulletin.email_sentdate = Time.now if @bulletin.email_sent == false @bulletin.email_sentdate = Time.now if @bulletin.email_sent == false
else else
render_401 render_401
end end
end end
def update def update
@ -70,7 +70,7 @@ class Admin::AnnouncementsController < OrbitAdminController
bulletin.update_attributes(bulletin_params) bulletin.update_attributes(bulletin_params)
bulletin.save bulletin.save
build_email(bulletin) build_email(bulletin)
redirect_to "/admin/announcements" redirect_to params['referer_url']
end end
def destroy def destroy

View File

@ -60,9 +60,10 @@ class AnnouncementsController < ApplicationController
def show def show
params = OrbitHelper.params params = OrbitHelper.params
announcement = Bulletin.can_display.find_by(:uid=>params[:uid]) 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| { tags = announcement.tags.map{|tag| {
"tag" => tag.name , "tag" => tag.name ,
"url" => OrbitHelper.page_for_tag(tag) "url" => OrbitHelper.page_for_tag(tag)
@ -81,7 +82,8 @@ class AnnouncementsController < ApplicationController
"body" =>announcement.text, "body" =>announcement.text,
"image" => announcement.image.url "image" => announcement.image.url
}, },
"impressionist" => (announcement.is_preview ? nil : announcement) "impressionist" => (announcement.is_preview ? nil : announcement),
"url_to_edit"=>url_to_edit
} }
end end

View File

@ -287,6 +287,7 @@
<!-- Form Actions --> <!-- Form Actions -->
<div class="form-actions"> <div class="form-actions">
<%= f.submit t('submit'), class: 'btn btn-primary' %> <%= f.submit t('submit'), class: 'btn btn-primary' %>
<input type="hidden" name="referer_url" value="<%= request.referer %>">
<%= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn', type: :button %> <%= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn', type: :button %>
<%= link_to t('cancel'), admin_announcements_path, :class=>"btn" %> <%= link_to t('cancel'), admin_announcements_path, :class=>"btn" %>
</div> </div>