class AdminServer
Public Instance Methods
check_availability(t)
click to toggle source
# File Views/Admin/Server.rb, line 18 def check_availability(t) if ConfigBase.server_url.to_s.length == 0 [false, 'No server defined, aborting'] else if Persons.center [true, "Fetching #{t} from server"] else [false, 'There is no center defined, aborting'] end end end
get_ctype(name, ms)
click to toggle source
# File Views/Admin/Server.rb, line 84 def get_ctype(name, ms) ms.status = status_list(true, status: "Downloading CourseType #{name}") cts = ICC.get(:CourseTypes, :fetch, args: {course_type_names: name.to_a}) if cts._code == 'Error' raise StandardError(cts._msg) end log_msg :CourseType, "Downloaded #{name}" ct = cts._msg.first ct = if ct_exist = CourseTypes.match_by_name(ct._name) log_msg :CourseType, "Updating CourseType #{ct._name}" ct_exist.data_set_hash(ct) else log_msg :CourseType, "Creating CourseType #{ct._name}" CourseTypes.create(ct) end [ct._file_diploma, ct._file_exam].compact.each { |f| file = f.first if file.length > 0 ms.status = status_list(true, status: "Downloading file #{file}") rep = ICC.get(:CourseTypes, :_file, args: {name: [file]}) if rep._code == 'OK' data = rep._msg log_msg :CourseType, "Got file #{file} with length #{data.length}" IO.write("#{ConfigBase.template_dir}/#{file}", data) else log_msg :CourseType, "Got error #{rep._msg}" end end } ct end
get_person(name, ms)
click to toggle source
# File Views/Admin/Server.rb, line 126 def get_person(name, ms) if p = Persons.match_by_login_name(name) return p end ms.status = status_list(true, status: "Fetching person #{name}") person = ICC.get(:Persons, :get, args: {center: Persons.center, name: [name]}) if person._code == 'Error' raise StandardError(person._msg) end Persons.create(person._msg.to_sym) end
layout()
click to toggle source
# File Views/Admin/Server.rb, line 2 def layout @functions_need = [:course_client] @order = 300 gui_vbox do show_button :import_ctypes show_button :import_courses gui_window :win_import do show_html :status show_list :import_list show_button :download, :close end end end
rpc_update_with_values(session, data)
click to toggle source
# File Views/Admin/Server.rb, line 118 def rpc_update_with_values(session, data) MakeSteps.make_step(session, data) end
status_list(show_status, status: '', list: [])
click to toggle source
# File Views/Admin/Server.rb, line 30 def status_list(show_status, status: '', list: []) reply_one_two(show_status, :close, :download) + reply_one_two(show_status, :status, :import_list) + if show_status reply(:update, status: status) else reply(:empty, :import_list) + reply(:update, import_list: list) end end