diff options
| author | Xinhui | 2017-08-25 17:13:24 +0200 |
|---|---|---|
| committer | Xinhui | 2017-08-25 17:13:24 +0200 |
| commit | 0777d35ff4460cf07c34e69ee7c10c0270a446bf (patch) | |
| tree | b2d850bbce3c8669ee6c636fa93e91c5a6a662bc /app/controllers/api_keys_controller.rb | |
| parent | 5dda0f5286043823acab68a73d84437a3cbd803f (diff) | |
| parent | 1d7db2b6c254ac55105c08ee177580036b0377f3 (diff) | |
| download | chouette-core-0777d35ff4460cf07c34e69ee7c10c0270a446bf.tar.bz2 | |
Merge branch 'master' into staging
Diffstat (limited to 'app/controllers/api_keys_controller.rb')
| -rw-r--r-- | app/controllers/api_keys_controller.rb | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/app/controllers/api_keys_controller.rb b/app/controllers/api_keys_controller.rb index 35a84da87..7059cf52e 100644 --- a/app/controllers/api_keys_controller.rb +++ b/app/controllers/api_keys_controller.rb @@ -1,22 +1,32 @@ -class ApiKeysController < ChouetteController - defaults :resource_class => Api::V1::ApiKey - - belongs_to :referential +class ApiKeysController < BreadcrumbController + defaults resource_class: Api::V1::ApiKey def create - create! { referential_path(@referential) } + @api_key = Api::V1::ApiKey.new(api_key_params.merge(organisation: current_organisation)) + create! { organisation_api_keys_path } + end + + def index + @api_keys = decorate_api_keys(current_organisation.api_keys.paginate(page: params[:page])) end + def update - update! { referential_path(@referential) } + update! { organisation_api_key_path(resource) } end + def destroy - destroy! { referential_path(@referential) } + destroy! { organisation_api_keys_path } end private def api_key_params - params.require(:api_key).permit( :name ) - end - -end + params.require(:api_key).permit(:name, :referential_id) + end + def decorate_api_keys(api_keys) + ModelDecorator.decorate( + api_keys, + with: ApiKeyDecorator, + ) + end +end |
