Class: Kaui::AdminController

Inherits:
EngineController show all
Defined in:
app/controllers/kaui/admin_controller.rb

Constant Summary

Constants included from EngineControllerUtil

EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD

Instance Method Summary collapse

Methods inherited from EngineController

#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient, #populate_account_details, #retrieve_allowed_users_for_current_user, #retrieve_tenants_for_current_user

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/kaui/admin_controller.rb', line 5

def index
  begin
    @clock = Kaui::Admin.get_clock(nil, options_for_klient)
  rescue KillBillClient::API::NotFound
    flash[:error] = "Failed to get current KB clock: Kill Bill server must be started with system property org.killbill.server.test.mode=true"
    redirect_to admin_tenants_path and return
  end

  params.permit!

  respond_to do |format|
    format.html
    format.js
  end
end

#set_clockObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/kaui/admin_controller.rb', line 21

def set_clock
  if params[:commit] == 'Submit'
    current_datetime = DateTime.parse(Kaui::Admin.get_clock(nil, options_for_klient)['currentUtcTime'])
    new_local_date = Date.parse(params[:new_date])
    new_datetime = DateTime.new(new_local_date.year, new_local_date.month, new_local_date.day, current_datetime.hour, current_datetime.min, current_datetime.sec, 'Z').to_s
    msg = "Clock was successfully updated to #{new_datetime}"
  else
    new_datetime = nil
    msg = 'Clock was successfully reset'
  end
  begin
    Kaui::Admin.set_clock(new_datetime, nil, options_for_klient)
  rescue KillBillClient::API::NotFound
    flash[:error] = "Failed to set current KB clock: Kill Bill server must be started with system property org.killbill.server.test.mode=true"
    redirect_to admin_tenants_path and return
  end

  redirect_to admin_path, :notice => msg
end