Exemple #1
0
class InvoiceSettingsForm(SettingsForm):
    invoice_address_asked = forms.BooleanField(
        label=_("Ask for invoice address"),
        required=False
    )
    invoice_address_required = forms.BooleanField(
        label=_("Require invoice address"),
        required=False
    )
    invoice_address_vatid = forms.BooleanField(
        label=_("Ask for VAT ID"),
        help_text=_("Does only work if an invoice address is asked for. VAT ID is not required."),
        required=False
    )
    invoice_numbers_consecutive = forms.BooleanField(
        label=_("Generate invoices with consecutive numbers"),
        help_text=_("If deactivated, the order code will be used in the invoice number."),
        required=False
    )
    invoice_generate = forms.ChoiceField(
        label=_("Generate invoices"),
        required=False,
        choices=(
            ('False', _('No')),
            ('admin', _('Manually in admin panel')),
            ('user', _('Automatically on user request')),
            ('True', _('Automatically for all created orders'))
        )
    )
    invoice_address_from = forms.CharField(
        widget=forms.Textarea(attrs={'rows': 5}), required=False,
        label=_("Your address"),
        help_text=_("Will be printed as the sender on invoices. Be sure to include relevant details required in "
                    "your jurisdiction (e.g. your VAT ID).")
    )
    invoice_introductory_text = I18nFormField(
        widget=I18nTextarea,
        required=False,
        label=_("Introductory text"),
        help_text=_("Will be printed on every invoice above the invoice rows.")
    )
    invoice_additional_text = I18nFormField(
        widget=I18nTextarea,
        required=False,
        label=_("Additional text"),
        help_text=_("Will be printed on every invoice below the invoice total.")
    )
    invoice_footer_text = I18nFormField(
        widget=I18nTextarea,
        required=False,
        label=_("Footer"),
        help_text=_("Will be printed centered and in a smaller font at the end of every invoice page.")
    )
    invoice_language = forms.ChoiceField(
        widget=forms.Select, required=True,
        label=_("Invoice language"),
        choices=[('__user__', _('The user\'s language'))] + settings.LANGUAGES,
    )
Exemple #2
0
class MailSettingsForm(SettingsForm):
    mail_prefix = forms.CharField(
        label=_("Subject prefix"),
        help_text=_("This will be prepended to the subject of all outgoing emails. This could be a short form of "
                    "your event name."),
        required=False
    )
    mail_from = forms.EmailField(
        label=_("Sender address"),
        help_text=_("Sender address for outgoing e-mails")
    )
    mail_text_order_placed = I18nFormField(
        label=_("Placed order"),
        required=False,
        widget=I18nTextarea,
        help_text=_("Available placeholders: {event}, {total}, {currency}, {date}, {paymentinfo}, {url}")
    )
    mail_text_order_paid = I18nFormField(
        label=_("Paid order"),
        required=False,
        widget=I18nTextarea,
        help_text=_("Available placeholders: {event}, {url}")
    )
    smtp_use_custom = forms.BooleanField(
        label=_("Use custom SMTP server"),
        help_text=_("All mail related to your event will be sent over the smtp server specified by you."),
        required=False
    )
    smtp_host = forms.CharField(
        label=_("Hostname"),
        required=False
    )
    smtp_port = forms.IntegerField(
        label=_("Port"),
        required=False
    )
    smtp_username = forms.CharField(
        label=_("Username"),
        required=False
    )
    smtp_password = forms.CharField(
        label=_("Password"),
        required=False,
        widget=forms.PasswordInput
    )
    smtp_use_tls = forms.BooleanField(
        label=_("Use STARTTLS"),
        help_text=_("Commonly enabled on port 587."),
        required=False
    )
    smtp_use_ssl = forms.BooleanField(
        label=_("Use SSL"),
        help_text=_("Commonly enabled on port 465."),
        required=False
    )
