Example #1
0
    def __init__(self, request, step, data=None, initial=None, errors=None):
        OrderForm.__init__(self, request, step, data, initial, errors)

        is_first_step = step == checkout.CHECKOUT_STEP_FIRST
        is_last_step = step == checkout.CHECKOUT_STEP_LAST
        is_payment_step = step == checkout.CHECKOUT_STEP_PAYMENT

        # Get list of country names
        countries = make_choices(get_country_names_list())
    
        if settings.SHOP_CHECKOUT_STEPS_SPLIT:
            if is_first_step:
                # Change country widgets to a Select widget
                self.fields["billing_detail_country"].widget = forms.Select(choices=countries)
                self.fields["billing_detail_country"].initial = settings.SHOP_DEFAULT_COUNTRY
                self.fields["shipping_detail_country"].widget = forms.Select(choices=countries)
                self.fields["shipping_detail_country"].initial= settings.SHOP_DEFAULT_COUNTRY
            if is_payment_step:
                # Make card number and cvv fields use the data encrypted widget
                self.fields["card_number"].widget = DataEncryptedTextInput()
                self.fields["card_ccv"].widget = DataEncryptedPasswordInput()
        else:
            # Change country widgets to a Select widget
            self.fields["billing_detail_country"].widget = forms.Select(choices=countries)
            self.fields["billing_detail_country"].initial = settings.SHOP_DEFAULT_COUNTRY            
            self.fields["shipping_detail_country"].widget = forms.Select(choices=countries)
            self.fields["shipping_detail_country"].initial= settings.SHOP_DEFAULT_COUNTRY
            if settings.SHOP_PAYMENT_STEP_ENABLED:
                # Make card number and cvv fields use the data encrypted widget
                self.fields["card_number"].widget = DataEncryptedTextInput()
                self.fields["card_ccv"].widget = DataEncryptedPasswordInput()
Example #2
0
    def __init__(self, request, step, data=None, initial=None, errors=None):
        OrderForm.__init__(self, request, step, data, initial, errors)

        is_first_step = step == checkout.CHECKOUT_STEP_FIRST
        is_last_step = step == checkout.CHECKOUT_STEP_LAST
        is_payment_step = step == checkout.CHECKOUT_STEP_PAYMENT

        # Get list of country names
        countries = make_choices(get_country_names_list())

        if settings.SHOP_CHECKOUT_STEPS_SPLIT:
            if is_first_step:
                # Change country widgets to a Select widget
                self.fields["billing_detail_country"].widget = forms.Select(
                    choices=countries)
                self.fields[
                    "billing_detail_country"].initial = settings.SHOP_DEFAULT_COUNTRY
                self.fields["shipping_detail_country"].widget = forms.Select(
                    choices=countries)
                self.fields[
                    "shipping_detail_country"].initial = settings.SHOP_DEFAULT_COUNTRY
            if is_payment_step:
                # Make card number and cvv fields use the data encrypted widget
                self.fields["card_number"].widget = DataEncryptedTextInput()
                self.fields["card_ccv"].widget = DataEncryptedPasswordInput()
        else:
            # Change country widgets to a Select widget
            self.fields["billing_detail_country"].widget = forms.Select(
                choices=countries)
            self.fields[
                "billing_detail_country"].initial = settings.SHOP_DEFAULT_COUNTRY
            self.fields["shipping_detail_country"].widget = forms.Select(
                choices=countries)
            self.fields[
                "shipping_detail_country"].initial = settings.SHOP_DEFAULT_COUNTRY
            if settings.SHOP_PAYMENT_STEP_ENABLED:
                # Make card number and cvv fields use the data encrypted widget
                self.fields["card_number"].widget = DataEncryptedTextInput()
                self.fields["card_ccv"].widget = DataEncryptedPasswordInput()
from mezzanine.conf import register_setting
from cartridge_braintree.countries import get_country_names_list

register_setting(
    name="SHOP_DEFAULT_COUNTRY",
    description="Default selected country in the billing/shipping fields",
    editable=True,
    choices=zip(get_country_names_list(), get_country_names_list()),
    default="United States of America"
)

# -----------------------------------------------
# Braintree Client Side Encryption Key
# -----------------------------------------------
register_setting(
    name="BRAINTREE_CLIENT_SIDE_ENCRYPTION_KEY",
    editable=False,
    default="",
)

# -----------------------------------------------
# Make sure we can access the client side encryption key from within templates
# -----------------------------------------------
register_setting(
    name="TEMPLATE_ACCESSIBLE_SETTINGS",
    append=True,
    default=("BRAINTREE_CLIENT_SIDE_ENCRYPTION_KEY",),
)
Example #4
0
from mezzanine.conf import register_setting
from cartridge_braintree.countries import get_country_names_list

register_setting(
    name="SHOP_DEFAULT_COUNTRY",
    description="Default selected country in the billing/shipping fields",
    editable=True,
    choices=zip(get_country_names_list(), get_country_names_list()),
    default="United States of America")

# -----------------------------------------------
# Braintree Client Side Encryption Key
# -----------------------------------------------
register_setting(
    name="BRAINTREE_CLIENT_SIDE_ENCRYPTION_KEY",
    editable=False,
    default="",
)

# -----------------------------------------------
# Make sure we can access the client side encryption key from within templates
# -----------------------------------------------
register_setting(
    name="TEMPLATE_ACCESSIBLE_SETTINGS",
    append=True,
    default=("BRAINTREE_CLIENT_SIDE_ENCRYPTION_KEY", ),
)