Esempio n. 1
0
def test_grant_when_paid_and_changed(event, customer, granting_ticket):
    cp1 = CartPosition.objects.create(
        item=granting_ticket,
        price=0,
        expires=now() + timedelta(days=1),
        event=event,
        cart_id="123",
    )
    q = event.quotas.create(size=None, name="foo")
    q.items.add(granting_ticket)
    order = _create_order(event,
                          email='*****@*****.**',
                          positions=[cp1],
                          now_dt=now(),
                          payment_provider=BankTransfer(event),
                          locale='de',
                          customer=customer)[0]
    assert not customer.memberships.exists()

    order.payments.first().confirm()

    m = customer.memberships.get()
    assert m.granted_in == order.positions.first()
    assert m.membership_type == granting_ticket.grant_membership_type
    assert m.date_start == TZ.localize(datetime(2021, 4, 27, 10, 0, 0, 0))
    assert m.date_end == TZ.localize(datetime(2021, 4, 28, 10, 0, 0, 0))
Esempio n. 2
0
def test_use_membership(event, customer, membership, requiring_ticket):
    cp1 = CartPosition.objects.create(item=requiring_ticket,
                                      price=23,
                                      expires=now() + timedelta(days=1),
                                      event=event,
                                      cart_id="123",
                                      used_membership=membership)
    order = _create_order(event,
                          email='*****@*****.**',
                          positions=[cp1],
                          now_dt=now(),
                          payment_provider=BankTransfer(event),
                          locale='de',
                          customer=customer)[0]
    assert order.positions.first().used_membership == membership
Esempio n. 3
0
class QuickSetupForm(I18nForm):
    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=_("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
    )
    ticket_download = forms.BooleanField(
        label=_("Ticket downloads"),
        help_text=_("Your customers will be able to download their tickets in PDF format."),
        required=False
    )
    attendee_names_required = forms.BooleanField(
        label=_("Require all attendees to fill in their names"),
        help_text=_("By default, we will ask for names but not require them. You can turn this off completely in the "
                    "settings."),
        required=False
    )
    imprint_url = forms.URLField(
        label=_("Imprint URL"),
        help_text=_("This should point e.g. to a part of your website that has your contact details and legal "
                    "information."),
        required=False,
    )
    contact_mail = forms.EmailField(
        label=_("Contact address"),
        required=False,
        help_text=_("We'll show this publicly to allow attendees to contact you.")
    )
    total_quota = forms.IntegerField(
        label=_("Total capacity"),
        min_value=0,
        widget=forms.NumberInput(
            attrs={
                'placeholder': '∞'
            }
        ),
        required=False
    )
    payment_stripe__enabled = forms.BooleanField(
        label=_("Payment via Stripe"),
        help_text=_("Stripe is an online payments processor supporting credit cards and lots of other payment options. "
                    "To accept payments via Stripe, you will need to set up an account with them, which takes less "
                    "than five minutes using their simple interface."),
        required=False
    )
    payment_banktransfer__enabled = forms.BooleanField(
        label=_("Payment by bank transfer"),
        help_text=_("Your customers will be instructed to wire the money to your account. You can then import your "
                    "bank statements to process the payments within pretix, or mark them as paid manually."),
        required=False
    )
    payment_banktransfer_bank_details = BankTransfer.form_field(required=False)

    def __init__(self, *args, **kwargs):
        self.obj = kwargs.pop('event', None)
        self.locales = self.obj.settings.get('locales') if self.obj else kwargs.pop('locales', None)
        kwargs['locales'] = self.locales
        super().__init__(*args, **kwargs)
        if not self.obj.settings.payment_stripe_connect_client_id:
            del self.fields['payment_stripe__enabled']
        self.fields['payment_banktransfer_bank_details'].required = False
Esempio n. 4
0
 def clean(self):
     cleaned_data = super().clean()
     if cleaned_data.get('payment_banktransfer__enabled'):
         provider = BankTransfer(self.obj)
         cleaned_data = provider.settings_form_clean(cleaned_data)
     return cleaned_data