Exemple #1
0
def create_transaction():
    sqlHandler = SqlHandler(mysql)
    jsonData = request.get_json()
    jwt_service = JWTService()

    buyer_id = jwt_service.get_account(jsonData['token'])
    event_id = jsonData['eventID']
    tickets = jsonData['tickets']
    commission = jsonData['commission']
    tax = jsonData['tax']
    subtotal = jsonData['subtotal']
    total = jsonData['total']
    group_id = jsonData['group_id']
    tax_per_ticket = jsonData['taxPerTicket']
    comm_per_ticket = jsonData['commPerTicket']
    subtotal_per_ticket = jsonData['subtotalPerTicket']

    success = sqlHandler.create_transaction(buyer_id, tickets, commission, tax,
                                            subtotal, total, group_id,
                                            tax_per_ticket, comm_per_ticket,
                                            subtotal_per_ticket)
    if success:
        event_info = sqlHandler.get_event_info(event_id)
        phone_num, email = sqlHandler.get_seller_email_and_phone(group_id)
        thr = threading.Thread(target=TTTEmailClient.send_sale_confirmation,
                               args=(email, event_info, tickets, commission,
                                     tax, subtotal, total))
        thr.start()

    return jsonify({'success': success})
    def createListing(self):
        sqlHandler = SqlHandler(self.mysql)
        jwt_service = JWTService()
        jsonData = self.json

        sectionNum = jsonData['section']
        rowNum = jsonData['row']
        seatsInfo = jsonData['seatsInfo']
        ticketPrice = jsonData['ticketPrice']
        numberOfTickets = jsonData['numberOfTickets']
        minPurchaseSize = jsonData['minPurchaseSize']
        gameDate = jsonData['dbGameDate']
        accountID = jwt_service.get_account(jsonData['token'])

        ticketIds = sqlHandler.insert_ticket_listing(sectionNum, rowNum,
                                                     seatsInfo, ticketPrice,
                                                     numberOfTickets,
                                                     minPurchaseSize, gameDate,
                                                     accountID)

        print(ticketIds)

        mysqlInsertSuccess = False

        if (ticketIds):
            mysqlInsertSuccess = True

        fileUploadSuccess = self.pdfworker.splitPDF(self.file, ticketIds)
        #fileUploadSuccess = True

        return mysqlInsertSuccess and fileUploadSuccess
Exemple #3
0
def get_account_info():
    if 'application/json' in request.headers.environ['CONTENT_TYPE']:
        jsonData = request.get_json()
        try:
            jwt_service = JWTService()
            account_id = jwt_service.get_account(jsonData['token'])
            sqlHandler = SqlHandler(mysql)
            return jsonify(sqlHandler.get_account_info(account_id))
        except Exception as e:
            return jsonify({'authenticated': False})
Exemple #4
0
def hold_tickets():
    jsonData = request.get_json()
    try:
        jwt_service = JWTService()
        account_id = jwt_service.get_account(jsonData['token'])
        sqlHandler = SqlHandler(mysql)
        result = sqlHandler.hold_tickets(account_id, jsonData['ticketIds'])
        return jsonify({'authenticated': result, 'timer': 30000})  # 5 minutes
    except Exception as e:
        print(e)
        return jsonify({'authenticated': False})
Exemple #5
0
def get_buyer_purchases():
    jsonData = request.get_json()
    try:
        jwt_service = JWTService()
        account_id = jwt_service.get_account(jsonData['token'])
        sqlHandler = SqlHandler(mysql)
        transactions = sqlHandler.get_buyer_transactions(account_id)
        return jsonify({'purchases': transactions, 'authenticated': True})
    except Exception as e:
        print(e)
        return jsonify({'authenticated': False})
Exemple #6
0
def get_seller_listings():
    jsonData = request.get_json()
    try:
        jwt_service = JWTService()
        account_id = jwt_service.get_account(jsonData['token'])
        sqlHandler = SqlHandler(mysql)
        transactions = sqlHandler.get_seller_transactions(account_id)
        listings = sqlHandler.get_seller_tickets(account_id)
        # Concatenate the two arrays into one listings array to be consumed by frontend page
        return jsonify({
            'listings': listings + transactions,
            'authenticated': True
        })
    except Exception as e:
        print(e)
        return jsonify({'authenticated': False})
Exemple #7
0
def sendTicketsPDF():
    if 'application/json' in request.headers.environ['CONTENT_TYPE']:
        jsonData = request.get_json()
        jwt_service = JWTService()
        sqlHandler = SqlHandler(mysql)
        try:
            accountID = jwt_service.get_account(jsonData['token'])
            email = sqlHandler.get_user_email(accountID)

            ticketIds = jsonData['ticketIds']
            outputPDF = pdfworker.getCombinedPDF(ticketIds)
            outputPDFName = "Tickets.pdf"

            thr = threading.Thread(
                target=TTTEmailClient.send_combined_ticket_file,
                args=(email, outputPDF, outputPDFName))
            thr.start()
        except Exception as e:
            print(e)
            return jsonify({'success': False})
    else:
        return requestNotSupported()
    return jsonify({'success': True})