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()
def __init__(self, prizewinners, *args, **kwargs): super(AutomailPrizeWinnersForm, self).__init__(*args, **kwargs) event = prizewinners[0].prize.event if len(prizewinners) > 0 else None self.fields['fromaddress'] = forms.EmailField( max_length=256, initial=prizemail.get_event_default_sender_email(event), required=True, label='From Address', help_text= 'Specify the e-mail you would like to identify as the sender', ) self.fields['replyaddress'] = forms.EmailField( max_length=256, required=False, label='Reply Address', help_text='If left blank this will be the same as the from address', ) self.fields['emailtemplate'] = forms.ModelChoiceField( queryset=post_office.models.EmailTemplate.objects.all(), initial=event.prizewinneremailtemplate if event else None, empty_label='Pick a template...', required=True, label='Email Template', help_text= 'Select an email template to use. Can be overridden by the prize itself.', ) self.fields['acceptdeadline'] = forms.DateField( initial=timezone.now() + datetime.timedelta(weeks=2)) self.choices = [] for prizewinner in prizewinners: winner = prizewinner.winner prize = prizewinner.prize self.choices.append(( prizewinner.id, mark_safe( format_html( '<a href="{0}">{1}</a>: <a href="{2}">{3}</a> <a href="{4}">Preview</a>', viewutil.admin_url(prize), prize, viewutil.admin_url(winner), winner, reverse( 'admin:preview_prize_winner_mail', args=(prizewinner.id, ), ), )), )) self.fields['prizewinners'] = forms.TypedMultipleChoiceField( choices=self.choices, initial=[prizewinner.id for prizewinner in prizewinners], coerce=lambda x: int(x), label='Prize Winners', empty_value='', widget=forms.widgets.CheckboxSelectMultiple, )
def __init__(self, prizes, *args, **kwargs): super(AutomailPrizeContributorsForm, self).__init__(*args, **kwargs) self.choices = [] prizes = filter(lambda prize: prize.handler, prizes) event = prizes[0].event if len(prizes) > 0 else None for prize in prizes: self.choices.append((prize.id, mark_safe(format_html(u'<a href="{0}">{1}</a> State: {2} (<a href="mailto:{3}">{3}</a>)', viewutil.admin_url(prize), prize, prize.get_state_display(), prize.handler.email)))) self.fields['fromaddress'] = forms.EmailField(max_length=256, initial=prizemail.get_event_default_sender_email(event), required=True, label='From Address', help_text='Specify the e-mail you would like to identify as the sender') self.fields['replyaddress'] = forms.EmailField(max_length=256, required=False, label='Reply Address', help_text="If left blank this will be the same as the from address") self.fields['emailtemplate'] = forms.ModelChoiceField(queryset=post_office.models.EmailTemplate.objects.all(), empty_label="Pick a template...", required=True, label='Email Template', help_text="Select an email template to use.") self.fields['prizes'] = forms.TypedMultipleChoiceField(choices=self.choices, initial=[prize.id for prize in prizes], label='Prizes', empty_value='', widget=forms.widgets.CheckboxSelectMultiple)
def __init__(self, prizewinners, *args, **kwargs): super(AutomailPrizeShippingNotifyForm, self).__init__(*args, **kwargs) event = prizewinners[0].prize.event if len(prizewinners) > 0 else None self.fields['fromaddress'] = forms.EmailField(max_length=256, initial=prizemail.get_event_default_sender_email(event), required=True, label='From Address', help_text='Specify the e-mail you would like to identify as the sender') self.fields['replyaddress'] = forms.EmailField(max_length=256, required=False, label='Reply Address', help_text="If left blank this will be the same as the from address") self.fields['emailtemplate'] = forms.ModelChoiceField(queryset=post_office.models.EmailTemplate.objects.all(), initial=None, empty_label="Pick a template...", required=True, label='Email Template', help_text="Select an email template to use.") self.choices = [] for prizewinner in prizewinners: winner = prizewinner.winner prize = prizewinner.prize self.choices.append((prizewinner.id, mark_safe(format_html(u'<a href="{0}">{1}</a>: <a href="{2}">{3}</a>', viewutil.admin_url(prize), prize, viewutil.admin_url(winner), winner)))) self.fields['prizewinners'] = forms.TypedMultipleChoiceField(choices=self.choices, initial=[prizewinner.id for prizewinner in prizewinners], coerce=lambda x: int(x), label='Prize Winners', empty_value='', widget=forms.widgets.CheckboxSelectMultiple)
def __init__(self, prizes, *args, **kwargs): super(AutomailPrizeContributorsForm, self).__init__(*args, **kwargs) self.choices = [] prizes = filter(lambda prize: prize.handler, prizes) event = prizes[0].event if len(prizes) > 0 else None for prize in prizes: self.choices.append((prize.id, mark_safe(format_html( u'<a href="{0}">{1}</a> State: {2} (<a href="mailto:{3}">{3}</a>)', viewutil.admin_url(prize), prize, prize.get_state_display(), prize.handler.email)))) self.fields['fromaddress'] = forms.EmailField(max_length=256, initial=prizemail.get_event_default_sender_email( event), required=True, label='From Address', help_text='Specify the e-mail you would like to identify as the sender') self.fields['replyaddress'] = forms.EmailField( max_length=256, required=False, label='Reply Address', help_text="If left blank this will be the same as the from address") self.fields['emailtemplate'] = forms.ModelChoiceField(queryset=post_office.models.EmailTemplate.objects.all( ), empty_label="Pick a template...", required=True, label='Email Template', help_text="Select an email template to use.") self.fields['prizes'] = forms.TypedMultipleChoiceField(choices=self.choices, initial=[ prize.id for prize in prizes], label='Prizes', empty_value='', widget=forms.widgets.CheckboxSelectMultiple)
def __init__(self, prizewinners, *args, **kwargs): super(AutomailPrizeShippingNotifyForm, self).__init__(*args, **kwargs) event = prizewinners[0].prize.event if len(prizewinners) > 0 else None self.fields['fromaddress'] = forms.EmailField(max_length=256, initial=prizemail.get_event_default_sender_email( event), required=True, label='From Address', help_text='Specify the e-mail you would like to identify as the sender') self.fields['replyaddress'] = forms.EmailField( max_length=256, required=False, label='Reply Address', help_text="If left blank this will be the same as the from address") self.fields['emailtemplate'] = forms.ModelChoiceField(queryset=post_office.models.EmailTemplate.objects.all( ), initial=None, empty_label="Pick a template...", required=True, label='Email Template', help_text="Select an email template to use.") self.choices = [] for prizewinner in prizewinners: winner = prizewinner.winner prize = prizewinner.prize self.choices.append((prizewinner.id, mark_safe(format_html(u'<a href="{0}">{1}</a>: <a href="{2}">{3}</a>', viewutil.admin_url(prize), prize, viewutil.admin_url(winner), winner)))) self.fields['prizewinners'] = forms.TypedMultipleChoiceField(choices=self.choices, initial=[prizewinner.id for prizewinner in prizewinners], coerce=lambda x: int( x), label='Prize Winners', empty_value='', widget=forms.widgets.CheckboxSelectMultiple)
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()