示例#1
0
 def __init__(self, *args, **kwargs):
     self.order = kwargs.pop('order')
     super().__init__(*args, **kwargs)
     change_decimal_field(self.fields['partial_amount'],
                          self.order.event.currency)
     if self.order.status == Order.STATUS_CANCELED:
         del self.fields['action']
示例#2
0
文件: item.py 项目: pajowu/pretix
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.fields['category'].queryset = self.instance.event.categories.all()
     self.fields['tax_rule'].queryset = self.instance.event.tax_rules.all()
     self.fields['description'].widget.attrs['placeholder'] = _(
         'e.g. This reduced price is available for full-time students, jobless and people '
         'over 65. This ticket includes access to all parts of the event, except the VIP '
         'area.')
     if self.event.tax_rules.exists():
         self.fields['tax_rule'].required = True
     self.fields['description'].widget.attrs['rows'] = '4'
     self.fields['sales_channels'] = forms.MultipleChoiceField(
         label=_('Sales channels'),
         choices=((c.identifier, c.verbose_name)
                  for c in get_all_sales_channels().values()),
         widget=forms.CheckboxSelectMultiple)
     change_decimal_field(self.fields['default_price'], self.event.currency)
     self.fields['hidden_if_available'].queryset = self.event.quotas.all()
     self.fields['hidden_if_available'].widget = Select2(
         attrs={
             'data-model-select2':
             'generic',
             'data-select2-url':
             reverse('control:event.items.quotas.select2',
                     kwargs={
                         'event': self.event.slug,
                         'organizer': self.event.organizer.slug,
                     }),
             'data-placeholder':
             _('Quota')
         })
     self.fields['hidden_if_available'].widget.choices = self.fields[
         'hidden_if_available'].choices
     self.fields['hidden_if_available'].required = False
示例#3
0
    def __init__(self, *args, **kwargs):
        instance = kwargs.pop('instance')
        items = kwargs.pop('items')
        initial = kwargs.get('initial', {})

        initial['price'] = instance.price

        kwargs['initial'] = initial
        super().__init__(*args, **kwargs)
        if instance.order.event.has_subevents:
            self.fields['subevent'].queryset = instance.order.event.subevents.all()
            self.fields['subevent'].widget = Select2(
                attrs={
                    'data-model-select2': 'event',
                    'data-select2-url': reverse('control:event.subevents.select2', kwargs={
                        'event': instance.order.event.slug,
                        'organizer': instance.order.event.organizer.slug,
                    }),
                    'data-placeholder': _('(Unchanged)')
                }
            )
            self.fields['subevent'].widget.choices = self.fields['subevent'].choices
        else:
            del self.fields['subevent']

        self.fields['tax_rule'].queryset = instance.event.tax_rules.all()
        self.fields['tax_rule'].label_from_instance = self.taxrule_label_from_instance

        if not instance.seat and not (
                instance.item.seat_category_mappings.filter(subevent=instance.subevent).exists()
        ):
            del self.fields['seat']

        choices = [
            ('', _('(Unchanged)'))
        ]
        for i in items:
            pname = str(i)
            if not i.is_available():
                pname += ' ({})'.format(_('inactive'))
            variations = list(i.variations.all())

            if variations:
                for v in variations:
                    choices.append(('%d-%d' % (i.pk, v.pk),
                                    '%s – %s' % (pname, v.value)))
            else:
                choices.append((str(i.pk), pname))
        self.fields['itemvar'].choices = choices
        change_decimal_field(self.fields['price'], instance.order.event.currency)

        choices = [
            ('', _('(Unchanged)')),
            ('CLEAR', _('(No membership)')),
        ]
        if instance.order.customer:
            self.memberships = list(instance.order.customer.memberships.all())
            for m in self.memberships:
                choices.append((str(m.pk), str(m)))
        self.fields['used_membership'].choices = choices
示例#4
0
文件: item.py 项目: zenny/pretix
    def __init__(self, *args, **kwargs):
        self.item = kwargs.pop('item')
        super().__init__(*args, **kwargs)
        instance = kwargs.get('instance', None)
        initial = kwargs.get('initial', {})

        if instance:
            try:
                if instance.bundled_variation:
                    initial['itemvar'] = '%d-%d' % (instance.bundled_item.pk, instance.bundled_variation.pk)
                elif instance.bundled_item:
                    initial['itemvar'] = str(instance.bundled_item.pk)
            except Item.DoesNotExist:
                pass

        kwargs['initial'] = initial
        super().__init__(*args, **kwargs)

        choices = []
        for i in self.event.items.prefetch_related('variations').all():
            pname = str(i)
            if not i.is_available():
                pname += ' ({})'.format(_('inactive'))
            variations = list(i.variations.all())

            if variations:
                for v in variations:
                    choices.append(('%d-%d' % (i.pk, v.pk),
                                    '%s – %s' % (pname, v.value)))
            else:
                choices.append((str(i.pk), '%s' % pname))
        self.fields['itemvar'].choices = choices
        change_decimal_field(self.fields['designated_price'], self.event.currency)
示例#5
0
文件: orders.py 项目: zjw2011/pretix
    def __init__(self, *args, **kwargs):
        instance = kwargs.pop('instance')
        initial = kwargs.get('initial', {})

        initial['value'] = instance.value
        kwargs['initial'] = initial
        super().__init__(*args, **kwargs)
        change_decimal_field(self.fields['value'], instance.order.event.currency)
示例#6
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     prs = self.instance.payment_refund_sum
     if prs > 0:
         change_decimal_field(self.fields['cancellation_fee'], self.instance.event.currency)
         self.fields['cancellation_fee'].initial = Decimal('0.00')
         self.fields['cancellation_fee'].max_value = prs
     else:
         del self.fields['cancellation_fee']
示例#7
0
文件: orders.py 项目: sker152/pretix
    def __init__(self, *args, **kwargs):
        instance = kwargs.pop('instance')
        initial = kwargs.get('initial', {})

        initial['price'] = instance.price

        kwargs['initial'] = initial
        super().__init__(*args, **kwargs)
        if instance.order.event.has_subevents:
            self.fields['subevent'].queryset = instance.order.event.subevents.all()
            self.fields['subevent'].widget = Select2(
                attrs={
                    'data-model-select2': 'event',
                    'data-select2-url': reverse('control:event.subevents.select2', kwargs={
                        'event': instance.order.event.slug,
                        'organizer': instance.order.event.organizer.slug,
                    }),
                    'data-placeholder': _('(Unchanged)')
                }
            )
            self.fields['subevent'].widget.choices = self.fields['subevent'].choices
        else:
            del self.fields['subevent']

        if instance.seat:
            self.fields['seat'].queryset = instance.order.event.seats.all()
            self.fields['seat'].widget = Select2(
                attrs={
                    'data-model-select2': 'seat',
                    'data-select2-url': reverse('control:event.seats.select2', kwargs={
                        'event': instance.order.event.slug,
                        'organizer': instance.order.event.organizer.slug,
                    }),
                    'data-placeholder': _('(Unchanged)')
                }
            )
            self.fields['seat'].widget.choices = self.fields['seat'].choices
        else:
            del self.fields['seat']

        choices = [
            ('', _('(Unchanged)'))
        ]
        for i in instance.order.event.items.prefetch_related('variations').all():
            pname = str(i)
            if not i.is_available():
                pname += ' ({})'.format(_('inactive'))
            variations = list(i.variations.all())

            if variations:
                for v in variations:
                    choices.append(('%d-%d' % (i.pk, v.pk),
                                    '%s – %s' % (pname, v.value)))
            else:
                choices.append((str(i.pk), pname))
        self.fields['itemvar'].choices = choices
        change_decimal_field(self.fields['price'], instance.order.event.currency)
示例#8
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.fields['category'].queryset = self.instance.event.categories.all()
     self.fields['tax_rule'].queryset = self.instance.event.tax_rules.all()
     self.fields['description'].widget.attrs['placeholder'] = _(
         'e.g. This reduced price is available for full-time students, jobless and people '
         'over 65. This ticket includes access to all parts of the event, except the VIP '
         'area.')
     change_decimal_field(self.fields['default_price'], self.event.currency)
示例#9
0
文件: orders.py 项目: sker152/pretix
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     prs = self.instance.payment_refund_sum
     if prs > 0:
         change_decimal_field(self.fields['cancellation_fee'], self.instance.event.currency)
         self.fields['cancellation_fee'].initial = Decimal('0.00')
         self.fields['cancellation_fee'].max_value = prs
     else:
         del self.fields['cancellation_fee']
