def __init__(self, event=None, *args, **kwargs): super(DonationEntryForm, self).__init__(*args, **kwargs) minDonationAmount = event.minimumdonation if event != None else Decimal( "1.00") self.fields['amount'] = forms.DecimalField(decimal_places=2, min_value=minDonationAmount, max_value=Decimal("100000"), label="Donation Amount (min ${0})".format( minDonationAmount), widget=tracker.widgets.NumberInput(attrs={'id': 'iDonationAmount', 'min': str(minDonationAmount), 'step': '0.01'}), required=True) self.fields['comment'] = forms.CharField( widget=forms.Textarea, required=False) self.fields['requestedvisibility'] = forms.ChoiceField( initial='ALIAS', choices=models.Donation._meta.get_field('requestedvisibility').choices, label='Name Visibility') self.fields['requestedalias'] = forms.CharField( max_length=32, label='Preferred Alias', required=False) self.fields['requestedemail'] = forms.EmailField( max_length=128, label='Preferred Email', required=False) self.fields['requestedsolicitemail'] = forms.ChoiceField( initial='CURR', choices=models.Donation._meta.get_field('requestedsolicitemail').choices, label='Charity Email Opt In')
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())
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)))
class PrizeSearchForm(forms.Form): feed = forms.ChoiceField(required=False, initial='upcomming', choices=( ('all', 'All'), ('unwon', 'Not Drawn'), ('won', 'Drawn'), ('current', 'Current'), ('future', 'Future')), label='Type') q = forms.CharField(required=False, initial=None, max_length=255, label='Search')
class RunSearchForm(forms.Form): feed = forms.ChoiceField(required=False, initial='current', choices=( ('all', 'All'), ('current', 'Current'), ('future', 'Future')), label='Type') q = forms.CharField(required=False, initial=None, max_length=255, label='Search')
class DonationSearchForm(forms.Form): feed = forms.ChoiceField(required=False, initial='recent', choices=( ('all', 'All'), ('recent', 'Recent')), label='Filter') q = forms.CharField(required=False, initial=None, max_length=255, label='Search')