Improved code layout.

This commit is contained in:
Martin Edenhofer 2016-05-11 00:09:10 +02:00
parent 944b9bf498
commit c49bd234fd

View file

@ -12,7 +12,7 @@ class TicketArticlesController < ApplicationController
# GET /articles/1 # GET /articles/1
def show def show
@article = Ticket::Article.find( params[:id] ) @article = Ticket::Article.find(params[:id])
render json: @article render json: @article
end end
@ -21,7 +21,7 @@ class TicketArticlesController < ApplicationController
def create def create
form_id = params[:ticket_article][:form_id] form_id = params[:ticket_article][:form_id]
params[:ticket_article].delete(:form_id) params[:ticket_article].delete(:form_id)
@article = Ticket::Article.new( Ticket::Article.param_validation( params[:ticket_article] ) ) @article = Ticket::Article.new(Ticket::Article.param_validation( params[:ticket_article]))
# find attachments in upload cache # find attachments in upload cache
if form_id if form_id
@ -47,9 +47,9 @@ class TicketArticlesController < ApplicationController
# PUT /articles/1 # PUT /articles/1
def update def update
@article = Ticket::Article.find( params[:id] ) @article = Ticket::Article.find(params[:id])
if @article.update_attributes( Ticket::Article.param_validation( params[:ticket_article] ) ) if @article.update_attributes(Ticket::Article.param_validation(params[:ticket_article]))
render json: @article, status: :ok render json: @article, status: :ok
else else
render json: @article.errors, status: :unprocessable_entity render json: @article.errors, status: :unprocessable_entity
@ -58,7 +58,7 @@ class TicketArticlesController < ApplicationController
# DELETE /articles/1 # DELETE /articles/1
def destroy def destroy
@article = Ticket::Article.find( params[:id] ) @article = Ticket::Article.find(params[:id])
@article.destroy @article.destroy
head :ok head :ok
@ -125,14 +125,14 @@ class TicketArticlesController < ApplicationController
def attachment def attachment
# permission check # permission check
ticket = Ticket.find( params[:ticket_id] ) ticket = Ticket.lookup(id: params[:ticket_id])
if !ticket_permission(ticket) if !ticket_permission(ticket)
render( json: 'No such ticket.', status: :unauthorized ) render(json: 'No such ticket.', status: :unauthorized)
return return
end end
article = Ticket::Article.find( params[:article_id] ) article = Ticket::Article.find(params[:article_id])
if ticket.id != article.ticket_id if ticket.id != article.ticket_id
render( json: 'No access, article_id/ticket_id is not matching.', status: :unauthorized ) render(json: 'No access, article_id/ticket_id is not matching.', status: :unauthorized)
return return
end end
@ -144,7 +144,7 @@ class TicketArticlesController < ApplicationController
end end
} }
if !access if !access
render( json: 'Requested file id is not linked with article_id.', status: :unauthorized ) render(json: 'Requested file id is not linked with article_id.', status: :unauthorized)
return return
end end
@ -162,8 +162,8 @@ class TicketArticlesController < ApplicationController
def article_plain def article_plain
# permission check # permission check
article = Ticket::Article.find( params[:id] ) article = Ticket::Article.find(params[:id])
return if !ticket_permission( article.ticket ) return if !ticket_permission(article.ticket)
list = Store.list( list = Store.list(
object: 'Ticket::Article::Mail', object: 'Ticket::Article::Mail',