def METHOD_NAME(user_id=None):
    if current_user.has_permission("admin") and user_id is not None:
        user = User.query.get(user_id)
    else:
        user = current_user
    if not user.owned_purchases.filter_by(is_paid_for=True).all():
        abort(404)
    png = bool(request.args.get("png"))
    pdf = bool(request.args.get("pdf"))
    page = render_receipt(user, png, pdf)
    if pdf:
        url = external_url("tickets.receipt", user_id=user_id)
        return send_file(render_pdf(url, page), mimetype="application/pdf", max_age=60)
    return page