Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Admin
- class AccountsController < ApplicationController
- include SmartListing::Helper::ControllerExtensions
- helper SmartListing::Helper
- before_action :authenticate_user!
- include Pagination::BaseControllerExtension
- # authorize_resource class: false
- before_action :find_account, only: [:edit, :update]
- def index
- # accounts = Account.all
- user_pagination = Pagination::AccountPaginator.new(current_user, current_account, smart_listing_params)
- user_pagination.fetch_resources
- table_data = user_pagination.get_hash_resources
- @filter = smart_listing_params[:filter].to_json
- smart_listing_create :accounts, table_data, partial: 'admin/accounts/listing'
- end
- def edit
- end
- def update
- AccountsManager.update @account, account_params
- AuthService::Service.update_account @account, account_params, current_user
- respond_with_success t('message.success.admin.accounts.update'), admin_accounts_path
- end
- private
- def find_account
- @account = Account.find_by(uniq_code: params[:id])
- raise Exceptions::NotFound if @account.blank?
- end
- def account_params
- params.require(:account).permit(default_access_areas: [])
- end
- def get_smart_listing_params
- if params.key? 'accounts_smart_listing'
- params.require(:accounts_smart_listing).permit(:name, :first_name, :owner, :page, :per_page, :filter, sort: sorting_params).to_h.symbolize_keys
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement