Example #1
0
class SubEventBulkForm(SubEventForm):
    time_from = forms.TimeField(
        label=_('Event start time'),
        widget=forms.TimeInput(attrs={'class': 'timepickerfield'}))
    time_to = forms.TimeField(
        label=_('Event end time'),
        widget=forms.TimeInput(attrs={'class': 'timepickerfield'}),
        required=False)
    time_admission = forms.TimeField(
        label=_('Admission time'),
        widget=forms.TimeInput(attrs={'class': 'timepickerfield'}),
        required=False)
    rel_presale_start = RelativeDateTimeField(
        label=_('Start of presale'),
        help_text=_('Optional. No products will be sold before this date.'),
        required=False,
        limit_choices=('date_from', 'date_to'),
    )
    rel_presale_end = RelativeDateTimeField(
        label=_('End of presale'),
        help_text=_(
            'Optional. No products will be sold after this date. If you do not set this value, the presale '
            'will end after the end date of your event.'),
        required=False,
        limit_choices=('date_from', 'date_to'),
    )

    def __init__(self, *args, **kwargs):
        self.event = kwargs['event']
        super().__init__(*args, **kwargs)
        self.fields['location'].widget.attrs['rows'] = '3'
        del self.fields['date_from']
        del self.fields['date_to']
        del self.fields['date_admission']
Example #2
0
class VenuelessSettingsForm(SettingsForm):
    venueless_url = forms.URLField(
        label=_("Venueless URL"),
        required=False,
    )
    venueless_secret = SecretKeySettingsField(
        label=_("Venueless secret"),
        required=False,
    )
    venueless_issuer = forms.CharField(
        label=_("Venueless issuer"),
        required=False,
    )
    venueless_audience = forms.CharField(
        label=_("Venueless audience"),
        required=False,
    )
    venueless_start = RelativeDateTimeField(
        label=_('Start of live event'),
        required=False,
    )
    venueless_allow_pending = forms.BooleanField(
        label=_(
            'Allow users to access the live event before their order is paid'),
        required=False,
    )
    venueless_all_items = forms.BooleanField(
        label=_('Allow buyers of all admission products'), required=False)
    venueless_items = forms.ModelMultipleChoiceField(
        widget=forms.CheckboxSelectMultiple(
            attrs={
                'class': 'scrolling-multiple-choice',
                'data-inverse-dependency': '<[name$=venueless_all_items]'
            }),
        label=_('Limit to products'),
        required=False,
        queryset=Item.objects.none(),
        initial=None)

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

    def clean(self):
        data = super().clean()

        for k, v in self.fields.items():
            if isinstance(v, forms.ModelMultipleChoiceField):
                answstr = [o.pk for o in data[k]]
                data[k] = answstr

        return data
Example #3
0
class BulkSubEventItemVariationForm(SubEventItemVariationForm):
    rel_available_from = RelativeDateTimeField(
        label=_('Available from'),
        required=False,
        limit_choices=('date_from', 'date_to'),
    )
    rel_available_until = RelativeDateTimeField(
        label=_('Available_until'),
        required=False,
        limit_choices=('date_from', 'date_to'),
    )

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        del self.fields['available_from']
        del self.fields['available_until']
        if self.instance and self.instance.available_from and 'rel_available_from' not in self.initial:
            self.initial['rel_available_from'] = RelativeDateWrapper(
                self.instance.available_from)
        if self.instance and self.instance.available_until and 'rel_available_until' not in self.initial:
            self.initial['rel_available_until'] = RelativeDateWrapper(
                self.instance.available_until)
Example #4
0
class TicketSettingsForm(SettingsForm):
    ticket_download = forms.BooleanField(
        label=_("Use feature"),
        help_text=
        _("Use pretix to generate tickets for the user to download and print out."
          ),
        required=False)
    ticket_download_date = RelativeDateTimeField(
        label=_("Download date"),
        help_text=
        _("Ticket download will be offered after this date. If you use the event series feature and an order "
          "contains tickets for multiple event dates, download of all tickets will be available if at least "
          "one of the event dates allows it."),
        required=False,
    )
    ticket_download_addons = forms.BooleanField(
        label=_("Offer to download tickets separately for add-on products"),
        required=False,
        widget=forms.CheckboxInput(
            attrs={'data-display-dependency': '#id_ticket_download'}),
    )
    ticket_download_nonadm = forms.BooleanField(
        label=_("Generate tickets for non-admission products"),
        required=False,
        widget=forms.CheckboxInput(
            attrs={'data-display-dependency': '#id_ticket_download'}),
    )

    def prepare_fields(self):
        # See clean()
        for k, v in self.fields.items():
            v._required = v.required
            v.required = False
            v.widget.is_required = False
            if isinstance(v, I18nFormField):
                v._required = v.one_required
                v.one_required = False
                v.widget.enabled_locales = self.locales

    def clean(self):
        # required=True files should only be required if the feature is enabled
        cleaned_data = super().clean()
        enabled = cleaned_data.get('ticket_download') == 'True'
        if not enabled:
            return
        for k, v in self.fields.items():
            val = cleaned_data.get(k)
            if v._required and (val is None or val == ""):
                self.add_error(k, _('This field is required.'))
