Advertisement
Guest User

Untitled

a guest
May 31st, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 1.52 KB | None | 0 0
  1. module Admin
  2.   class AccountsController < ApplicationController
  3.     include SmartListing::Helper::ControllerExtensions
  4.     helper SmartListing::Helper
  5.     before_action :authenticate_user!
  6.     include Pagination::BaseControllerExtension
  7.     # authorize_resource class: false
  8.  
  9.     before_action :find_account, only: [:edit, :update]
  10.  
  11.     def index
  12.       # accounts = Account.all
  13.       user_pagination = Pagination::AccountPaginator.new(current_user, current_account, smart_listing_params)
  14.       user_pagination.fetch_resources
  15.       table_data = user_pagination.get_hash_resources
  16.       @filter = smart_listing_params[:filter].to_json
  17.       smart_listing_create :accounts, table_data, partial: 'admin/accounts/listing'
  18.  
  19.     end
  20.  
  21.     def edit
  22.     end
  23.  
  24.     def update
  25.       AccountsManager.update @account, account_params
  26.       AuthService::Service.update_account @account, account_params, current_user
  27.       respond_with_success t('message.success.admin.accounts.update'), admin_accounts_path
  28.     end
  29.  
  30.     private
  31.  
  32.     def find_account
  33.       @account = Account.find_by(uniq_code: params[:id])
  34.       raise Exceptions::NotFound if @account.blank?
  35.     end
  36.  
  37.     def account_params
  38.       params.require(:account).permit(default_access_areas: [])
  39.     end
  40.     def get_smart_listing_params
  41.       if params.key? 'accounts_smart_listing'
  42.         params.require(:accounts_smart_listing).permit(:name, :first_name, :owner, :page, :per_page, :filter, sort: sorting_params).to_h.symbolize_keys
  43.       end
  44.     end
  45.  
  46.   end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement