예제 #1
0
def load_tickets(departures):
    with open("data/tickets") as f:
        content = f.readlines()

    tickets = []
    for line in content:
        ticket_data = line.strip().split('|')

        departure_pointer = [
            departure for departure in departures
            if departure.id == ticket_data[1]
        ][0]

        ticket = Ticket(
            ticket_data[0],  # ticket_id
            departure_pointer,  # departure_id
            ticket_data[2],  # first_name
            ticket_data[3],  # last_name
            ticket_data[4],  # contact_phone
            ticket_data[5],  # contact_email
            ticket_data[6],  # passport number
            ticket_data[7],  # nationality
            ticket_data[8],  # gender
            ticket_data[9],  # purchase_date
            ticket_data[10],  # seat
            ticket_data[11],  # delete
            ticket_data[12])  # sold_by
        tickets.append(ticket)
    return tickets
예제 #2
0
    def undo_order_method(self):
        if len(self.history_object) != 0:
            last_order = self.history_object[len(self.history_object) -
                                             (self.history_index + 1)]
            self.history_index = self.history_index + 1
            if last_order["order"] == "delete":
                self.set_y_index()
                new_ticket_element = {
                    "id": last_order["obj"].id,
                    "title": last_order["obj"].title_text,
                    "type": last_order["obj"].type_text,
                    "assigned_to": last_order["obj"].assigned_to_text,
                    "status": last_order["obj"].status
                }
                x_pos = 20 + self.get_distance_x_status(0)
                y_pos = 230 + (self.y_index[0] * 150)
                ticket = Ticket(self, last_order["obj"].id,
                                last_order["obj"].title_text,
                                last_order["obj"].type_text,
                                last_order["obj"].assigned_to_text, x_pos,
                                y_pos, last_order["obj"].status)
                self.y_index[0] = self.y_index[0] + 1
                ticket.setGeometry(x_pos, y_pos,
                                   ticket.size().width(),
                                   ticket.size().height())
                self.all_tickets.append(ticket)
                self.config.append(new_ticket_element)

                self.history_object[len(self.history_object) -
                                    1]["order"] = "create"
                self.history_object[len(self.history_object) -
                                    1]["obj"] = ticket

            self.update()
예제 #3
0
def purchase_ticket(departure, first_name, last_name, phone, email):
    global current_ticket_id  #, current_user
    current_ticket_id += 1
    ticket_id = "AA" + f"{current_ticket_id:04d}"  # takes a number and formats it into 4 digits with leading zeroes 2 --> 0002

    current_date_obj = datetime.today().date()
    current_date_str = current_date_obj.strftime("%d-%m-%Y")

    registered_user = None

    # we search whether the user is registered in the system, if yes then we save a reference to him
    for user in users:
        if user.first_name == first_name and user.last_name == last_name and user.email == email:
            registered_user = user
            break

    if registered_user is None:
        ticket = Ticket(
            ticket_id, departure, first_name.capitalize(),
            last_name.capitalize(), phone, email, "", "", "", current_date_str,
            "", "No", globals.current_user.first_name + " " +
            globals.current_user.last_name)
        # "" -> No seat assigned yet. "No" -> not q'd for deletion
    else:  # the user has not been found as registered in the system
        ticket = Ticket(
            ticket_id, departure, user.first_name, user.last_name, user.phone,
            user.email, user.passport_number, user.nationality, user.gender,
            current_date_str, "", "No", globals.current_user.first_name + " " +
            globals.current_user.last_name
        )  # current global user is the seller, we mark his name

    tickets.append(ticket)
    departure.seats_taken += 1
    save_ticket_to_file(ticket)
    save_departures_to_file()

    print("Purchase successful.")
    print_ticket(ticket, "Single")
예제 #4
0
 def make_new_ticket(self, type_element):
     new_id = len(self.config) + 1
     new_ticket_element = {
         "id": new_id,
         "title": "",
         "type": type_element,
         "assigned_to": "",
         "status": 0
     }
     x_pos = 20 + self.get_distance_x_status(0)
     y_pos = 230 + (self.y_index[0] * 150)
     ticket = Ticket(self, new_id, "", type_element, "", x_pos, y_pos, 0)
     self.y_index[0] = self.y_index[0] + 1
     ticket.setGeometry(x_pos, y_pos,
                        ticket.size().width(),
                        ticket.size().height())
     self.all_tickets.append(ticket)
     self.config.append(new_ticket_element)
예제 #5
0
    def append_tickets_to_ui(self):
        for ticket_elements in self.all_tickets:
            ticket_elements.setParent(None)
            self.all_tickets.remove(ticket_elements)

        self.y_index = [0, 0, 0]
        self.all_tickets = []
        for ticket_in_config in self.config:
            x_pos = 20 + self.get_distance_x_status(ticket_in_config["status"])
            y_pos = 230 + (self.y_index[ticket_in_config["status"]] * 150)
            ticket = Ticket(self, ticket_in_config["id"],
                            ticket_in_config["title"],
                            ticket_in_config["type"],
                            ticket_in_config["assigned_to"], x_pos, y_pos,
                            ticket_in_config["status"])
            self.y_index[ticket_in_config["status"]] = self.y_index[
                ticket_in_config["status"]] + 1

            ticket.setGeometry(x_pos, y_pos,
                               ticket.size().width(),
                               ticket.size().height())
            self.all_tickets.append(ticket)

        self.update()
 def toString(self):
     delimiter = " | "
     return Ticket.toString() + delimiter + self.__serviceReqNumber
 def __init__(self, subject, creator, owner,ownerEmail, ownerTeam, service, createdDateTime, resolveDate, serviceRequestNumber, status, typeData):
     Ticket.__init__(self, subject, creator, owner, ownerEmail, ownerTeam, service, createdDateTime, resolveDate, status, typeData)
     self.__serviceReqNumber = serviceRequestNumber
예제 #8
0
 def create_ticket_prueba(self, id_plaza, fecha_deposito, fecha_salida,
                          facturado):
     self.tickets.append(
         Ticket(id_plaza, fecha_deposito, fecha_salida, facturado))
예제 #9
0
 def create_ticket(self, id_plaza, tipo_vehiculo):
     self.tickets.append(Ticket.Ticket(id_plaza, tipo_vehiculo))
예제 #10
0
 def __init__(self, subject, creator, owner, ownerEmail, ownerTeam, service, createdDateTime, resolveDate, incidentNumber,
              status, typeData, firstCall):
     Ticket.__init__(self, subject, creator,owner,ownerEmail,ownerTeam, service, createdDateTime, resolveDate, status, typeData)
     self.__incidentNumber = incidentNumber
     self.__firstCall = firstCall
예제 #11
0
 def toString(self):
     delimiter = " | "
     return Ticket.toString() + delimiter + self.__incidentNumber