mirror of
https://github.com/bszczuka/steel-training.git
synced 2025-12-21 13:23:02 +01:00
Add custom target distance forsingle targets
This commit is contained in:
38
app.py
38
app.py
@@ -143,6 +143,10 @@ def shootoff():
|
||||
def ipsc():
|
||||
return render_template('ipsc.html', current_url=request.path)
|
||||
|
||||
@app.route('/custom')
|
||||
def custom():
|
||||
return render_template('custom.html', current_url=request.path)
|
||||
|
||||
@app.route('/generate-pdf', methods=['POST'])
|
||||
def generate_pdf():
|
||||
distance = int(request.form.get('distance', 1) or 1)
|
||||
@@ -264,6 +268,40 @@ def generate_pdf_ipsc():
|
||||
|
||||
return send_file(pdf_file, download_name=filename, as_attachment=False)
|
||||
|
||||
@app.route('/generate-pdf-custom', methods=['POST'])
|
||||
def generate_pdf_custom():
|
||||
distance = int(request.form.get('distance', 1) or 1)
|
||||
simulated_distance_meters = int(request.form.get('simulated_distance') or 1)
|
||||
simulated_distance = simulated_distance_meters * 100
|
||||
size = request.form.get('size')
|
||||
target_type = request.form.get('target_type')
|
||||
scale = distance / simulated_distance
|
||||
print(distance,simulated_distance_meters, simulated_distance, scale)
|
||||
original_target_height= IPSC_TARGET_HEIGHT if target_type == 'ipsc' else IDPA_TARGET_HEIGHT
|
||||
|
||||
rendered_html = render_template(
|
||||
'pdf_template_custom.html',
|
||||
distance=distance,
|
||||
size=size,
|
||||
target_height=scale * original_target_height,
|
||||
target_width=scale * IPSC_TARGET_WIDTH,
|
||||
gap=scale * IPSC_GAP + scale * IPSC_TARGET_WIDTH,
|
||||
target_type=target_type,
|
||||
simulated_distance=simulated_distance_meters
|
||||
)
|
||||
# return rendered_html
|
||||
|
||||
pdf_file = io.BytesIO()
|
||||
HTML(string=rendered_html).write_pdf(pdf_file)
|
||||
pdf_file.seek(0)
|
||||
filename = 'Steel Training - '+target_type.upper()+' - Sim: ' + str(simulated_distance_meters) + 'm - ' + str(distance) + 'cm-' + size + '.pdf'
|
||||
|
||||
return send_file(pdf_file, download_name=filename, as_attachment=False)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def calculate_distance(desired_wall_length, stage, size):
|
||||
wall_extra_space_for_paper = 297 if size == 'a3' else 210
|
||||
|
||||
Reference in New Issue
Block a user