Fixed attachment download.
This commit is contained in:
parent
d36732dcf0
commit
b291af1c04
4 changed files with 40 additions and 20 deletions
|
@ -193,8 +193,8 @@ class Index extends App.Controller
|
|||
|
||||
bulk_form: =>
|
||||
@configure_attributes_ticket = [
|
||||
{ name: 'ticket_state_id', display: 'State', tag: 'select', multiple: false, null: true, relation: 'TicketState', filter: @bulk, nulloption: true, default: '', class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'ticket_priority_id', display: 'Priority', tag: 'select', multiple: false, null: true, relation: 'TicketPriority', filter: @bulk, nulloption: true, default: '', class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'ticket_state_id', display: 'State', tag: 'select', multiple: false, null: true, relation: 'TicketState', filter: @bulk, translate: true, nulloption: true, default: '', class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'ticket_priority_id', display: 'Priority', tag: 'select', multiple: false, null: true, relation: 'TicketPriority', filter: @bulk, translate: true, nulloption: true, default: '', class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: true, relation: 'Group', filter: @bulk, nulloption: true, class: 'span2', item_class: 'keepleft' },
|
||||
{ name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, null: true, relation: 'User', filter: @bulk, nulloption: true, class: 'span2', item_class: 'keepleft' },
|
||||
]
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<% if article.attachments: %>
|
||||
<div>
|
||||
<% for attachment in article.attachments: %>
|
||||
<a href="ticket_attachment/<%= attachment.id %>" target="_blank" data-type="attachment" class="" title="<%= attachment.size %>"><%= attachment.filename %></a>
|
||||
<a href="ticket_attachment/<%= article.ticket_id %>/<%= article.id %>/<%= attachment.id %>" target="_blank" data-type="attachment" class="" title="<%= attachment.size %>"><%= attachment.filename %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -286,7 +286,27 @@ class TicketOverviewsController < ApplicationController
|
|||
|
||||
# permissin check
|
||||
ticket = Ticket.find( params[:ticket_id] )
|
||||
return if !ticket_permission(ticket)
|
||||
if !ticket_permission(ticket)
|
||||
render( :json => 'No such ticket.', :status => :unauthorized )
|
||||
return
|
||||
end
|
||||
article = Ticket::Article.find( params[:article_id] )
|
||||
if ticket.id != article.ticket_id
|
||||
render( :json => 'No access, article_id/ticket_id is not matching.', :status => :unauthorized )
|
||||
return
|
||||
end
|
||||
|
||||
list = Store.list( :object => 'Ticket::Article', :o_id => params[:article_id] ) || []
|
||||
access = false
|
||||
list.each {|item|
|
||||
if item.id.to_i == params[:id].to_i
|
||||
access = true
|
||||
end
|
||||
}
|
||||
if !access
|
||||
render( :json => 'Requested file id is not linked with article_id.', :status => :unauthorized )
|
||||
return
|
||||
end
|
||||
|
||||
# find file
|
||||
file = Store.find(params[:id])
|
||||
|
|
|
@ -8,7 +8,7 @@ module ExtraRoutes
|
|||
map.resources :ticket_states, :only => [:create, :show, :index, :update]
|
||||
map.resources :tickets, :only => [:create, :show, :index, :update]
|
||||
map.match '/ticket_full/:id', :to => 'ticket_overviews#ticket_full'
|
||||
map.match '/ticket_attachment/:id', :to => 'ticket_overviews#ticket_attachment'
|
||||
map.match '/ticket_attachment/:ticket_id/:article_id/:id', :to => 'ticket_overviews#ticket_attachment'
|
||||
map.match '/ticket_attachment_new', :to => 'ticket_overviews#ticket_attachment_new'
|
||||
map.match '/ticket_article_plain/:id', :to => 'ticket_overviews#ticket_article_plain'
|
||||
map.match '/ticket_history/:id', :to => 'ticket_overviews#ticket_history'
|
||||
|
|
Loading…
Reference in a new issue