示例#10
0
文件: item.py 项目: zenny/pretix
    def __init__(self, *args, **kwargs):
        self.event = kwargs['event']
        self.user = kwargs.pop('user')
        super().__init__(*args, **kwargs)

        self.fields['category'].queryset = self.instance.event.categories.all()
        self.fields['tax_rule'].queryset = self.instance.event.tax_rules.all()
        change_decimal_field(self.fields['default_price'], self.instance.event.currency)
        self.fields['tax_rule'].empty_label = _('No taxation')
        self.fields['copy_from'] = forms.ModelChoiceField(
            label=_("Copy product information"),
            queryset=self.event.items.all(),
            widget=forms.Select,
            empty_label=_('Do not copy'),
            required=False
        )
        if self.event.tax_rules.exists():
            self.fields['tax_rule'].required = True

        if not self.event.has_subevents:
            choices = [
                (self.NONE, _("Do not add to a quota now")),
                (self.EXISTING, _("Add product to an existing quota")),
                (self.NEW, _("Create a new quota for this product"))
            ]
            if not self.event.quotas.exists():
                choices.remove(choices[1])

            self.fields['quota_option'] = forms.ChoiceField(
                label=_("Quota options"),
                widget=forms.RadioSelect,
                choices=choices,
                initial=self.NONE,
                required=False
            )

            self.fields['quota_add_existing'] = forms.ModelChoiceField(
                label=_("Add to existing quota"),
                widget=forms.Select(),
                queryset=self.instance.event.quotas.all(),
                required=False
            )

            self.fields['quota_add_new_name'] = forms.CharField(
                label=_("Name"),
                max_length=200,
                widget=forms.TextInput(attrs={'placeholder': _("New quota name")}),
                required=False
            )

            self.fields['quota_add_new_size'] = forms.IntegerField(
                min_value=0,
                label=_("Size"),
                widget=forms.TextInput(attrs={'placeholder': _("Number of tickets")}),
                help_text=_("Leave empty for an unlimited number of tickets."),
                required=False
            )
示例#11
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        change_decimal_field(self.fields['default_price'], self.event.currency)

        qs = self.event.organizer.membership_types.all()
        if qs:
            self.fields['require_membership_types'].queryset = qs
        else:
            del self.fields['require_membership']
            del self.fields['require_membership_types']
示例#12
0
文件: item.py 项目: astrocbxy/pretix
    def __init__(self, *args, **kwargs):
        qs = kwargs.pop('membership_types')
        super().__init__(*args, **kwargs)
        change_decimal_field(self.fields['default_price'], self.event.currency)

        if qs:
            self.fields['require_membership_types'].queryset = qs
        else:
            del self.fields['require_membership']
            del self.fields['require_membership_types']
示例#13
0
    def __init__(self, *args, **kwargs):
        self.items = kwargs.pop('items')
        order = kwargs.pop('order')
        super().__init__(*args, **kwargs)

        try:
            ia = order.invoice_address
        except InvoiceAddress.DoesNotExist:
            ia = None

        choices = []
        for i in self.items:
            pname = str(i)
            if not i.is_available():
                pname += ' ({})'.format(_('inactive'))
            variations = list(i.variations.all())
            if i.tax_rule:  # performance optimization
                i.tax_rule.event = order.event
            if variations:
                for v in variations:
                    p = get_price(i, v, invoice_address=ia)
                    choices.append(('%d-%d' % (i.pk, v.pk),
                                    '%s – %s (%s)' % (pname, v.value, p.print(order.event.currency))))
            else:
                p = get_price(i, invoice_address=ia)
                choices.append((str(i.pk), '%s (%s)' % (pname, p.print(order.event.currency))))
        self.fields['itemvar'].choices = choices
        if order.event.cache.get_or_set(
                'has_addon_products',
                default=lambda: ItemAddOn.objects.filter(base_item__event=order.event).exists(),
                timeout=300
        ):
            self.fields['addon_to'].queryset = order.positions.filter(addon_to__isnull=True).select_related(
                'item', 'variation'
            )
        else:
            del self.fields['addon_to']

        if order.event.has_subevents:
            self.fields['subevent'].queryset = order.event.subevents.all()
            self.fields['subevent'].widget = Select2(
                attrs={
                    'data-model-select2': 'event',
                    'data-select2-url': reverse('control:event.subevents.select2', kwargs={
                        'event': order.event.slug,
                        'organizer': order.event.organizer.slug,
                    }),
                    'data-placeholder': pgettext_lazy('subevent', 'Date')
                }
            )
            self.fields['subevent'].widget.choices = self.fields['subevent'].choices
            self.fields['subevent'].required = True
        else:
            del self.fields['subevent']
        change_decimal_field(self.fields['price'], order.event.currency)
