class PaymentMethodForm(ProxyContactForm): paymentmethod = forms.ChoiceField(label=_('Payment method'), choices=labelled_gateway_choices(), widget=forms.RadioSelect, required=True) def __init__(self, cart=None, order=None, *args, **kwargs): super(PaymentMethodForm, self).__init__(*args, **kwargs) self.cart = cart # Send a signal to perform additional filtering of available payment methods. # Receivers have cart/order passed in variables to check the contents and modify methods # list if neccessary. payment_choices = labelled_gateway_choices() signals.payment_methods_query.send(PaymentMethodForm, methods=payment_choices, cart=cart, order=order, contact=self._contact) if self.fields['paymentmethod'].initial == None: self.fields['paymentmethod'].initial = payment_choices[0][0] if len(payment_choices) == 1: self.fields['paymentmethod'].widget = forms.HiddenInput() else: self.fields['paymentmethod'].widget = forms.RadioSelect() self.fields['paymentmethod'].choices = payment_choices def clean(self): # allow additional validation form_validate.send(PaymentMethodForm, form=self) return self.cleaned_data
def __init__(self, *args, **kwargs): super(PaymentMethodForm, self).__init__(*args, **kwargs) # Send a signal to perform additional filtering of available payment methods. # Receivers have cart/order passed in variables to check the contents and modify methods # list if neccessary. payment_choices = labelled_gateway_choices() #signals.payment_methods_query.send( # PaymentMethodForm, # methods=payment_choices, # cart=cart, # order=order, # contact=self._contact # ) if len(payment_choices) == 1: self.fields['paymentmethod'].widget = forms.HiddenInput(attrs={'value' : payment_choices[0][0]}) else: self.fields['paymentmethod'].widget = forms.RadioSelect(attrs={'value' : payment_choices[0][0]}) self.fields['paymentmethod'].choices = payment_choices
def __init__(self, cart=None, order=None, *args, **kwargs): super(PaymentMethodForm, self).__init__(*args, **kwargs) self.cart = cart # Send a signal to perform additional filtering of available payment methods. # Receivers have cart/order passed in variables to check the contents and modify methods # list if neccessary. payment_choices = labelled_gateway_choices() signals.payment_methods_query.send(PaymentMethodForm, methods=payment_choices, cart=cart, order=order, contact=self._contact) if self.fields['paymentmethod'].initial == None: self.fields['paymentmethod'].initial = payment_choices[0][0] if len(payment_choices) == 1: self.fields['paymentmethod'].widget = forms.HiddenInput() else: self.fields['paymentmethod'].widget = forms.RadioSelect() self.fields['paymentmethod'].choices = payment_choices
def __init__(self, cart=None, order=None, *args, **kwargs): super(PaymentMethodForm, self).__init__(*args, **kwargs) self.cart = cart # Send a signal to perform additional filtering of available payment methods. # Receivers have cart/order passed in variables to check the contents and modify methods # list if neccessary. payment_choices = labelled_gateway_choices() signals.payment_methods_query.send( PaymentMethodForm, methods=payment_choices, cart=cart, order=order, contact=self._contact ) if self.fields['paymentmethod'].initial == None: self.fields['paymentmethod'].initial = payment_choices[0][0] if len(payment_choices) == 1: self.fields['paymentmethod'].widget = forms.HiddenInput() else: self.fields['paymentmethod'].widget = forms.RadioSelect() self.fields['paymentmethod'].choices = payment_choices
def __init__(self, *args, **kwargs): choices = kwargs.pop("choices", "__DYNAMIC__") if choices == "__DYNAMIC__": kwargs['choices'] = labelled_gateway_choices() super(PaymentChoiceCharField, self).__init__(*args, **kwargs)
def __init__(self, choices="__DYNAMIC__", *args, **kwargs): if choices == "__DYNAMIC__": kwargs["choices"] = labelled_gateway_choices() super(PaymentChoiceCharField, self).__init__(*args, **kwargs)
def __init__(self, choices="__DYNAMIC__", *args, **kwargs): if choices == "__DYNAMIC__": kwargs['choices'] = labelled_gateway_choices() super(PaymentChoiceCharField, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): super(OrderPaymentBaseAdminForm, self).__init__(*args, **kwargs) self.fields['payment'].choices = [('', '--------') ] + labelled_gateway_choices()