class CourseDiploma
Shows the existing courses and the courses on the server, so that the two can be synchronized.
Public Instance Methods
layout()
click to toggle source
# File Views/Course/Diploma.rb, line 10 def layout set_data_class :Courses @order = 30 @update = true gui_hbox do gui_vbox :nogroup do show_table :diplomas_t, :headings => [:Name, :Grade, :State, :PDF], :widths => [200, 50, 100], :height => 500, :columns => [0, 0, 0, :html] end gui_vbox :nogroup do gui_fields do show_info :status show_button :do_diplomas, :abort end show_print :print end gui_window :missing_data do show_html :missing show_button :close end gui_window :printing do show_html :msg_print show_button :close end end end
pdf_link(path)
click to toggle source
# File Views/Course/Diploma.rb, line 77 def pdf_link(path) "<a target='other' href=\"/getdiplomas/#{path}\">#{File.basename(path)}</a>" end
rpc_list_choice_courses(session, args)
click to toggle source
# File Views/Course/Diploma.rb, line 49 def rpc_list_choice_courses(session, args) args.to_sym! ret = reply(:empty_nonlists, :diplomas_t) if args._courses.length > 0 if course = Courses.match_by_course_id(args._courses.to_a[0]) course.update_state(true) ret += rpc_update_with_values(session, args) end end return ret end
rpc_show(session)
click to toggle source
Calls superclass method
# File Views/Course/Diploma.rb, line 39 def rpc_show(session) super(session) + reply(:hide, [:abort, :status]) end
rpc_update(session)
click to toggle source
Calls superclass method
# File Views/Course/Diploma.rb, line 44 def rpc_update(session) super(session) + reply_print(session) end
rpc_update_with_values(session, args)
click to toggle source
# File Views/Course/Diploma.rb, line 81 def rpc_update_with_values(session, args) #dputs_func args.to_sym! if true (course_id = args._courses[0]) or return [] #ret = rpc_list_choice( session, "courses", "courses" => course_id.to_s ) (course = Entities.Courses.match_by_course_id(course_id)) or return [] else return unless course = args._courses end ret = [] overall_state = course.make_pdfs_state['0'] if overall_state == 'done' ret += reply(:auto_update, 0) + reply(:hide, [:abort, :status]) + reply(:unhide, :do_diplomas) else ret += reply(:auto_update, -5) + reply(:unhide, [:abort, :status]) + reply(:hide, :do_diplomas) + reply(:update, :status => overall_state) end dputs(3) { "Overall_state is #{overall_state}" } states = case course.get_files.select { |f| f =~ /(000-4pp.pdf|zip)$/ }.first when /zip$/ [['all.zip', ['All files', '', '', pdf_link("#{course.name}/all.zip")]]] when /pdf$/ [['000-4pp.pdf', ['4 on 1 page', '', '', pdf_link("#{course.name}/000-4pp.pdf")]], ['000-all.pdf', ['All diplomas', '', '', pdf_link("#{course.name}/000-all.pdf")]]] else dputs(3) { course.get_files.inspect } [] end dputs(3) { "States is #{states}" } states += course.make_pdfs_state.keys.reject { |k| k == '0' }. collect { |s| st = course.make_pdfs_state[s] p = Persons.match_by_login_name(s) link = st[1] == 'done' ? pdf_link(st[2]) : '---' [s, [p.full_name, st[0], st[1], link]] }.sort { |a, b| a[1][0] <=> b[1][0] } return ret + reply_print(session) + reply(:update, :diplomas_t => states) end