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.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

View File

@ -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

View File

@ -287,6 +287,7 @@
<!-- Form Actions -->
<div class="form-actions">
<%= 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 %>
<%= link_to t('cancel'), admin_announcements_path, :class=>"btn" %>
</div>