Exemplo n.º 1
0
    def page_logic(self):
        first_name = self.get_request_value_normalized("ncc_firstname", must=True, label="First Name")
        last_name = self.get_request_value_normalized("ncc_lastname", must=True, label="Last Name")
        swim_event = self.get_request_value_normalized("ncc_swim_event", must=True, label="Swim Event")
        email = self.get_request_value_normalized("ncc_emailaddr")
        phone = self.get_request_value_normalized("ncc_phone")
        agree = self.get_request_value_normalized("ncc_agreement")
        transaction = str(uuid.uuid4())
        gender = self.get_request_value_normalized("ncc_gender", must=True, label="Gender")
        age = self.get_request_value_normalized("ncc_age", must=True, label="Age")
        shirt_size = self.get_request_value_normalized("ncc_shirtsize", must=True, label="Shirt Size")

        if not agree:
            raise NamoException("You must read and agree to the release form.")

        if gender not in ["male", "female"]:
            raise NamoException("Invalid gender")
        age = verify_age(age)
        if swim_event not in get_swim_events():
            raise NamoException("Invalid event name.")
        if agree != "agree":
            raise NamoException("You must agree to the wavier in order to participate in the event.")
        swim_data = get_swim_order_lookup(transaction)
        if swim_data:
            logging.error("The transaction ID already exists, what to do?")
            raise NamoException("The transaction ID already exists, what to do?")

        description = "Namolokama Swim Race.  Course %s." % (swim_event)
        event_name = swim_event

        price = get_swim_event_price(swim_event)
        swim_data = SwimmerData(
            description=description,
            event_name=event_name,
            phone=phone,
            swim_event=swim_event,
            firstname=first_name,
            lastname=last_name,
            gender=gender,
            age=age,
            agreed=True,
            emailaddress=email,
            transaction_id=transaction,
            price=price,
            shirt_size=shirt_size,
        )
        swim_data.put()

        html = make_gco_request(swim_data)
        button_value = html()

        button_value = mark_safe(button_value)
        logging.error("html button | %s" % (button_value))

        self.template_values["button"] = button_value
        self.write_page("checkout.html")
Exemplo n.º 2
0
    def page_logic(self):
        first_name = self.get_request_value_normalized('ncc_firstname', must=True, label="First Name")
        last_name = self.get_request_value_normalized('ncc_lastname', must=True, label="Last Name")
        boat_number = self.get_request_value_normalized('ncc_boat_number', must=True, label="Boat Number")
        boat_type = self.get_request_value_normalized('ncc_boat_type', must=True, label="Boat Type")
        email = self.get_request_value_normalized('ncc_emailaddr')
        agree = self.get_request_value_normalized('ncc_agreement')
        transaction = str(uuid.uuid4())
        gender = self.get_request_value_normalized('ncc_gender', must=True, label="Gender")
        age = self.get_request_value_normalized('ncc_age', must=True, label="Age")

        second_first_name = self.get_request_value_normalized('ncc_second_firstname', must=False)
        second_last_name = self.get_request_value_normalized('ncc_second_lastname', must=False)
        second_age = self.get_request_value_normalized('ncc_second_age', must=False)
        second_gender = self.get_request_value_normalized('ncc_second_gender', must=False)

        if not agree:
            raise NamoException("You must read and agree to the release form.")

        if gender not in ["male", "female"]:
            raise NamoException("Invalid gender")
        age = verify_age(age)

        if boat_type not in get_boat_types():
            raise NamoException("Invalid boat type")
        if agree != "agree":
            raise NamoException("You must agree to the wavier in order to participate in the event.")
        rd = get_race_order_lookup(transaction)
        if rd:
            logging.error("The transaction ID already exists, what to do?")
            raise NamoException("The transaction ID already exists, what to do?")

        description = "Namolokama canoe race.  Watercraft %s" % (boat_type)
        event_name = boat_type
        price = get_event_price(boat_type)
        rd = RacersData(firstname=first_name, lastname=last_name, boatnumber=boat_number, boattype=boat_type,
                        agreed=True,transaction_id=transaction, price=price, emailaddress=email,
                        age=age, gender=gender, description=description, event_name=event_name)

        if boat_type == 'oc2':
            if not second_first_name:
                raise NamoException("For the OC2 event you must register both paddlers")
            if not second_last_name:
                raise NamoException("For the OC2 event you must register both paddlers")
            if not second_age:
                raise NamoException("For the OC2 event you must register both paddler's age")
            if not second_gender:
                raise NamoException("For the OC2 event you must register both paddler's gender")
            second_age = verify_age(second_age)

            rd.second_paddler_firstname = second_first_name
            rd.second_paddler_lastname = second_last_name
            rd.second_paddler_age = second_age
            rd.second_paddler_gender = second_gender

        rd.put()

        html = make_gco_request(rd)

        button_value = html()

        logging.error("html button | %s" % (button_value))

        self.template_values['button'] = button_value
        self.write_page('checkout.html')