Use imported scope to simplify trace controller methods
This commit is contained in:
parent
50df5eefcc
commit
91143a5959
3 changed files with 15 additions and 22 deletions
|
@ -6,21 +6,17 @@ module Traces
|
|||
authorize_resource :trace
|
||||
|
||||
def show
|
||||
trace = Trace.visible.find(params[:trace_id])
|
||||
trace = Trace.visible.imported.find(params[:trace_id])
|
||||
|
||||
if trace.inserted?
|
||||
if trace.public? || (current_user && current_user == trace.user)
|
||||
if trace.icon.attached?
|
||||
redirect_to rails_blob_path(trace.icon, :disposition => "inline")
|
||||
else
|
||||
expires_in 7.days, :private => !trace.public?, :public => trace.public?
|
||||
send_file(trace.icon_picture_name, :filename => "#{trace.id}_icon.gif", :type => "image/gif", :disposition => "inline")
|
||||
end
|
||||
if trace.public? || (current_user && current_user == trace.user)
|
||||
if trace.icon.attached?
|
||||
redirect_to rails_blob_path(trace.icon, :disposition => "inline")
|
||||
else
|
||||
head :forbidden
|
||||
expires_in 7.days, :private => !trace.public?, :public => trace.public?
|
||||
send_file(trace.icon_picture_name, :filename => "#{trace.id}_icon.gif", :type => "image/gif", :disposition => "inline")
|
||||
end
|
||||
else
|
||||
head :not_found
|
||||
head :forbidden
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
head :not_found
|
||||
|
|
|
@ -6,21 +6,17 @@ module Traces
|
|||
authorize_resource :trace
|
||||
|
||||
def show
|
||||
trace = Trace.visible.find(params[:trace_id])
|
||||
trace = Trace.visible.imported.find(params[:trace_id])
|
||||
|
||||
if trace.inserted?
|
||||
if trace.public? || (current_user && current_user == trace.user)
|
||||
if trace.icon.attached?
|
||||
redirect_to rails_blob_path(trace.image, :disposition => "inline")
|
||||
else
|
||||
expires_in 7.days, :private => !trace.public?, :public => trace.public?
|
||||
send_file(trace.large_picture_name, :filename => "#{trace.id}.gif", :type => "image/gif", :disposition => "inline")
|
||||
end
|
||||
if trace.public? || (current_user && current_user == trace.user)
|
||||
if trace.icon.attached?
|
||||
redirect_to rails_blob_path(trace.image, :disposition => "inline")
|
||||
else
|
||||
head :forbidden
|
||||
expires_in 7.days, :private => !trace.public?, :public => trace.public?
|
||||
send_file(trace.large_picture_name, :filename => "#{trace.id}.gif", :type => "image/gif", :disposition => "inline")
|
||||
end
|
||||
else
|
||||
head :not_found
|
||||
head :forbidden
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
head :not_found
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue