Beispiel #1
0
    def __init__(self, *args, **kwargs):
        super(PrizeAcceptanceForm, self).__init__(*args, **kwargs)
        self.accepted = None

        if 'data' in kwargs and kwargs['data'] != None:
            if 'accept' in kwargs['data']:
                self.accepted = True
            elif 'deny' in kwargs['data']:
                self.accepted = False

        self.fields['count'] = forms.ChoiceField(initial=self.instance.pendingcount, choices=list(map(lambda x: (x, x), range(1, self.instance.pendingcount + 1))), label='Count',
                                                 help_text='You were selected to win more than one copy of this prize, please select how many you would like to take, or press Deny All if you do not want any of them.')
        if self.instance.pendingcount == 1:
            self.fields['count'].widget = forms.HiddenInput()
        self.fields['total'] = forms.IntegerField(initial=self.instance.pendingcount, validators=[
                                                  positive], widget=forms.HiddenInput())
        self.fields['comments'] = forms.CharField(max_length=512, label='Notes', required=False,
                                                  help_text="Please put any additional notes here (such as if you have the option of customizing your prize before it is shipped, or additional delivery information).", widget=forms.Textarea(attrs=dict(cols=40, rows=2)))
Beispiel #2
0
 def __init__(self, model, objects, *args, **kwargs):
     super(MergeObjectsForm, self).__init__(*args, **kwargs)
     self.model = model
     self.choices = []
     for objId in objects:
         self.choices.append(
             (objId, unicode(self.model.objects.get(id=objId))))
     self.fields['root'] = forms.ChoiceField(
         choices=self.choices, required=True)
     self.fields['objects'] = forms.CharField(initial=','.join(
         [str(i) for i in objects]), widget=forms.HiddenInput())
Beispiel #3
0
 def __init__(self, *args, **kwargs):
     super(PrizeShippingForm, self).__init__(*args, **kwargs)
     self.saved = False
     self.instance = kwargs['instance']
     self.fields[
         'shippingstate'].label = 'Shipped yet?' if self.instance.prize.requiresshipping else 'Sent yet?'
     self.fields[
         'shippingcost'].help_text = 'Fill in the amount you would like to be reimbursed for (leave blank for zero)'
     self.fields[
         'shipping_receipt_url'].help_text = 'Please post a url with an image of the shipping receipt here. If you are uncomfortable uploading this image to a web page, you can send the image to {0} instead'.format(prizemail.get_event_default_sender_email(self.instance.prize.event))
     self.fields[
         'couriername'].help_text = '(e.g. FedEx, DHL, ...) Optional, but nice if you have it'
     self.fields[
         'trackingnumber'].help_text = 'Optional, and you must also supply the courier name if you want to provide a tracking number'
     self.fields['shippingnotes'].label = 'Additional Notes'
     self.fields[
         'shippingnotes'].help_text = 'Any extra information you would like to relay to the recipient'
     self.fields['shippingnotes'].widget = forms.Textarea(
         attrs=dict(cols=40, rows=2))
     if not self.instance.prize.requiresshipping:
         self.fields['shippingcost'].widget = forms.HiddenInput()
         self.fields['shipping_receipt_url'].widget = forms.HiddenInput()
         self.fields['couriername'].widget = forms.HiddenInput()
         self.fields['trackingnumber'].widget = forms.HiddenInput()