printme.local only text no png
This commit is contained in:
		
							
								
								
									
										15
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								main.py
									
									
									
									
									
								
							@@ -130,23 +130,19 @@ def order():
 | 
			
		||||
        print("[DEBUG] Pretix returned no JSON")
 | 
			
		||||
        return jsonify({"error": "Pretix returned no JSON", "status_code": resp.status_code, "text": resp.text}), 502
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if "positions" in resp_json and "item" in resp_json["positions"][0] and isinstance(resp_json["positions"][0]["item"], list):
 | 
			
		||||
        if isinstance(resp_json["positions"][0]["item"][0], str):
 | 
			
		||||
            print("[DEBUG] Not enough quota available")
 | 
			
		||||
            return "Essen ist bereits alle", 418
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    try:
 | 
			
		||||
        secret = resp_json["positions"][0]["secret"]
 | 
			
		||||
        print(f"[DEBUG] Secret: {secret}")
 | 
			
		||||
    except (KeyError, IndexError):
 | 
			
		||||
        return jsonify({"error": "Secret not found in Pretix response", "resp_json": resp_json}), 500
 | 
			
		||||
 | 
			
		||||
    qr_bytes = generate_qr(secret)
 | 
			
		||||
    meal_times = get_meal_times(meal_key)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    mail_body = MAIL_TEMPLATE.render(
 | 
			
		||||
        meal_name=meal_info["name"],
 | 
			
		||||
        meal_name_en=meal_info["name_en"],
 | 
			
		||||
@@ -154,18 +150,11 @@ def order():
 | 
			
		||||
        meal_times=meal_times
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if email.endswith("@printme.local"):
 | 
			
		||||
        log_printed(email, meal_key)
 | 
			
		||||
        response = app.response_class(
 | 
			
		||||
            response=qr_bytes,
 | 
			
		||||
            status=200,
 | 
			
		||||
            mimetype='image/png'
 | 
			
		||||
        )
 | 
			
		||||
        response.headers["Content-Disposition"] = f"inline; filename=ticket.png"
 | 
			
		||||
        return response
 | 
			
		||||
 | 
			
		||||
        return secret, 200, {"Content-Type": "text/plain; charset=utf-8"}
 | 
			
		||||
 | 
			
		||||
    qr_bytes = generate_qr(secret)
 | 
			
		||||
    send_email(email, "Dein Engelessen / Your Angel Meal", mail_body, qr_bytes, "ticket.png")
 | 
			
		||||
 | 
			
		||||
    return "Token gesendet", 201
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user