示例#14
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     prs = self.instance.payment_refund_sum
     if prs > 0:
         change_decimal_field(self.fields['cancellation_fee'], self.instance.event.currency)
         self.fields['cancellation_fee'].widget.attrs['placeholder'] = floatformat(
             Decimal('0.00'),
             settings.CURRENCY_PLACES.get(self.instance.event.currency, 2)
         )
         self.fields['cancellation_fee'].max_value = prs
     else:
         del self.fields['cancellation_fee']
示例#15
0
    def __init__(self, *args, **kwargs):
        instance = kwargs.pop('instance')
        initial = kwargs.get('initial', {})

        try:
            ia = instance.order.invoice_address
        except InvoiceAddress.DoesNotExist:
            ia = None

        if instance:
            try:
                if instance.variation:
                    initial['itemvar'] = '%d-%d' % (instance.item.pk, instance.variation.pk)
                elif instance.item:
                    initial['itemvar'] = str(instance.item.pk)
            except Item.DoesNotExist:
                pass

            if instance.item.tax_rule and not instance.item.tax_rule.price_includes_tax:
                initial['price'] = instance.price - instance.tax_value
            else:
                initial['price'] = instance.price
        initial['subevent'] = instance.subevent

        kwargs['initial'] = initial
        super().__init__(*args, **kwargs)
        if instance.order.event.has_subevents:
            self.fields['subevent'].instance = instance
            self.fields['subevent'].queryset = instance.order.event.subevents.all()
        else:
            del self.fields['subevent']

        choices = []
        for i in instance.order.event.items.prefetch_related('variations').all():
            pname = str(i.name)
            if not i.is_available():
                pname += ' ({})'.format(_('inactive'))
            variations = list(i.variations.all())

            if variations:
                for v in variations:
                    p = get_price(i, v, voucher=instance.voucher, subevent=instance.subevent,
                                  invoice_address=ia)
                    choices.append(('%d-%d' % (i.pk, v.pk),
                                    '%s – %s (%s)' % (pname, v.value, p.print(instance.order.event.currency))))
            else:
                p = get_price(i, None, voucher=instance.voucher, subevent=instance.subevent,
                              invoice_address=ia)
                choices.append((str(i.pk), '%s (%s)' % (pname, p.print(instance.order.event.currency))))
        self.fields['itemvar'].choices = choices
        change_decimal_field(self.fields['price'], instance.order.event.currency)
示例#16
0
    def __init__(self, *args, **kwargs):
        instance = kwargs.pop('instance')
        initial = kwargs.get('initial', {})

        try:
            ia = instance.order.invoice_address
        except InvoiceAddress.DoesNotExist:
            ia = None

        if instance:
            try:
                if instance.variation:
                    initial['itemvar'] = '%d-%d' % (instance.item.pk, instance.variation.pk)
                elif instance.item:
                    initial['itemvar'] = str(instance.item.pk)
            except Item.DoesNotExist:
                pass

            if instance.item.tax_rule and not instance.item.tax_rule.price_includes_tax:
                initial['price'] = instance.price - instance.tax_value
            else:
                initial['price'] = instance.price
        initial['subevent'] = instance.subevent

        kwargs['initial'] = initial
        super().__init__(*args, **kwargs)
        if instance.order.event.has_subevents:
            self.fields['subevent'].instance = instance
            self.fields['subevent'].queryset = instance.order.event.subevents.all()
        else:
            del self.fields['subevent']

        choices = []
        for i in instance.order.event.items.prefetch_related('variations').all():
            pname = str(i)
            if not i.is_available():
                pname += ' ({})'.format(_('inactive'))
            variations = list(i.variations.all())

            if variations:
                for v in variations:
                    p = get_price(i, v, voucher=instance.voucher, subevent=instance.subevent,
                                  invoice_address=ia)
                    choices.append(('%d-%d' % (i.pk, v.pk),
                                    '%s – %s (%s)' % (pname, v.value, p.print(instance.order.event.currency))))
            else:
                p = get_price(i, None, voucher=instance.voucher, subevent=instance.subevent,
                              invoice_address=ia)
                choices.append((str(i.pk), '%s (%s)' % (pname, p.print(instance.order.event.currency))))
        self.fields['itemvar'].choices = choices
        change_decimal_field(self.fields['price'], instance.order.event.currency)
示例#17
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.fields['category'].queryset = self.instance.event.categories.all()
     self.fields['tax_rule'].queryset = self.instance.event.tax_rules.all()
     self.fields['description'].widget.attrs['placeholder'] = _(
         'e.g. This reduced price is available for full-time students, jobless and people '
         'over 65. This ticket includes access to all parts of the event, except the VIP '
         'area.')
     self.fields['sales_channels'] = forms.MultipleChoiceField(
         label=_('Sales channels'),
         choices=((c.identifier, c.verbose_name)
                  for c in get_all_sales_channels().values()),
         widget=forms.CheckboxSelectMultiple)
     change_decimal_field(self.fields['default_price'], self.event.currency)
示例#18
0
    def __init__(self, *args, **kwargs):
        order = kwargs.pop('order')
        super().__init__(*args, **kwargs)

        try:
            ia = order.invoice_address
        except InvoiceAddress.DoesNotExist:
            ia = None

        choices = []
        for i in order.event.items.prefetch_related('variations').all():
            pname = str(i)
            if not i.is_available():
                pname += ' ({})'.format(_('inactive'))
            variations = list(i.variations.all())
            if variations:
                for v in variations:
                    p = get_price(i, v, invoice_address=ia)
                    choices.append(('%d-%d' % (i.pk, v.pk),
                                    '%s – %s (%s)' % (pname, v.value, p.print(order.event.currency))))
            else:
                p = get_price(i, invoice_address=ia)
                choices.append((str(i.pk), '%s (%s)' % (pname, p.print(order.event.currency))))
        self.fields['itemvar'].choices = choices
        if ItemAddOn.objects.filter(base_item__event=order.event).exists():
            self.fields['addon_to'].queryset = order.positions.filter(addon_to__isnull=True).select_related(
                'item', 'variation'
            )
        else:
            del self.fields['addon_to']

        if order.event.has_subevents:
            self.fields['subevent'].queryset = order.event.subevents.all()
            self.fields['subevent'].widget = Select2(
                attrs={
                    'data-model-select2': 'event',
                    'data-select2-url': reverse('control:event.subevents.select2', kwargs={
                        'event': order.event.slug,
                        'organizer': order.event.organizer.slug,
                    }),
                    'data-placeholder': pgettext_lazy('subevent', 'Date')
                }
            )
            self.fields['subevent'].widget.choices = self.fields['subevent'].choices
            self.fields['subevent'].required = True
        else:
            del self.fields['subevent']
        change_decimal_field(self.fields['price'], order.event.currency)
示例#19
0
    def __init__(self, *args, **kwargs):
        instance = kwargs.pop('instance')
        initial = kwargs.get('initial', {})

        if instance.item.tax_rule and not instance.item.tax_rule.price_includes_tax:
            initial['price'] = instance.price - instance.tax_value
        else:
            initial['price'] = instance.price

        kwargs['initial'] = initial
        super().__init__(*args, **kwargs)
        if instance.order.event.has_subevents:
            self.fields['subevent'].queryset = instance.order.event.subevents.all()
            self.fields['subevent'].widget = Select2(
                attrs={
                    'data-model-select2': 'event',
                    'data-select2-url': reverse('control:event.subevents.select2', kwargs={
                        'event': instance.order.event.slug,
                        'organizer': instance.order.event.organizer.slug,
                    }),
                    'data-placeholder': _('(Unchanged)')
                }
            )
            self.fields['subevent'].widget.choices = self.fields['subevent'].choices
        else:
            del self.fields['subevent']

        choices = [
            ('', _('(Unchanged)'))
        ]
        for i in instance.order.event.items.prefetch_related('variations').all():
            pname = str(i)
            if not i.is_available():
                pname += ' ({})'.format(_('inactive'))
            variations = list(i.variations.all())

            if variations:
                for v in variations:
                    choices.append(('%d-%d' % (i.pk, v.pk),
                                    '%s – %s' % (pname, v.value)))
            else:
                choices.append((str(i.pk), pname))
        self.fields['itemvar'].choices = choices
        change_decimal_field(self.fields['price'], instance.order.event.currency)
