def mass(): filename = request.form['filename'] printer = request.form.get('printer', DEFAULT_PRINTER) count = int(request.form['count']) for _ in range(count): print_file(os.path.join(PDF_UPLOAD_PATH, filename), printer) return "OK"
def contestant(): temp_directory = create_temp_directory() original_pdf_path = os.path.join(temp_directory, 'original.pdf') request.files['pdf'].save(original_pdf_path) contestant_data = get_contestant_data(_real_ip()) contestant_id = (contestant_data['contestant'] or {}).get('id', '') desk_zone = (contestant_data['desk'] or {}).get('zone') print_id = generate_print_id() hostname = platform.uname().node final_pdf_path = modifier.make_contestant_pdf( pdf_file_path=original_pdf_path, contestant=contestant_data['contestant'], desk=contestant_data['desk'], print_id=print_id, temp_directory=temp_directory, ) job_name = 'contestant:%s:%s' % (contestant_id, print_id) metric_name = 'contestant:%s' % (contestant_id) print_file(file_path=final_pdf_path, printer=settings.printer_for_contestant(desk_zone), job_name=job_name, metric_name=metric_name) return "Queued as %s on %s" % (print_id, hostname)
def mass(): temp_directory = create_temp_directory() original_pdf_path = os.path.join(temp_directory, 'original.pdf') request.files['pdf'].save(original_pdf_path) printer = request.form.get('printer', settings.printer_for_mass()) count = int(request.form['count']) for _ in range(count): print_file(original_pdf_path, printer, 'mass') return "OK"
def translation(): filename = request.form['filename'] country_code = request.form['country_code'] country_name = request.form['country_name'] count = int(request.form['count']) temp_directory = create_temp_directory() final_pdf_path = make_translation_pdf( os.path.join(PDF_UPLOAD_PATH, filename), country_code, country_name, temp_directory ) for _ in range(count): print_file(final_pdf_path, DEFAULT_PRINTER) return "OK"
def password(): req_data = request.get_json() title = req_data['title'] users = req_data['users'] temp_directory = create_temp_directory() pdf_path = modifier.make_password_pdf( title=title, users=users, temp_directory=temp_directory, ) job_name = 'password' print_file(pdf_path, settings.printer_for_mass(), job_name) return jsonify({'status': 'OK'})
def cms_request(): request_message = request.form['request_message'] ip = request.form['ip'] contestant_data = get_contestant_data(ip) temp_directory = create_temp_directory() if 'desk_image_url' in contestant_data: desk_map_img = download(contestant_data['desk_image_url'], 'desk_map.svg', temp_directory) else: desk_map_img = contestant_data['desk_image_path'] request_pdf_path = make_cms_request_pdf( request_message, contestant_data['contestant_id'], contestant_data['contestant_name'], contestant_data['desk_id'], desk_map_img, temp_directory ) print_file(request_pdf_path, PRINTER_FOR_ZONE[contestant_data['zone']]) return "OK"
def staff_call(): req_data = request.get_json() message = req_data['message'] contestant = req_data['contestant'] contestant_id = req_data['contestant']['id'] desk = req_data['desk'] desk_zone = req_data['desk'].get('zone') temp_directory = create_temp_directory() pdf_path = modifier.make_staff_call_pdf( message=message, contestant=contestant, desk=desk, temp_directory=temp_directory, ) job_name = 'staff_call:%s' % contestant_id print_file(pdf_path, settings.printer_for_contestant(desk_zone), job_name, job_priority=JOB_PRIORITY_HIGH) return jsonify({'status': 'OK'})
def contestant(): filename = request.form['filename'] ip = request.form['ip'] cups_job_id = request.form['cups_job_id'] contestant_data = get_contestant_data(ip) temp_directory = create_temp_directory() if 'desk_image_url' in contestant_data: desk_map_img = download(contestant_data['desk_image_url'], 'desk_map.svg', temp_directory) else: desk_map_img = contestant_data['desk_image_path'] final_pdf_path = make_contestant_pdf( os.path.join(PDF_UPLOAD_PATH, filename), contestant_data['contestant_id'], contestant_data['contestant_name'], contestant_data['contestant_country'], contestant_data['desk_id'], desk_map_img, cups_job_id, temp_directory ) print_file(final_pdf_path, PRINTER_FOR_ZONE[contestant_data['zone']]) return "OK"
def translation(): temp_directory = create_temp_directory() original_pdf_path = os.path.join(temp_directory, 'original.pdf') request.files['pdf'].save(original_pdf_path) country_code = request.form['country_code'] country_name = request.form['country_name'] cover_page = int(request.form['cover_page']) > 0 count = int(request.form['count']) if cover_page: final_pdf_path = modifier.make_translation_pdf(original_pdf_path, country_code, country_name, temp_directory) else: final_pdf_path = original_pdf_path job_name = 'translation:%s' % country_code for _ in range(count): print_file(final_pdf_path, settings.printer_for_translation(), job_name) return "OK"