Exemple #1
0
    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, prizewinners, *args, **kwargs):
   super(AutomailPrizeWinnersForm, self).__init__(*args, **kwargs)
   self.fields['fromaddress'] = forms.EmailField(max_length=256, initial=settings.EMAIL_HOST_USER, 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(DrawPrizeWinnersForm, self).__init__(*args, **kwargs)
   self.choices = []
   for prize in prizes:
     self.choices.append((prize.id, mark_safe(format_html(u'<a href="{0}">{1}</a>', viewutil.admin_url(prize), prize))))
   self.fields['prizes'] = forms.TypedMultipleChoiceField(choices=self.choices, initial=[prize.id for prize in prizes], coerce=lambda x: int(x), label='Prizes', empty_value='', widget=forms.widgets.CheckboxSelectMultiple)
   self.fields['seed'] = forms.IntegerField(required=False, label='Random Seed', help_text="Completely optional, if you don't know what this is, don't worry about it")
Exemple #4
0
 def __init__(self, prizes, *args, **kwargs):
     super(DrawPrizeWinnersForm, self).__init__(*args, **kwargs)
     self.choices = []
     for prize in prizes:
         self.choices.append((prize.id, mark_safe(format_html(
             u'<a href="{0}">{1}</a>', viewutil.admin_url(prize), prize))))
     self.fields['prizes'] = forms.TypedMultipleChoiceField(choices=self.choices, initial=[prize.id for prize in prizes], coerce=lambda x: int(
         x), label='Prizes', empty_value='', widget=forms.widgets.CheckboxSelectMultiple)
     self.fields['seed'] = forms.IntegerField(
         required=False, label='Random Seed', help_text="Completely optional, if you don't know what this is, don't worry about it")
Exemple #5
0
    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)
Exemple #6
0
 def parent_(self, obj):
   targetObject = None
   if obj.parent:
     targetObject = obj.parent
   elif obj.speedrun:
     targetObject = obj.speedrun
   elif obj.event:
     targetObject = obj.event
   if targetObject:
     return mark_safe('<a href={0}>{1}</a>'.format(unicode(viewutil.admin_url(targetObject)), targetObject))
   else:
     return u'<None>'
Exemple #7
0
 def parent_(self, obj):
     targetObject = None
     if obj.parent:
         targetObject = obj.parent
     elif obj.speedrun:
         targetObject = obj.speedrun
     elif obj.event:
         targetObject = obj.event
     if targetObject:
         return mark_safe('<a href={0}>{1}</a>'.format(
             str(viewutil.admin_url(targetObject)), targetObject))
     else:
         return '<None>'
Exemple #8
0
 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)
Exemple #9
0
 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 admin_url(obj):
    return viewutil.admin_url(obj)
def admin_url(obj):
  return viewutil.admin_url(obj)