示例#20
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.fields['category'].queryset = self.instance.event.categories.all()
     self.fields['tax_rule'].queryset = self.instance.event.tax_rules.all()
     self.fields['description'].widget.attrs['placeholder'] = _(
         'e.g. This reduced price is available for full-time students, jobless and people '
         'over 65. This ticket includes access to all parts of the event, except the VIP '
         'area.'
     )
     if self.event.tax_rules.exists():
         self.fields['tax_rule'].required = True
     self.fields['description'].widget.attrs['rows'] = '4'
     self.fields['sales_channels'] = forms.MultipleChoiceField(
         label=_('Sales channels'),
         choices=(
             (c.identifier, c.verbose_name) for c in get_all_sales_channels().values()
         ),
         widget=forms.CheckboxSelectMultiple
     )
     change_decimal_field(self.fields['default_price'], self.event.currency)
示例#21
0
    def __init__(self, *args, **kwargs):
        order = kwargs.pop('order')
        super().__init__(*args, **kwargs)

        try:
            ia = order.invoice_address
        except InvoiceAddress.DoesNotExist:
            ia = None

        choices = []
        for i in order.event.items.prefetch_related('variations').all():
            pname = str(i.name)
            if not i.is_available():
                pname += ' ({})'.format(_('inactive'))
            variations = list(i.variations.all())
            if variations:
                for v in variations:
                    p = get_price(i, v, invoice_address=ia)
                    choices.append(
                        ('%d-%d' % (i.pk, v.pk), '%s – %s (%s)' %
                         (pname, v.value, p.print(order.event.currency))))
            else:
                p = get_price(i, invoice_address=ia)
                choices.append(
                    (str(i.pk),
                     '%s (%s)' % (pname, p.print(order.event.currency))))
        self.fields['itemvar'].choices = choices
        if ItemAddOn.objects.filter(base_item__event=order.event).exists():
            self.fields['addon_to'].queryset = order.positions.filter(
                addon_to__isnull=True).select_related('item', 'variation')
        else:
            del self.fields['addon_to']

        if order.event.has_subevents:
            self.fields['subevent'].queryset = order.event.subevents.all()
        else:
            del self.fields['subevent']
        change_decimal_field(self.fields['price'], order.event.currency)
示例#22
0
    def __init__(self, *args, **kwargs):
        qs = kwargs.pop('membership_types')
        super().__init__(*args, **kwargs)
        change_decimal_field(self.fields['default_price'], self.event.currency)
        self.fields['sales_channels'] = forms.MultipleChoiceField(
            label=_('Sales channels'),
            required=False,
            choices=(
                (c.identifier, c.verbose_name) for c in get_all_sales_channels().values()
            ),
            help_text=_('The sales channel selection for the product as a whole takes precedence, so if a sales channel is '
                        'selected here but not on product level, the variation will not be available.'),
            widget=forms.CheckboxSelectMultiple
        )
        if not self.instance.pk:
            self.initial.setdefault('sales_channels', list(get_all_sales_channels().keys()))

        self.fields['description'].widget.attrs['rows'] = 3
        if qs:
            self.fields['require_membership_types'].queryset = qs
        else:
            del self.fields['require_membership']
            del self.fields['require_membership_types']
示例#23
0
 def __init__(self, *args, **kwargs):
     self.item = kwargs.pop('item')
     self.variation = kwargs.pop('variation', None)
     super().__init__(*args, **kwargs)
     change_decimal_field(self.fields['price'], self.item.event.currency)
示例#24
0
 def __init__(self, *args, **kwargs):
     self.order = kwargs.pop('order')
     super().__init__(*args, **kwargs)
     change_decimal_field(self.fields['partial_amount'], self.order.event.currency)
     if self.order.status in (Order.STATUS_REFUNDED, Order.STATUS_CANCELED):
         del self.fields['action']