Exemple #3
0
class MailSettingsForm(SettingsForm):
    mail_prefix = forms.CharField(
        label=_("Subject prefix"),
        help_text=_(
            "This will be prepended to the subject of all outgoing emails. This could be a short form of "
            "your event name."),
        required=False)
    mail_from = forms.EmailField(
        label=_("Sender address"),
        help_text=_("Sender address for outgoing e-mails"))
    mail_text_order_placed = I18nFormField(
        label=_("Placed order"),
        required=False,
        widget=I18nTextarea,
        help_text=
        _("Available placeholders: {event}, {total}, {currency}, {date}, {paymentinfo}, {url}"
          ))
    mail_text_order_paid = I18nFormField(
        label=_("Paid order"),
        required=False,
        widget=I18nTextarea,
        help_text=_("Available placeholders: {event}, {url}"))
    mail_text_resend_link = I18nFormField(
        label=_("Resend link"),
        required=False,
        widget=I18nTextarea,
        help_text=_("Available placeholders: {event}, {url}"))
    smtp_use_custom = forms.BooleanField(
        label=_("Use custom SMTP server"),
        help_text=
        _("All mail related to your event will be sent over the smtp server specified by you."
          ),
        required=False)
    smtp_host = forms.CharField(label=_("Hostname"), required=False)
    smtp_port = forms.IntegerField(label=_("Port"), required=False)
    smtp_username = forms.CharField(label=_("Username"), required=False)
    smtp_password = forms.CharField(label=_("Password"),
                                    required=False,
                                    widget=forms.PasswordInput)
    smtp_use_tls = forms.BooleanField(
        label=_("Use STARTTLS"),
        help_text=_("Commonly enabled on port 587."),
        required=False)
    smtp_use_ssl = forms.BooleanField(
        label=_("Use SSL"),
        help_text=_("Commonly enabled on port 465."),
        required=False)

    def clean(self):
        data = self.cleaned_data
        if not data.get('smtp_password') and data.get('smtp_username'):
            # Leave password unchanged if the username is set and the password field is empty.
            # This makes it impossible to set an empty password as long as a username is set, but
            # Python's smtplib does not support password-less schemes anyway.
            data['smtp_password'] = self.initial.get('smtp_password')
Exemple #4
0
 def __init__(self, *args, **kwargs):
     event = kwargs.pop('event')
     super().__init__(*args, **kwargs)
     self.fields['subject'] = I18nFormField(
         widget=I18nTextInput,
         required=True,
         langcodes=event.settings.get('locales'))
     self.fields['message'] = I18nFormField(
         widget=I18nTextarea,
         required=True,
         langcodes=event.settings.get('locales'))
Exemple #5
0
class DisplaySettingsForm(SettingsForm):
    primary_color = forms.CharField(
        label=_("Primary color"),
        required=False,
        validators=[
            RegexValidator(
                regex='^#[0-9a-fA-F]{6}$',
                message=
                _('Please enter the hexadecimal code of a color, e.g. #990000.'
                  ))
        ])
    logo_image = ExtFileField(
        label=_('Logo image'),
        ext_whitelist=(".png", ".jpg", ".svg", ".gif", ".jpeg"),
        required=False,
        help_text=
        _('If you provide a logo image, we will by default not show your events name and date '
          'in the page header. We will show your logo with a maximal height of 120 pixels.'
          ))
    frontpage_text = I18nFormField(label=_("Frontpage text"),
                                   required=False,
                                   widget=I18nTextarea)
    show_variations_expanded = forms.BooleanField(
        label=_("Show variations of a product expanded by default"),
        required=False)
Exemple #6
0
 def settings_form_fields(self):
     form_field = I18nFormField(
         label=_('Bank account details'),
         widget=I18nTextarea,
     )
     return OrderedDict(
         list(super().settings_form_fields.items()) +
         [('bank_details', form_field)])
