Resourceful route names for api/trace_controller
This commit is contained in:
parent
36817f777c
commit
5444af981c
5 changed files with 74 additions and 74 deletions
|
@ -33,7 +33,7 @@ class ApiAbility
|
|||
can [:new, :create, :reply, :show, :inbox, :outbox, :mark, :destroy], Message
|
||||
can [:close, :reopen], Note
|
||||
can [:new, :create], Report
|
||||
can [:api_create, :api_read, :api_update, :api_delete, :api_data], Trace
|
||||
can [:create, :show, :update, :destroy, :data], Trace
|
||||
can [:api_details, :api_gpx_files], User
|
||||
can [:read, :read_one, :update, :update_one, :delete_one], UserPreference
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ class ApiCapability
|
|||
def initialize(token)
|
||||
if Settings.status != "database_offline"
|
||||
can [:create, :comment, :close, :reopen], Note if capability?(token, :allow_write_notes)
|
||||
can [:api_read, :api_data], Trace if capability?(token, :allow_read_gpx)
|
||||
can [:api_create, :api_update, :api_delete], Trace if capability?(token, :allow_write_gpx)
|
||||
can [:show, :data], Trace if capability?(token, :allow_read_gpx)
|
||||
can [:create, :update, :destroy], Trace if capability?(token, :allow_write_gpx)
|
||||
can [:api_details], User if capability?(token, :allow_read_prefs)
|
||||
can [:api_gpx_files], User if capability?(token, :allow_read_gpx)
|
||||
can [:read, :read_one], UserPreference if capability?(token, :allow_read_prefs)
|
||||
|
|
|
@ -8,14 +8,14 @@ module Api
|
|||
|
||||
authorize_resource
|
||||
|
||||
before_action :check_database_readable, :except => [:api_read, :api_data]
|
||||
before_action :check_database_writable, :only => [:api_create, :api_update, :api_delete]
|
||||
before_action :check_api_readable, :only => [:api_read, :api_data]
|
||||
before_action :check_api_writable, :only => [:api_create, :api_update, :api_delete]
|
||||
before_action :offline_redirect, :only => [:api_create, :api_delete, :api_data]
|
||||
before_action :check_database_readable, :except => [:show, :data]
|
||||
before_action :check_database_writable, :only => [:create, :update, :destroy]
|
||||
before_action :check_api_readable, :only => [:show, :data]
|
||||
before_action :check_api_writable, :only => [:create, :update, :destroy]
|
||||
before_action :offline_redirect, :only => [:create, :destroy, :data]
|
||||
around_action :api_call_handle_error
|
||||
|
||||
def api_read
|
||||
def show
|
||||
trace = Trace.visible.find(params[:id])
|
||||
|
||||
if trace.public? || trace.user == current_user
|
||||
|
@ -25,7 +25,7 @@ module Api
|
|||
end
|
||||
end
|
||||
|
||||
def api_update
|
||||
def update
|
||||
trace = Trace.visible.find(params[:id])
|
||||
|
||||
if trace.user == current_user
|
||||
|
@ -38,7 +38,7 @@ module Api
|
|||
end
|
||||
end
|
||||
|
||||
def api_delete
|
||||
def destroy
|
||||
trace = Trace.visible.find(params[:id])
|
||||
|
||||
if trace.user == current_user
|
||||
|
@ -52,7 +52,7 @@ module Api
|
|||
end
|
||||
end
|
||||
|
||||
def api_data
|
||||
def data
|
||||
trace = Trace.visible.find(params[:id])
|
||||
|
||||
if trace.public? || trace.user == current_user
|
||||
|
@ -68,7 +68,7 @@ module Api
|
|||
end
|
||||
end
|
||||
|
||||
def api_create
|
||||
def create
|
||||
tags = params[:tags] || ""
|
||||
description = params[:description] || ""
|
||||
visibility = params[:visibility]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue