hydraveil-gui/gui/v2/actions/ticket_actions.py

34 lines
No EOL
1.3 KiB
Python

# core
from core.services.payment_phase.payment_state import OverallPaymentCycle, PaymentData, TicketPaymentData
from core.models.enum_models import PaymentType
from core.controllers.tickets.UseTicketController import get_unused_tickets
from core.models.Result import Result, ResultError
# from core.controllers.ProfileController import ProfileController
# gui
from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool
from gui.v2.infrastructure.take_plumbing_action import take_action
from gui.v2.infrastructure.setup_observers import connection_observer, ticket_observer
def get_ticket_data() -> Result:
"""This is running in the background ALREADY. Get a list of unused tickets from core"""
ticket_results = get_unused_tickets()
valid = ticket_results.get('valid')
if not valid:
message = ticket_results.get('message')
if not message:
message = "Error gathering ticket data"
Result(valid=False, error_type=ResultError.MISSING_FILE, message=message)
raw_tickets = ticket_results.get('data')
print(f"raw_tickets is {raw_tickets}")
if not raw_tickets:
Result(valid=True, data=raw_tickets, message="No tickets available.")
formatted_data = [(f"Ticket #{t}", t) for t in raw_tickets]
print(f"formatted_data is {formatted_data}")
return Result(valid=True, data=formatted_data)