diff options
| author | Xinhui | 2017-08-18 14:35:30 +0200 | 
|---|---|---|
| committer | Xinhui | 2017-08-18 14:38:09 +0200 | 
| commit | dba01bf83eed749a96a55bb751245568cd476152 (patch) | |
| tree | 254b6b8aa22847fb3b2fc8c73bba522417b5744f /app/controllers/api_keys_controller.rb | |
| parent | 30b746b8b238c9ba22e972556e94950adb3f5e8b (diff) | |
| download | chouette-core-dba01bf83eed749a96a55bb751245568cd476152.tar.bz2 | |
Refactoring api_keys views with table_builder
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..bd225818b 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_key_path(resource) } +  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 | 
