def get_ticket(request): """ this view gives a user access to her ticket via URL with code the response is a PDF download """ _code = request.matchdict['code'] _email = request.matchdict['email'] _ticket = PartyTicket.get_by_code(_code) if isinstance(_ticket, NoneType): return HTTPFound(location=request.route_url('party')) if not (_ticket.email == _email): #print("no match!") return HTTPFound(location=request.route_url('party')) # prepare ticket URL with email & code # 'https://events.c3s.cc/ci/p1402/' + _ticket.email + _ticket.email_confirm_code # 'https://192.168.2.128:6544/ci/p1402/' + _ticket.email + _ticket.email_confirm_code _url = request.registry.settings[ 'c3spartyticketing.url'] + '/ci/p1402/' + _ticket.email_confirm_code # return a pdf file pdf_file = make_qr_code_pdf(_ticket, _url) response = Response(content_type='application/pdf') pdf_file.seek(0) # rewind to beginning response.app_iter = open(pdf_file.name, "r") return response
def test_generate_qr_code(self): """ Test QR-Code generation """ from c3spartyticketing.utils import make_qr_code_pdf _ticket = PartyTicket.get_by_id(1) result = make_qr_code_pdf( _ticket, "http://192.168.2.128:6544/ci/p1402/ABCDEFGBAR") result
def give_ticket(request): """ this view gives a user access to her ticket via URL with code the response is a PDF download """ _code = request.matchdict['code'] _ticket = PartyTicket.get_by_code(_code) # _url = 'https://events.c3s.cc/ci/p1402/' + _ticket.email_confirm_code # _url = 'https://192.168.2.128:6544/ci/p1402/' + _ticket.email_confirm_code _url = request.registry.settings[ 'c3spartyticketing.url'] + '/ci/p1402/' + _ticket.email_confirm_code # return a pdf file pdf_file = make_qr_code_pdf(_url) response = Response(content_type='application/pdf') pdf_file.seek(0) # rewind to beginning response.app_iter = open(pdf_file.name, "r") return response