예제 #1
0
파일: forms.py 프로젝트: 34/T
    def __init__(self, *args, **kwargs):
        super(ShippingMethodForm, self).__init__(*args, **kwargs)

        shipping_choices_ = shipping_choices()
        
        if len(shipping_choices_) == 1:
            self.fields['shippingmethod'].widget = forms.HiddenInput(attrs={'value' : shipping_choices_[0][0]})
        else:
            self.fields['shippingmethod'].widget = forms.RadioSelect(attrs={'value' : shipping_choices_[0][0]})
        self.fields['shippingmethod'].choices = shipping_choices_
예제 #2
0
파일: forms.py 프로젝트: 34/T
 def __init__(self, *args, **kwargs):
     super(PaymentShippingAddressBookForm, self).__init__(*args, **kwargs)
     
     if not self.cart:
         request = threadlocals.get_current_request()
         self.cart = Cart.objects.from_request(request)
     
     shipping_choices_ = shipping_choices()
     if len(shipping_choices_) == 1:
         self.fields['shippingmethod'].widget = forms.HiddenInput(attrs={'value' : shipping_choices_[0][0]})
     else:
         self.fields['shippingmethod'].widget = forms.RadioSelect(attrs={'value' : shipping_choices_[0][0]})
     self.fields['shippingmethod'].choices = shipping_choices_
     
     self.fields['discount'] = forms.CharField(max_length=30, required=False)
     if config_value('PAYMENT', 'USE_DISCOUNTS'):
         if not self.fields['discount'].initial:
             sale = _find_sale(self.cart)
             if sale:
                 self.fields['discount'].initial = sale.code
     else:
         self.fields['discount'].widget = forms.HiddenInput()
         
     form_init.send(PaymentContactInfoForm, form=self)