Example #5
0
class EventSettingsForm(SettingsForm):
    show_date_to = forms.BooleanField(
        label=_("Show event end date"),
        help_text=
        _("If disabled, only event's start date will be displayed to the public."
          ),
        required=False)
    show_times = forms.BooleanField(
        label=_("Show dates with time"),
        help_text=
        _("If disabled, the event's start and end date will be displayed without the time of day."
          ),
        required=False)
    show_items_outside_presale_period = forms.BooleanField(
        label=_("Show items outside presale period"),
        help_text=
        _("Show item details before presale has started and after presale has ended"
          ),
        required=False)
    display_net_prices = forms.BooleanField(
        label=
        _("Show net prices instead of gross prices in the product list (not recommended!)"
          ),
        help_text=_(
            "Independent of your choice, the cart will show gross prices as this the price that needs to be "
            "paid"),
        required=False)
    presale_start_show_date = forms.BooleanField(
        label=_("Show start date"),
        help_text=_("Show the presale start date before presale has started."),
        widget=forms.CheckboxInput,
        required=False)
    last_order_modification_date = RelativeDateTimeField(
        label=_('Last date of modifications'),
        help_text=
        _("The last date users can modify details of their orders, such as attendee names or "
          "answers to questions. If you use the event series feature and an order contains tickets for "
          "multiple event dates, the earliest date will be used."),
        required=False,
    )
    timezone = forms.ChoiceField(
        choices=((a, a) for a in common_timezones),
        label=_("Default timezone"),
    )
    locales = forms.MultipleChoiceField(
        choices=settings.LANGUAGES,
        widget=forms.CheckboxSelectMultiple,
        label=_("Available languages"),
    )
    locale = forms.ChoiceField(
        choices=settings.LANGUAGES,
        label=_("Default language"),
    )
    show_quota_left = forms.BooleanField(
        label=_("Show number of tickets left"),
        help_text=
        _("Publicly show how many tickets of a certain type are still available."
          ),
        required=False)
    waiting_list_enabled = forms.BooleanField(
        label=_("Enable waiting list"),
        help_text=
        _("Once a ticket is sold out, people can add themselves to a waiting list. As soon as a ticket "
          "becomes available again, it will be reserved for the first person on the waiting list and this "
          "person will receive an email notification with a voucher that can be used to buy a ticket."
          ),
        required=False)
    waiting_list_hours = forms.IntegerField(
        label=_("Waiting list response time"),
        min_value=6,
        help_text=
        _("If a ticket voucher is sent to a person on the waiting list, it has to be redeemed within this "
          "number of hours until it expires and can be re-assigned to the next person on the list."
          ),
        required=False,
        widget=forms.NumberInput(
            attrs={
                'data-display-dependency': '#id_settings-waiting_list_enabled'
            }),
    )
    waiting_list_auto = forms.BooleanField(
        label=_("Automatic waiting list assignments"),
        help_text=
        _("If ticket capacity becomes free, automatically create a voucher and send it to the first person "
          "on the waiting list for that product. If this is not active, mails will not be send automatically "
          "but you can send them manually via the control panel."),
        required=False,
        widget=forms.CheckboxInput(
            attrs={
                'data-display-dependency': '#id_settings-waiting_list_enabled'
            }),
    )
    attendee_names_asked = forms.BooleanField(
        label=_("Ask for attendee names"),
        help_text=
        _("Ask for a name for all tickets which include admission to the event."
          ),
        required=False,
    )
    attendee_names_required = forms.BooleanField(
        label=_("Require attendee names"),
        help_text=_(
            "Require customers to fill in the names of all attendees."),
        required=False,
        widget=forms.CheckboxInput(
            attrs={
                'data-checkbox-dependency': '#id_settings-attendee_names_asked'
            }),
    )
    attendee_emails_asked = forms.BooleanField(
        label=_("Ask for email addresses per ticket"),
        help_text=
        _("Normally, pretix asks for one email address per order and the order confirmation will be sent "
          "only to that email address. If you enable this option, the system will additionally ask for "
          "individual email addresses for every admission ticket. This might be useful if you want to "
          "obtain individual addresses for every attendee even in case of group orders. However, "
          "pretix will send the order confirmation only to the one primary email address, not to the "
          "per-attendee addresses."),
        required=False)
    attendee_emails_required = forms.BooleanField(
        label=_("Require email addresses per ticket"),
        help_text=
        _("Require customers to fill in individual e-mail addresses for all admission tickets. See the "
          "above option for more details. One email address for the order confirmation will always be "
          "required regardless of this setting."),
        required=False,
        widget=forms.CheckboxInput(attrs={
            'data-checkbox-dependency':
            '#id_settings-attendee_emails_asked'
        }),
    )
    order_email_asked_twice = forms.BooleanField(
        label=_("Ask for the order email address twice"),
        help_text=
        _("Require customers to fill in the primary email address twice to avoid errors."
          ),
        required=False,
    )
    max_items_per_order = forms.IntegerField(
        min_value=1,
        label=_("Maximum number of items per order"),
        help_text=_("Add-on products will not be counted."))
    reservation_time = forms.IntegerField(
        min_value=0,
        label=_("Reservation period"),
        help_text=
        _("The number of minutes the items in a user's cart are reserved for this user."
          ),
    )
    imprint_url = forms.URLField(
        label=_("Imprint URL"),
        required=False,
    )
    confirm_text = I18nFormField(
        label=_('Confirmation text'),
        help_text=
        _('This text needs to be confirmed by the user before a purchase is possible. You could for example '
          'link your terms of service here. If you use the Pages feature to publish your terms of service, '
          'you don\'t need this setting since you can configure it there.'),
        required=False,
        widget=I18nTextarea)
    contact_mail = forms.EmailField(
        label=_("Contact address"),
        required=False,
        help_text=_("Public email address for contacting the organizer"))
    cancel_allow_user = forms.BooleanField(
        label=_("Allow users to cancel unpaid orders"),
        help_text=
        _("If checked, users can cancel orders by themselves as long as they are not yet paid."
          ),
        required=False)

    def clean(self):
        data = super().clean()
        if data['locale'] not in data['locales']:
            raise ValidationError({
                'locale':
                _('Your default locale must also be enabled for your event (see box above).'
                  )
            })
        if data['attendee_names_required'] and not data['attendee_names_asked']:
            raise ValidationError({
                'attendee_names_required':
                _('You cannot require specifying attendee names if you do not ask for them.'
                  )
            })
        if data['attendee_emails_required'] and not data[
                'attendee_emails_asked']:
            raise ValidationError({
                'attendee_emails_required':
                _('You have to ask for attendee emails if you want to make them required.'
                  )
            })
        return data

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['confirm_text'].widget.attrs['rows'] = '3'
        self.fields['confirm_text'].widget.attrs['placeholder'] = _(
            'e.g. I hereby confirm that I have read and agree with the event organizer\'s terms of service '
            'and agree with them.')