Exemple #7
0
 def __init__(self, *args, **kwargs):
     event = kwargs.pop('event')
     super().__init__(*args, **kwargs)
     self.fields['subject'] = I18nFormField(
         widget=I18nTextInput,
         required=True,
         langcodes=event.settings.get('locales'))
     self.fields['message'] = I18nFormField(
         widget=I18nTextarea,
         required=True,
         langcodes=event.settings.get('locales'))
     choices = list(Order.STATUS_CHOICE)
     if not event.settings.get('payment_term_expire_automatically',
                               as_type=bool):
         choices.append(('overdue', _('pending with payment overdue')))
     self.fields['sendto'] = forms.MultipleChoiceField(
         label=_("Send to"),
         widget=forms.CheckboxSelectMultiple,
         choices=choices)
Exemple #8
0
    def __init__(self, *args, **kwargs):
        self.obj = GlobalSettingsObject()
        super().__init__(*args, obj=self.obj, **kwargs)

        self.fields = OrderedDict([
            ('footer_text', I18nFormField(
                widget=I18nTextInput,
                required=False,
                label=_("Additional footer text"),
                help_text=_("Will be included as additional text in the footer, site-wide.")
            )),
            ('footer_link', I18nFormField(
                widget=I18nTextInput,
                required=False,
                label=_("Additional footer link"),
                help_text=_("Will be included as the link in the additional footer text.")
            ))
        ])
        responses = register_global_settings.send(self)
        for r, response in responses:
            for key, value in response.items():
                # We need to be this explicit, since OrderedDict.update does not retain ordering
                self.fields[key] = value
Exemple #9
0
class QuestionForm(I18nModelForm):
    question = I18nFormField(label=_("Question"),
                             widget_kwargs={'attrs': {
                                 'rows': 5
                             }},
                             widget=I18nTextarea)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['items'].queryset = self.instance.event.items.all()

    class Meta:
        model = Question
        localized_fields = '__all__'
        fields = ['question', 'type', 'required', 'items']
        widgets = {
            'items': forms.CheckboxSelectMultiple,
        }
Exemple #10
0
class MailSettingsForm(SettingsForm):
    mail_prefix = forms.CharField(
        label=_("Subject prefix"),
        help_text=_("This will be prepended to the subject of all outgoing emails. This could be a short form of "
                    "your event name."),
        required=False
    )
    mail_from = forms.EmailField(
        label=_("Sender address"),
        help_text=_("Sender address for outgoing emails")
    )
    mail_text_order_placed = I18nFormField(
        label=_("Text"),
        required=False,
        widget=I18nTextarea,
        help_text=_("Available placeholders: {event}, {total}, {currency}, {date}, {paymentinfo}, {url}")
    )
    mail_text_order_paid = I18nFormField(
        label=_("Text"),
        required=False,
        widget=I18nTextarea,
        help_text=_("Available placeholders: {event}, {url}")
    )
    mail_text_order_free = I18nFormField(
        label=_("Text"),
        required=False,
        widget=I18nTextarea,
        help_text=_("Available placeholders: {event}, {url}")
    )
    mail_text_order_changed = I18nFormField(
        label=_("Text"),
        required=False,
        widget=I18nTextarea,
        help_text=_("Available placeholders: {event}, {url}")
    )
    mail_text_resend_link = I18nFormField(
        label=_("Text (sent by admin)"),
        required=False,
        widget=I18nTextarea,
        help_text=_("Available placeholders: {event}, {url}")
    )
    mail_text_resend_all_links = I18nFormField(
        label=_("Text (requested by user)"),
        required=False,
        widget=I18nTextarea,
        help_text=_("Available placeholders: {event}, {orders}")
    )
    mail_days_order_expire_warning = forms.IntegerField(
        label=_("Number of days"),
        required=False,
        min_value=0,
        help_text=_("This email will be sent out this many days before the order expires. If the "
                    "value is 0, the mail will never be sent.")
    )
    mail_text_order_expire_warning = I18nFormField(
        label=_("Text"),
        required=False,
        widget=I18nTextarea,
        help_text=_("Available placeholders: {event}, {url}, {expire_date}")
    )
    smtp_use_custom = forms.BooleanField(
        label=_("Use custom SMTP server"),
        help_text=_("All mail related to your event will be sent over the smtp server specified by you."),
        required=False
    )
    smtp_host = forms.CharField(
        label=_("Hostname"),
        required=False
    )
    smtp_port = forms.IntegerField(
        label=_("Port"),
        required=False
    )
    smtp_username = forms.CharField(
        label=_("Username"),
        required=False
    )
    smtp_password = forms.CharField(
        label=_("Password"),
        required=False,
        widget=forms.PasswordInput(attrs={
            'autocomplete': 'new-password'  # see https://bugs.chromium.org/p/chromium/issues/detail?id=370363#c7
        }),
    )
    smtp_use_tls = forms.BooleanField(
        label=_("Use STARTTLS"),
        help_text=_("Commonly enabled on port 587."),
        required=False
    )
    smtp_use_ssl = forms.BooleanField(
        label=_("Use SSL"),
        help_text=_("Commonly enabled on port 465."),
        required=False
    )

    def clean(self):
        data = self.cleaned_data
        if not data.get('smtp_password') and data.get('smtp_username'):
            # Leave password unchanged if the username is set and the password field is empty.
            # This makes it impossible to set an empty password as long as a username is set, but
            # Python's smtplib does not support password-less schemes anyway.
            data['smtp_password'] = self.initial.get('smtp_password')

        if data.get('smtp_use_tls') and data.get('smtp_use_ssl'):
            raise ValidationError(_('You can activate either SSL or STARTTLS security, but not both at the same time.'))
Exemple #11
0
    def settings_form_fields(self) -> dict:
        """
        When the event's administrator visits the event configuration
        page, this method is called to return the configuration fields available.

        It should therefore return a dictionary where the keys should be (unprefixed)
        settings keys and the values should be corresponding Django form fields.

        The default implementation returns the appropriate fields for the ``_enabled``,
        ``_fee_abs`` and ``_fee_percent`` settings mentioned above.

        We suggest that you return an ``OrderedDict`` object instead of a dictionary
        and make use of the default implementation. Your implementation could look
        like this::

            @property
            def settings_form_fields(self):
                return OrderedDict(
                    list(super().settings_form_fields.items()) + [
                        ('bank_details',
                         forms.CharField(
                             widget=forms.Textarea,
                             label=_('Bank account details'),
                             required=False
                         ))
                    ]
                )

        .. WARNING:: It is highly discouraged to alter the ``_enabled`` field of the default
                     implementation.
        """
        return OrderedDict([
            ('_enabled',
             forms.BooleanField(
                 label=_('Enable payment method'),
                 required=False,
             )),
            ('_fee_abs',
             forms.DecimalField(label=_('Additional fee'),
                                help_text=_('Absolute value'),
                                required=False)),
            ('_fee_percent',
             forms.DecimalField(label=_('Additional fee'),
                                help_text=_('Percentage'),
                                required=False)),
            ('_fee_reverse_calc',
             forms.BooleanField(
                 label=_(
                     'Calculate the fee from the total value including the fee.'
                 ),
                 help_text=
                 _('We recommend you to enable this if you want your users to pay the payment fees of your '
                   'payment provider. <a href="/control/help/payment/fee_reverse" target="_blank">Click here '
                   'for detailled information on what this does.</a> Don\'t forget to set the correct fees '
                   'above!'),
                 required=False)),
            ('_invoice_text',
             I18nFormField(
                 label=_('Text on invoices'),
                 help_text=
                 _('Will be printed just below the payment figures and above the closing text on invoices.'
                   ),
                 required=False,
                 widget=I18nTextarea,
             )),
        ])