示例#25
0
文件: item.py 项目: zenny/pretix
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     change_decimal_field(self.fields['default_price'], self.event.currency)
示例#26
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     change_decimal_field(self.fields['amount'], self.instance.event.currency)
     self.fields['amount'].initial = max(Decimal('0.00'), self.instance.pending_sum)
示例#27
0
 def __init__(self, *args, **kwargs):
     self.order = kwargs.pop('order')
     super().__init__(*args, **kwargs)
     change_decimal_field(self.fields['partial_amount'], self.order.event.currency)
示例#28
0
 def __init__(self, *args, **kwargs):
     self.item = kwargs.pop('item')
     self.variation = kwargs.pop('variation', None)
     super().__init__(*args, **kwargs)
     change_decimal_field(self.fields['price'], self.item.event.currency)
示例#29
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     change_decimal_field(self.fields['amount'], self.instance.event.currency)
     self.fields['amount'].initial = max(Decimal('0.00'), self.instance.pending_sum)
示例#30
0
    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        kwargs.setdefault('initial', {})
        kwargs['initial']['gift_card_expires'] = self.event.organizer.default_gift_card_expiry
        super().__init__(*args, **kwargs)
        self.fields['send_subject'] = I18nFormField(
            label=_("Subject"),
            required=True,
            widget_kwargs={'attrs': {'data-display-dependency': '#id_send'}},
            initial=_('Canceled: {event}'),
            widget=I18nTextInput,
            locales=self.event.settings.get('locales'),
        )
        self.fields['send_message'] = I18nFormField(
            label=_('Message'),
            widget=I18nTextarea,
            required=True,
            widget_kwargs={'attrs': {'data-display-dependency': '#id_send'}},
            locales=self.event.settings.get('locales'),
            initial=LazyI18nString.from_gettext(gettext_noop(
                'Hello,\n\n'
                'with this email, we regret to inform you that {event} has been canceled.\n\n'
                'We will refund you {refund_amount} to your original payment method.\n\n'
                'You can view the current state of your order here:\n\n{url}\n\nBest regards,\n\n'
                'Your {event} team'
            ))
        )

        self._set_field_placeholders('send_subject', ['event_or_subevent', 'refund_amount', 'position_or_address',
                                                      'order', 'event'])
        self._set_field_placeholders('send_message', ['event_or_subevent', 'refund_amount', 'position_or_address',
                                                      'order', 'event'])
        self.fields['send_waitinglist_subject'] = I18nFormField(
            label=_("Subject"),
            required=True,
            initial=_('Canceled: {event}'),
            widget=I18nTextInput,
            widget_kwargs={'attrs': {'data-display-dependency': '#id_send_waitinglist'}},
            locales=self.event.settings.get('locales'),
        )
        self.fields['send_waitinglist_message'] = I18nFormField(
            label=_('Message'),
            widget=I18nTextarea,
            required=True,
            locales=self.event.settings.get('locales'),
            widget_kwargs={'attrs': {'data-display-dependency': '#id_send_waitinglist'}},
            initial=LazyI18nString.from_gettext(gettext_noop(
                'Hello,\n\n'
                'with this email, we regret to inform you that {event} has been canceled.\n\n'
                'You will therefore not receive a ticket from the waiting list.\n\n'
                'Best regards,\n\n'
                'Your {event} team'
            ))
        )
        self._set_field_placeholders('send_waitinglist_subject', ['event_or_subevent', 'event'])
        self._set_field_placeholders('send_waitinglist_message', ['event_or_subevent', 'event'])

        if self.event.has_subevents:
            self.fields['subevent'].queryset = self.event.subevents.all()
            self.fields['subevent'].widget = Select2(
                attrs={
                    'data-inverse-dependency': '#id_all_subevents',
                    'data-model-select2': 'event',
                    'data-select2-url': reverse('control:event.subevents.select2', kwargs={
                        'event': self.event.slug,
                        'organizer': self.event.organizer.slug,
                    }),
                    'data-placeholder': pgettext_lazy('subevent', 'All dates')
                }
            )
            self.fields['subevent'].widget.choices = self.fields['subevent'].choices
        else:
            del self.fields['subevent']
            del self.fields['all_subevents']
        change_decimal_field(self.fields['keep_fee_fixed'], self.event.currency)