mirror of
https://github.com/internetee/registry.git
synced 2025-07-02 01:03:35 +02:00
Add account activities view to admin #2893
This commit is contained in:
parent
ce3397dbfb
commit
34e4342219
7 changed files with 151 additions and 0 deletions
28
app/controllers/admin/account_activities_controller.rb
Normal file
28
app/controllers/admin/account_activities_controller.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
class Admin::AccountActivitiesController < AdminController
|
||||
load_and_authorize_resource
|
||||
|
||||
def index # rubocop: disable Metrics/AbcSize
|
||||
params[:q] ||= {}
|
||||
# account = current_user.registrar.cash_account
|
||||
|
||||
ca_cache = params[:q][:created_at_lteq]
|
||||
begin
|
||||
end_time = params[:q][:created_at_lteq].try(:to_date)
|
||||
params[:q][:created_at_lteq] = end_time.try(:end_of_day)
|
||||
rescue
|
||||
logger.warn('Invalid date')
|
||||
end
|
||||
|
||||
@q = AccountActivity.includes(:invoice, account: :registrar).search(params[:q])
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
|
||||
respond_to do |format|
|
||||
format.html { @account_activities = @q.result.page(params[:page]) }
|
||||
format.csv do
|
||||
send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"
|
||||
end
|
||||
end
|
||||
|
||||
params[:q][:created_at_lteq] = ca_cache
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue