mirror of
https://github.com/pretix/pretix.git
synced 2026-03-24 16:02:27 +00:00
Compare commits
17 Commits
shorter-lo
...
voucher-wi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
673df7df80 | ||
|
|
9e9fc36b50 | ||
|
|
bfd87f11dd | ||
|
|
f76d173162 | ||
|
|
f8b38dca82 | ||
|
|
248ab25567 | ||
|
|
982a622e88 | ||
|
|
82b68bf7e0 | ||
|
|
2efde1669d | ||
|
|
eea6a5e9da | ||
|
|
fdbe71ff63 | ||
|
|
a8be2d5f24 | ||
|
|
b15c4e6d6f | ||
|
|
8b00361d1b | ||
|
|
444678ce6b | ||
|
|
0f8d520336 | ||
|
|
4d7b5a0a3b |
@@ -201,6 +201,10 @@ You can use an existing memcached server as pretix's caching backend::
|
||||
|
||||
If no memcached is configured, pretix will use Django's built-in local-memory caching method.
|
||||
|
||||
.. note:: If you use memcached and you deploy pretix across multiple servers, you should use *one*
|
||||
shared memcached instance, not multiple ones, because cache invalidations would not be
|
||||
propagated otherwise.
|
||||
|
||||
|
||||
Redis
|
||||
-----
|
||||
|
||||
@@ -168,7 +168,7 @@ named ``/etc/systemd/system/pretix.service`` with the following content::
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
You can leave the MySQL socket volume out if you're using PostgreSQL. You can now run the following comamnds
|
||||
You can leave the MySQL socket volume out if you're using PostgreSQL. You can now run the following commands
|
||||
to enable and start the service::
|
||||
|
||||
# systemctl daemon-reload
|
||||
|
||||
@@ -5,51 +5,33 @@ General remarks
|
||||
|
||||
Requirements
|
||||
------------
|
||||
To use pretix, the most minimal setup consists of:
|
||||
To use pretix, you wull need the following things:
|
||||
|
||||
* **pretix** and the python packages it depends on
|
||||
|
||||
* An **WSGI application server** (we recommend gunicorn)
|
||||
|
||||
* A periodic task runner, e.g. ``cron``
|
||||
|
||||
To run pretix, you will need **at least Python 3.4**. We only recommend installations on **Linux**, Windows is not
|
||||
officially supported (but might work).
|
||||
* **A database**. This needs to be a SQL-based that is supported by Django. We highly recommend to either
|
||||
go for **PostgreSQL** or **MySQL/MariaDB**. If you do not provide one, pretix will run on SQLite, which is useful
|
||||
for evaluation and development purposes.
|
||||
|
||||
Optional requirements
|
||||
---------------------
|
||||
.. warning:: Do not ever use SQLite in production. It will break.
|
||||
|
||||
pretix is built in a way that makes many of the following requirements optional. However, performance or security might
|
||||
be very low if you skip some of them, therefore they are only partly optional.
|
||||
* A **reverse proxy**. pretix needs to deliver some static content to your users (e.g. CSS, images, ...). While pretix
|
||||
is capable of doing this, having this handled by a proper web server like **nginx** or **Apache** will be much
|
||||
faster. Also, you need a proxying web server in front to provide SSL encryption.
|
||||
|
||||
Database
|
||||
A good SQL-based database to run on that is supported by Django. We highly recommend to either go for **PostgreSQL**
|
||||
or **MySQL/MariaDB**.
|
||||
If you do not provide one, pretix will run on SQLite, which is useful for evaluation and development purposes.
|
||||
.. warning:: Do not ever run without SSL in production. Your users deserve encrypted connections and thanks to
|
||||
`Let's Encrypt`_ SSL certificates can be obtained for free these days.
|
||||
|
||||
.. warning:: Do not ever use SQLite in production. It will break.
|
||||
* A **redis** server. This will be used for caching, session storage and task queuing.
|
||||
|
||||
Reverse proxy
|
||||
pretix needs to deliver some static content to your users (e.g. CSS, images, ...). While pretix is capable of
|
||||
doing this, having this handled by a proper web server like **nginx** or **Apache** will be much faster. Also, you
|
||||
need a proxying web server in front to provide SSL encryption.
|
||||
.. warning:: pretix can run without redis, however this is only intended for development and should never be
|
||||
used in production.
|
||||
|
||||
.. warning:: Do not ever run without SSL in production. Your users deserve encrypted connections and thanks to
|
||||
`Let's Encrypt`_ SSL certificates can be obtained for free these days.
|
||||
|
||||
Task worker
|
||||
When pretix has to do heavy stuff, it is better to offload it into a background process instead of having the
|
||||
users connection wait. Therefore pretix provides a background service that can be used to work on those
|
||||
longer-running tasks.
|
||||
|
||||
This requires at least Redis (and optionally RabbitMQ).
|
||||
|
||||
Redis
|
||||
If you provide a redis instance, pretix is able to make use of it in the three following ways:
|
||||
|
||||
* Caching
|
||||
* Fast session storage
|
||||
* Queuing and result storage for the task worker queue
|
||||
|
||||
RabbitMQ
|
||||
RabbitMQ can be used as a more advanced queue manager for the task workers if necessary.
|
||||
* Optionally: RabbitMQ or memcached. Both of them might provide speedups, but if they are not present,
|
||||
redis will take over their job.
|
||||
|
||||
.. _Let's Encrypt: https://letsencrypt.org/
|
||||
|
||||
@@ -70,8 +70,6 @@ The provider class
|
||||
|
||||
.. automethod:: is_allowed
|
||||
|
||||
.. automethod:: is_allowed_for_order
|
||||
|
||||
.. autoattribute:: payment_form_fields
|
||||
|
||||
.. automethod:: checkout_prepare
|
||||
|
||||
@@ -65,5 +65,3 @@ The output class
|
||||
.. automethod:: generate
|
||||
|
||||
.. autoattribute:: download_button_text
|
||||
|
||||
.. autoattribute:: download_button_icon
|
||||
|
||||
@@ -6,7 +6,7 @@ localecompile:
|
||||
|
||||
localegen:
|
||||
./manage.py makemessages --all --ignore "pretix/helpers/*"
|
||||
./manage.py makemessages --all -d djangojs --ignore "pretix/helpers/*"
|
||||
./manage.py makemessages --all -d djangojs --ignore "pretix/helpers/*" --ignore "static/jsi18n/*"
|
||||
|
||||
staticfiles: jsi18n
|
||||
./manage.py collectstatic --noinput
|
||||
|
||||
30
src/pretix/base/migrations/0048_auto_20161129_1330.py
Normal file
30
src/pretix/base/migrations/0048_auto_20161129_1330.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.3 on 2016-11-29 13:30
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pretixbase', '0047_auto_20161126_1300'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='voucher',
|
||||
name='price_mode',
|
||||
field=models.CharField(choices=[('none', 'No effect'), ('set', 'Set product price to'), ('subtract', 'Subtract from product price'), ('percent', 'Reduce product price by (%)')], default='set', max_length=100, verbose_name='Price mode'),
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='voucher',
|
||||
old_name='price',
|
||||
new_name='value',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='voucher',
|
||||
name='value',
|
||||
field=models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True, verbose_name='Voucher value'),
|
||||
),
|
||||
]
|
||||
@@ -8,6 +8,8 @@ import pytz
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.db.models import F
|
||||
from django.db.models.signals import post_delete
|
||||
from django.dispatch import receiver
|
||||
from django.utils.crypto import get_random_string
|
||||
from django.utils.timezone import make_aware, now
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@@ -563,3 +565,9 @@ class CachedTicket(models.Model):
|
||||
order_position = models.ForeignKey(OrderPosition, on_delete=models.CASCADE)
|
||||
cachedfile = models.ForeignKey(CachedFile, on_delete=models.CASCADE, null=True)
|
||||
provider = models.CharField(max_length=255)
|
||||
|
||||
|
||||
@receiver(post_delete, sender=CachedTicket)
|
||||
def cached_file_delete(sender, instance, **kwargs):
|
||||
if instance.cachedfile:
|
||||
instance.cachedfile.delete()
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
@@ -5,6 +7,7 @@ from django.utils.crypto import get_random_string
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from ..decimal import round_decimal
|
||||
from .base import LoggedModel
|
||||
from .event import Event
|
||||
from .items import Item, ItemVariation, Quota
|
||||
@@ -40,8 +43,11 @@ class Voucher(LoggedModel):
|
||||
:type block_quota: bool
|
||||
:param allow_ignore_quota: If set to true, this voucher can be redeemed even if the event is sold out
|
||||
:type allow_ignore_quota: bool
|
||||
:param price: If set, the voucher will allow the sale of associated items for this price
|
||||
:type price: decimal.Decimal
|
||||
:param price_mode: Sets how this voucher affects a product's price. Can be ``none``, ``set``, ``subtract``
|
||||
or ``percent``.
|
||||
:type price_mode: str
|
||||
:param value: The value by which the price should be modified in the way specified by ``price_mode``.
|
||||
:type value: decimal.Decimal
|
||||
:param item: If set, the item to sell
|
||||
:type item: Item
|
||||
:param variation: If set, the variation to sell
|
||||
@@ -59,6 +65,13 @@ class Voucher(LoggedModel):
|
||||
* You need to either select a quota or an item
|
||||
* If you select an item that has variations but do not select a variation, you cannot set block_quota
|
||||
"""
|
||||
PRICE_MODES = (
|
||||
('none', _('No effect')),
|
||||
('set', _('Set product price to')),
|
||||
('subtract', _('Subtract from product price')),
|
||||
('percent', _('Reduce product price by (%)')),
|
||||
)
|
||||
|
||||
event = models.ForeignKey(
|
||||
Event,
|
||||
on_delete=models.CASCADE,
|
||||
@@ -98,10 +111,15 @@ class Voucher(LoggedModel):
|
||||
"If activated, a holder of this voucher code can buy tickets, even if there are none left."
|
||||
)
|
||||
)
|
||||
price = models.DecimalField(
|
||||
verbose_name=_("Set product price to"),
|
||||
price_mode = models.CharField(
|
||||
verbose_name=_("Price mode"),
|
||||
max_length=100,
|
||||
choices=PRICE_MODES,
|
||||
default='set'
|
||||
)
|
||||
value = models.DecimalField(
|
||||
verbose_name=_("Voucher value"),
|
||||
decimal_places=2, max_digits=10, null=True, blank=True,
|
||||
help_text=_('If empty, the product will cost its normal price.')
|
||||
)
|
||||
item = models.ForeignKey(
|
||||
Item, related_name='vouchers',
|
||||
@@ -208,3 +226,19 @@ class Voucher(LoggedModel):
|
||||
if self.valid_until and self.valid_until < now():
|
||||
return False
|
||||
return True
|
||||
|
||||
def calculate_price(self, original_price: Decimal) -> Decimal:
|
||||
"""
|
||||
Returns how the price given in original_price would be modified if this
|
||||
voucher is applied, i.e. replaced by a different price or reduced by a
|
||||
certain percentage. If the voucher does not modify the price, the
|
||||
original price will be returned.
|
||||
"""
|
||||
if self.value:
|
||||
if self.price_mode == 'set':
|
||||
return self.value
|
||||
elif self.price_mode == 'subtract':
|
||||
return original_price - self.value
|
||||
elif self.price_mode == 'percent':
|
||||
return round_decimal(original_price * (Decimal('100.00') - self.value) / Decimal('100.00'))
|
||||
return original_price
|
||||
|
||||
@@ -168,11 +168,10 @@ def _add_new_items(event: Event, items: List[dict],
|
||||
err = err or error_messages['in_part']
|
||||
quota_ok = min(quota_ok, avail[1])
|
||||
|
||||
if voucher and voucher.price is not None:
|
||||
price = voucher.price
|
||||
else:
|
||||
price = item.default_price if variation is None else (
|
||||
variation.default_price if variation.default_price is not None else item.default_price)
|
||||
price = item.default_price if variation is None else (
|
||||
variation.default_price if variation.default_price is not None else item.default_price)
|
||||
if voucher:
|
||||
price = voucher.calculate_price(price)
|
||||
|
||||
if item.free_price and 'price' in i and i['price'] is not None and i['price'] != "":
|
||||
custom_price = i['price']
|
||||
|
||||
@@ -82,11 +82,15 @@ def mail(email: str, subject: str, template: str,
|
||||
if order:
|
||||
body += "\r\n"
|
||||
body += _(
|
||||
"You can view your order details at the following URL:\r\n{orderurl}."
|
||||
).format(event=event.name, orderurl=build_absolute_uri(order.event, 'presale:event.order', kwargs={
|
||||
'order': order.code,
|
||||
'secret': order.secret
|
||||
}))
|
||||
"You can view your order details at the following URL:\n{orderurl}."
|
||||
).replace("\n", "\r\n").format(
|
||||
event=event.name, orderurl=build_absolute_uri(
|
||||
order.event, 'presale:event.order', kwargs={
|
||||
'order': order.code,
|
||||
'secret': order.secret
|
||||
}
|
||||
)
|
||||
)
|
||||
body += "\r\n"
|
||||
return mail_send([email], subject, body, sender, event.id if event else None, headers)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ from pretix.base.models import (
|
||||
CartPosition, Event, Item, ItemVariation, Order, OrderPosition, Quota,
|
||||
User, Voucher,
|
||||
)
|
||||
from pretix.base.models.orders import InvoiceAddress
|
||||
from pretix.base.models.orders import CachedTicket, InvoiceAddress
|
||||
from pretix.base.payment import BasePaymentProvider
|
||||
from pretix.base.services.async import ProfiledTask
|
||||
from pretix.base.services.invoices import (
|
||||
@@ -233,8 +233,7 @@ def _check_positions(event: Event, now_dt: datetime, positions: List[CartPositio
|
||||
err = err or error_messages['voucher_expired']
|
||||
cp.delete()
|
||||
continue
|
||||
if cp.voucher.price is not None:
|
||||
price = cp.voucher.price
|
||||
price = cp.voucher.calculate_price(price)
|
||||
|
||||
if price != cp.price and not (cp.item.free_price and cp.price > price):
|
||||
positions[i] = cp
|
||||
@@ -282,7 +281,7 @@ def _create_order(event: Event, email: str, positions: List[CartPosition], now_d
|
||||
|
||||
tz = pytz.timezone(event.settings.timezone)
|
||||
exp_by_date = now_dt.astimezone(tz) + timedelta(days=event.settings.get('payment_term_days', as_type=int))
|
||||
exp_by_date = exp_by_date.replace(hour=23, minute=59, second=59, microsecond=0)
|
||||
exp_by_date = exp_by_date.astimezone(tz).replace(hour=23, minute=59, second=59, microsecond=0)
|
||||
if event.settings.get('payment_term_weekdays'):
|
||||
if exp_by_date.weekday() == 5:
|
||||
exp_by_date += timedelta(days=2)
|
||||
@@ -579,9 +578,13 @@ class OrderChangeManager:
|
||||
self._perform_operations()
|
||||
self._recalculate_total_and_payment_fee()
|
||||
self._reissue_invoice()
|
||||
self._clear_tickets_cache()
|
||||
self._check_paid_to_free()
|
||||
self._notify_user()
|
||||
|
||||
def _clear_tickets_cache(self):
|
||||
CachedTicket.objects.filter(order_position__order=self.order).delete()
|
||||
|
||||
def _get_payment_provider(self):
|
||||
responses = register_payment_providers.send(self.order.event)
|
||||
pprov = None
|
||||
|
||||
@@ -105,6 +105,12 @@ class OrderPositionChangeForm(forms.Form):
|
||||
|
||||
|
||||
class OrderContactForm(forms.ModelForm):
|
||||
regenerate_secrets = forms.BooleanField(required=False, label=_('Invalidate secrets'),
|
||||
help_text=_('Regenerates the order and ticket secrets. You will '
|
||||
'need to re-send the link to the order page to the user and '
|
||||
'the user will need to download his tickets again. The old '
|
||||
'versions will be invalid.'))
|
||||
|
||||
class Meta:
|
||||
model = Order
|
||||
fields = ['email']
|
||||
|
||||
@@ -8,6 +8,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from pretix.base.forms import I18nModelForm
|
||||
from pretix.base.models import Item, ItemVariation, Quota, Voucher
|
||||
from pretix.base.models.vouchers import _generate_random_code
|
||||
|
||||
|
||||
class VoucherForm(I18nModelForm):
|
||||
@@ -22,8 +23,8 @@ class VoucherForm(I18nModelForm):
|
||||
model = Voucher
|
||||
localized_fields = '__all__'
|
||||
fields = [
|
||||
'code', 'valid_until', 'block_quota', 'allow_ignore_quota', 'price', 'tag',
|
||||
'comment', 'max_usages'
|
||||
'code', 'valid_until', 'block_quota', 'allow_ignore_quota', 'value', 'tag',
|
||||
'comment', 'max_usages', 'price_mode'
|
||||
]
|
||||
widgets = {
|
||||
'valid_until': forms.DateTimeInput(attrs={'class': 'datetimepicker'}),
|
||||
@@ -90,9 +91,8 @@ class VoucherForm(I18nModelForm):
|
||||
}
|
||||
)
|
||||
|
||||
if 'codes' in data:
|
||||
data['codes'] = [a.strip() for a in data.get('codes', '').strip().split("\n") if a]
|
||||
cnt = len(data['codes']) * data['max_usages']
|
||||
if 'number' in data:
|
||||
cnt = data['number'] * data['max_usages']
|
||||
else:
|
||||
cnt = data['max_usages']
|
||||
|
||||
@@ -174,21 +174,37 @@ class VoucherForm(I18nModelForm):
|
||||
|
||||
|
||||
class VoucherBulkForm(VoucherForm):
|
||||
codes = forms.CharField(
|
||||
widget=forms.Textarea,
|
||||
label=_("Codes"),
|
||||
help_text=_(
|
||||
"Add one voucher code per line. We suggest that you copy this list and save it into a file."
|
||||
),
|
||||
number = forms.IntegerField(
|
||||
label=_("Number"),
|
||||
required=True
|
||||
)
|
||||
itemvar = forms.ChoiceField(
|
||||
label=_("Product"),
|
||||
widget=forms.RadioSelect
|
||||
)
|
||||
price_mode = forms.ChoiceField(
|
||||
choices=Voucher.PRICE_MODES,
|
||||
)
|
||||
has_valid_until = forms.BooleanField()
|
||||
value_percent = forms.DecimalField(
|
||||
required=False,
|
||||
max_digits=10, decimal_places=2
|
||||
)
|
||||
value_subtract = forms.DecimalField(
|
||||
required=False,
|
||||
max_digits=10, decimal_places=2
|
||||
)
|
||||
value_set = forms.DecimalField(
|
||||
required=False,
|
||||
max_digits=10, decimal_places=2
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = Voucher
|
||||
localized_fields = '__all__'
|
||||
fields = [
|
||||
'valid_until', 'block_quota', 'allow_ignore_quota', 'price', 'tag', 'comment',
|
||||
'max_usages'
|
||||
'valid_until', 'block_quota', 'allow_ignore_quota', 'value', 'tag', 'comment',
|
||||
'max_usages', 'price_mode'
|
||||
]
|
||||
widgets = {
|
||||
'valid_until': forms.DateTimeInput(attrs={'class': 'datetimepicker'}),
|
||||
@@ -203,21 +219,35 @@ class VoucherBulkForm(VoucherForm):
|
||||
def clean(self):
|
||||
data = super().clean()
|
||||
|
||||
if Voucher.objects.filter(code__in=data['codes'], event=self.instance.event).exists():
|
||||
raise ValidationError(_('A voucher with one of this codes already exists.'))
|
||||
if data.get('has_valid_until', False) and not data.get('valid_until'):
|
||||
raise ValidationError(_('You did not specify an expiration date for the vouchers.'))
|
||||
|
||||
if data.get('price_mode', 'none') != 'none':
|
||||
if data.get('value_%s' % data['price_mode']) is None:
|
||||
raise ValidationError(_('You specified that the vouchers should modify the products price '
|
||||
'but did not specify a value.'))
|
||||
|
||||
return data
|
||||
|
||||
def save(self, event, *args, **kwargs):
|
||||
objs = []
|
||||
for code in self.cleaned_data['codes']:
|
||||
|
||||
codes = set()
|
||||
while len(codes) < self.cleaned_data['number']:
|
||||
new_codes = set()
|
||||
for i in range(min(self.cleaned_data['number'] - len(codes), 500)):
|
||||
# Work around SQLite's SQLITE_MAX_VARIABLE_NUMBER
|
||||
new_codes.add(_generate_random_code())
|
||||
new_codes -= set([v['code'] for v in Voucher.objects.filter(code__in=new_codes).values('code')])
|
||||
codes |= new_codes
|
||||
|
||||
for code in codes:
|
||||
obj = copy.copy(self.instance)
|
||||
obj.event = event
|
||||
obj.code = code
|
||||
data = dict(self.cleaned_data)
|
||||
data['code'] = code
|
||||
data['bulk'] = True
|
||||
del data['codes']
|
||||
obj.save()
|
||||
objs.append(obj)
|
||||
return objs
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<script type="text/javascript" src="{% static "pretixcontrol/js/sb-admin-2.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "pretixcontrol/js/ui/main.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "pretixcontrol/js/ui/quota.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "pretixcontrol/js/ui/voucher.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "pretixcontrol/js/ui/question.js" %}"></script>
|
||||
{% endcompress %}
|
||||
{{ html_head|safe }}
|
||||
|
||||
@@ -99,8 +99,8 @@
|
||||
<th>{{ total.num_canceled|togglesum }}</th>
|
||||
<th>{{ total.num_refunded|togglesum }}</th>
|
||||
<th>{{ total.num_expired|togglesum }}</th>
|
||||
<th>{{ total.num_paid|togglesum }}</th>
|
||||
<th>{{ total.num_pending|togglesum }}</th>
|
||||
<th>{{ total.num_paid|togglesum }}</th>
|
||||
<th>{{ total.num_total|togglesum }}</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
@@ -2,59 +2,139 @@
|
||||
{% load i18n %}
|
||||
{% load eventsignal %}
|
||||
{% load bootstrap3 %}
|
||||
{% load capture_tags %}
|
||||
{% block title %}{% trans "Voucher" %}{% endblock %}
|
||||
{% block inside %}
|
||||
<h1>{% trans "Create multiple voucher" %}</h1>
|
||||
<form action="" method="post" class="form-horizontal">
|
||||
<h1>{% trans "Create new vouchers" %}</h1>
|
||||
<form action="" method="post" class="form-inline" id="voucher-create">
|
||||
{% csrf_token %}
|
||||
{% capture as number_field silent %} {% bootstrap_field form.number layout="inline" %} {% endcapture %}
|
||||
{% capture as max_usages_field silent %} {% bootstrap_field form.max_usages layout="inline" %} {% endcapture %}
|
||||
{% capture as valid_until_field silent %} {% bootstrap_field form.valid_until layout="inline" %} {% endcapture %}
|
||||
{% capture as value_field_percent silent %} {% bootstrap_field form.value_percent layout="inline" %} {% endcapture %}
|
||||
{% capture as value_field_subtract silent %} {% bootstrap_field form.value_subtract layout="inline" %} {% endcapture %}
|
||||
{% capture as value_field_set silent %} {% bootstrap_field form.value_set layout="inline" %} {% endcapture %}
|
||||
|
||||
{% bootstrap_form_errors form %}
|
||||
<fieldset>
|
||||
<legend>{% trans "Voucher codes" %}</legend>
|
||||
<div class="form-group">
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control input-xs"
|
||||
id="voucher-bulk-codes-num"
|
||||
placeholder="{% trans "Number" %}">
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-default" type="button" id="voucher-bulk-codes-generate"
|
||||
data-rng-url="{% url 'control:event.vouchers.rng' organizer=request.event.organizer.slug event=request.event.slug %}">
|
||||
{% trans "Generate random codes" %}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="wizard-step" id="step-number">
|
||||
<div class="wizard-step-inner">
|
||||
<h4>{% trans "How many vouchers do you want to create?" %}</h4>
|
||||
<div class="form-line">
|
||||
{% blocktrans trimmed %}
|
||||
Create {{ number_field }} voucher codes. Each of them can be redeemed {{ max_usages_field }}
|
||||
times.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wizard-step" id="step-valid">
|
||||
<div class="wizard-step-inner">
|
||||
<h4>{% trans "How long should the vouchers be valid?" %}</h4>
|
||||
<div class="radio radio-alt">
|
||||
<label>
|
||||
<input type="radio" name="has_valid_until" value="" {% if request.POST and not "has_valid_until" in request.POST %}checked="checked"{% endif %}>
|
||||
{% trans "The whole presale period" %}
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio radio-alt">
|
||||
<label>
|
||||
<input type="radio" name="has_valid_until" value="on" {% if "on" == request.POST.has_valid_until %}checked="checked"{% endif %}>
|
||||
{% blocktrans trimmed %}
|
||||
Only valid until {{ valid_until_field }}
|
||||
{% endblocktrans %}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wizard-step" id="step-products">
|
||||
<div class="wizard-step-inner">
|
||||
<h4>{% trans "For which products should the vouchers be applicable?" %}</h4>
|
||||
{% bootstrap_field form.itemvar layout="inline" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wizard-step" id="step-price">
|
||||
<div class="wizard-step-inner">
|
||||
<h4>{% trans "Should the vouchers modify the product's price?" %}</h4>
|
||||
<div class="radio radio-alt">
|
||||
<label>
|
||||
<input type="radio" name="price_mode" value="none" {% if "none" == request.POST.price_mode %}checked="checked"{% endif %}>
|
||||
{% trans "No, just allow to buy this product" %}
|
||||
<span class="help-block">
|
||||
{% trans "This is useful if you have products that can only be bought using vouchers. It also allows you to just block quota for someone (see next step)." %}
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio radio-alt">
|
||||
<label>
|
||||
<input type="radio" name="price_mode" value="percent" {% if "percent" == request.POST.price_mode %}checked="checked"{% endif %}>
|
||||
{% blocktrans trimmed %}
|
||||
Reduce price by {{ value_field_percent }} %
|
||||
{% endblocktrans %}
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio radio-alt">
|
||||
<label>
|
||||
<input type="radio" name="price_mode" value="subtract" {% if "subtract" == request.POST.price_mode %}checked="checked"{% endif %}>
|
||||
{% blocktrans trimmed with currency=request.event.currency %}
|
||||
Reduce price by {{ value_field_subtract }} {{ currency }}
|
||||
{% endblocktrans %}
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio radio-alt">
|
||||
<label>
|
||||
<input type="radio" name="price_mode" value="set" {% if "set" == request.POST.price_mode %}checked="checked"{% endif %}>
|
||||
{% blocktrans trimmed with currency=request.event.currency %}
|
||||
Change price to {{ value_field_set }} {{ currency }}
|
||||
{% endblocktrans %}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wizard-step" id="step-block">
|
||||
<div class="wizard-step-inner">
|
||||
<h4>{% trans "Should the vouchers block quota?" %}</h4>
|
||||
<div class="radio radio-alt">
|
||||
<label>
|
||||
<input type="radio" name="block_quota" value="" {% if request.POST and not "block_quota" in request.POST %}checked="checked"{% endif %}>
|
||||
{% trans "No" %}
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio radio-alt">
|
||||
<label>
|
||||
<input type="radio" name="block_quota" value="on" {% if "on" == request.POST.block_quota %}checked="checked"{% endif %}>
|
||||
{% trans "Yes" %}
|
||||
<span class="help-block">
|
||||
{% trans "If you select this option, these vouchers will be guaranteed, i.e. the applicable quotas will be reduced in a way that these vouchers can be redeemed as long as they are valid, even if your event sells out otherwise." %}
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wizard-step" id="step-advanced">
|
||||
<div class="wizard-step-inner">
|
||||
<a href="#" id="wizard-advanced-show">Show advanced options</a>
|
||||
<div class="wizard-advanced">
|
||||
<h4>{% trans "Advanced options" %}</h4>
|
||||
{% bootstrap_field form.allow_ignore_quota %}
|
||||
<p><strong>{% trans "Comment" %}</strong></p>
|
||||
{% bootstrap_field form.comment layout="inline" form_group_class="comment" %}
|
||||
<div class="help-block">
|
||||
{% trans "The text entered in this field will not be visible to the user and is available for your convenience." %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% bootstrap_field form.codes layout="horizontal" %}
|
||||
{% bootstrap_field form.max_usages layout="horizontal" %}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{% trans "Voucher details" %}</legend>
|
||||
{% bootstrap_field form.valid_until layout="horizontal" %}
|
||||
{% bootstrap_field form.block_quota layout="horizontal" %}
|
||||
{% bootstrap_field form.allow_ignore_quota layout="horizontal" %}
|
||||
{% bootstrap_field form.price layout="horizontal" %}
|
||||
{% bootstrap_field form.itemvar layout="horizontal" %}
|
||||
<div class="form-group">
|
||||
<div class="col-md-9 col-md-offset-3">
|
||||
<div class="controls">
|
||||
<div class="alert alert-info">
|
||||
{% blocktrans trimmed %}
|
||||
If you choose "any product" for a specific quota and choose to reserve quota for this
|
||||
voucher above, the product can still be unavailable to the voucher holder if another quota
|
||||
associated with the product is sold out!
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% bootstrap_field form.tag layout="horizontal" %}
|
||||
{% bootstrap_field form.comment layout="horizontal" %}
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
{% eventsignal request.event "pretix.control.signals.voucher_form_html" form=form %}
|
||||
<div class="form-group submit-group">
|
||||
<div class="submit-group" id="step-save">
|
||||
<button type="submit" class="btn btn-primary btn-save">
|
||||
{% trans "Save" %}
|
||||
{% trans "Create" %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -27,7 +27,15 @@
|
||||
{% bootstrap_field form.valid_until layout="horizontal" %}
|
||||
{% bootstrap_field form.block_quota layout="horizontal" %}
|
||||
{% bootstrap_field form.allow_ignore_quota layout="horizontal" %}
|
||||
{% bootstrap_field form.price layout="horizontal" %}
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label" for="id_tag">{% trans "Price effect" %}</label>
|
||||
<div class="col-md-5">
|
||||
{% bootstrap_field form.price_mode show_label=False form_group_class="" %}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{% bootstrap_field form.value show_label=False form_group_class="" %}
|
||||
</div>
|
||||
</div>
|
||||
{% bootstrap_field form.itemvar layout="horizontal" %}
|
||||
<div class="form-group">
|
||||
<div class="col-md-9 col-md-offset-3">
|
||||
|
||||
@@ -37,17 +37,12 @@
|
||||
</p>
|
||||
|
||||
<a href="{% url "control:event.vouchers.add" organizer=request.event.organizer.slug event=request.event.slug %}"
|
||||
class="btn btn-primary btn-lg"><i class="fa fa-plus"></i> {% trans "Create a new voucher" %}</a>
|
||||
<a href="{% url "control:event.vouchers.bulk" organizer=request.event.organizer.slug event=request.event.slug %}"
|
||||
class="btn btn-primary btn-lg"><i class="fa fa-plus"></i> {% trans "Create multiple new vouchers" %}</a>
|
||||
class="btn btn-primary btn-lg"><i class="fa fa-plus"></i> {% trans "Create new vouchers" %}</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<p>
|
||||
<a href="{% url "control:event.vouchers.add" organizer=request.event.organizer.slug event=request.event.slug %}"
|
||||
class="btn btn-default"><i class="fa fa-plus"></i> {% trans "Create a new voucher" %}</a>
|
||||
<a href="{% url "control:event.vouchers.bulk" organizer=request.event.organizer.slug event=request.event.slug %}"
|
||||
class="btn btn-default"><i class="fa fa-plus"></i>
|
||||
{% trans "Create multiple new vouchers" %}</a>
|
||||
class="btn btn-default"><i class="fa fa-plus"></i> {% trans "Create new vouchers" %}</a>
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-quotas">
|
||||
|
||||
@@ -90,7 +90,6 @@ urlpatterns = [
|
||||
url(r'^vouchers/(?P<voucher>\d+)/delete$', vouchers.VoucherDelete.as_view(),
|
||||
name='event.voucher.delete'),
|
||||
url(r'^vouchers/add$', vouchers.VoucherCreate.as_view(), name='event.vouchers.add'),
|
||||
url(r'^vouchers/bulk_add$', vouchers.VoucherBulkCreate.as_view(), name='event.vouchers.bulk'),
|
||||
url(r'^orders/(?P<code>[0-9A-Z]+)/transition$', orders.OrderTransition.as_view(),
|
||||
name='event.order.transition'),
|
||||
url(r'^orders/(?P<code>[0-9A-Z]+)/resend$', orders.OrderResendLink.as_view(),
|
||||
|
||||
@@ -16,7 +16,7 @@ from django.views.generic.detail import SingleObjectMixin
|
||||
|
||||
from pretix.base.forms import I18nModelForm
|
||||
from pretix.base.models import (
|
||||
Event, EventPermission, Item, ItemVariation, User,
|
||||
CachedTicket, Event, EventPermission, Item, ItemVariation, User,
|
||||
)
|
||||
from pretix.base.services import tickets
|
||||
from pretix.base.services.invoices import build_preview_invoice_pdf
|
||||
@@ -450,6 +450,9 @@ class TicketSettings(EventPermissionRequiredMixin, FormView):
|
||||
for k in provider.form.changed_data
|
||||
}
|
||||
)
|
||||
CachedTicket.objects.filter(
|
||||
order_position__order__event=self.request.event, provider=provider.identifier
|
||||
).delete()
|
||||
else:
|
||||
success = False
|
||||
form = self.get_form(self.get_form_class())
|
||||
|
||||
@@ -18,8 +18,8 @@ from django.views.generic.edit import DeleteView
|
||||
|
||||
from pretix.base.forms import I18nFormSet
|
||||
from pretix.base.models import (
|
||||
Item, ItemCategory, ItemVariation, Order, Question, QuestionAnswer,
|
||||
QuestionOption, Quota,
|
||||
CachedTicket, Item, ItemCategory, ItemVariation, Order, Question,
|
||||
QuestionAnswer, QuestionOption, Quota,
|
||||
)
|
||||
from pretix.control.forms.item import (
|
||||
CategoryForm, ItemCreateForm, ItemUpdateForm, ItemVariationForm,
|
||||
@@ -787,6 +787,7 @@ class ItemUpdateGeneral(ItemDetailMixin, EventPermissionRequiredMixin, UpdateVie
|
||||
for k in form.changed_data
|
||||
}
|
||||
)
|
||||
CachedTicket.objects.filter(order_position__item=self.item).delete()
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ from django.views.generic import DetailView, ListView, TemplateView, View
|
||||
|
||||
from pretix.base.i18n import language
|
||||
from pretix.base.models import (
|
||||
CachedFile, Invoice, Item, ItemVariation, Order, Quota,
|
||||
CachedFile, CachedTicket, Invoice, Item, ItemVariation, Order, Quota,
|
||||
generate_position_secret, generate_secret,
|
||||
)
|
||||
from pretix.base.services.export import export
|
||||
from pretix.base.services.invoices import (
|
||||
@@ -528,8 +529,16 @@ class OrderContactChange(OrderView):
|
||||
if self.form.is_valid():
|
||||
self.order.log_action('pretix.event.order.contact.changed', {
|
||||
'old_email': self.order.email,
|
||||
'new_email': self.form.cleaned_data['email']
|
||||
'new_email': self.form.cleaned_data['email'],
|
||||
'regenerate_secrets': self.form.cleaned_data['regenerate_secrets']
|
||||
})
|
||||
if self.form.cleaned_data['regenerate_secrets']:
|
||||
self.order.secret = generate_secret()
|
||||
for op in self.order.positions.all():
|
||||
op.secret = generate_position_secret()
|
||||
op.save()
|
||||
CachedTicket.objects.filter(order_position__order=self.order).delete()
|
||||
|
||||
self.form.save()
|
||||
messages.success(self.request, _('The order has been changed.'))
|
||||
return redirect(self.get_order_url())
|
||||
|
||||
@@ -59,7 +59,7 @@ class VoucherList(EventPermissionRequiredMixin, ListView):
|
||||
|
||||
headers = [
|
||||
_('Voucher code'), _('Valid until'), _('Product'), _('Reserve quota'), _('Bypass quota'),
|
||||
_('Price'), _('Tag'), _('Redeemed'), _('Maximum usages')
|
||||
_('Price effect'), _('Value'), _('Tag'), _('Redeemed'), _('Maximum usages')
|
||||
]
|
||||
writer.writerow(headers)
|
||||
|
||||
@@ -77,7 +77,8 @@ class VoucherList(EventPermissionRequiredMixin, ListView):
|
||||
prod,
|
||||
_("Yes") if v.block_quota else _("No"),
|
||||
_("Yes") if v.allow_ignore_quota else _("No"),
|
||||
str(v.price) if v.price else "",
|
||||
v.get_price_mode_display(),
|
||||
str(v.value) if v.value else "",
|
||||
v.tag,
|
||||
str(v.redeemed),
|
||||
str(v.max_usages)
|
||||
@@ -188,44 +189,6 @@ class VoucherUpdate(EventPermissionRequiredMixin, UpdateView):
|
||||
|
||||
|
||||
class VoucherCreate(EventPermissionRequiredMixin, CreateView):
|
||||
model = Voucher
|
||||
template_name = 'pretixcontrol/vouchers/detail.html'
|
||||
permission = 'can_change_vouchers'
|
||||
context_object_name = 'voucher'
|
||||
|
||||
def get_form_class(self):
|
||||
form_class = VoucherForm
|
||||
for receiver, response in voucher_form_class.send(self.request.event, cls=form_class):
|
||||
if response:
|
||||
form_class = response
|
||||
return form_class
|
||||
|
||||
def get_success_url(self) -> str:
|
||||
return reverse('control:event.vouchers', kwargs={
|
||||
'organizer': self.request.event.organizer.slug,
|
||||
'event': self.request.event.slug,
|
||||
})
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs['instance'] = Voucher(event=self.request.event)
|
||||
return kwargs
|
||||
|
||||
@transaction.atomic
|
||||
def form_valid(self, form):
|
||||
form.instance.event = self.request.event
|
||||
messages.success(self.request, _('The new voucher has been created.'))
|
||||
ret = super().form_valid(form)
|
||||
form.instance.log_action('pretix.voucher.added', data=dict(form.cleaned_data), user=self.request.user)
|
||||
return ret
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
# TODO: Transform this into an asynchronous call?
|
||||
with request.event.lock():
|
||||
return super().post(request, *args, **kwargs)
|
||||
|
||||
|
||||
class VoucherBulkCreate(EventPermissionRequiredMixin, CreateView):
|
||||
model = Voucher
|
||||
template_name = 'pretixcontrol/vouchers/bulk.html'
|
||||
permission = 'can_change_vouchers'
|
||||
@@ -240,6 +203,11 @@ class VoucherBulkCreate(EventPermissionRequiredMixin, CreateView):
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs['instance'] = Voucher(event=self.request.event)
|
||||
initial = {
|
||||
}
|
||||
if 'initial' in kwargs:
|
||||
initial.update(kwargs['initial'])
|
||||
kwargs['initial'] = initial
|
||||
return kwargs
|
||||
|
||||
@transaction.atomic
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-11-08 19:21+0000\n"
|
||||
"PO-Revision-Date: 2016-11-08 20:23+0100\n"
|
||||
"POT-Creation-Date: 2016-11-27 18:45+0000\n"
|
||||
"PO-Revision-Date: 2016-11-27 19:46+0100\n"
|
||||
"Last-Translator: Raphael Michel <michel@rami.io>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: de\n"
|
||||
@@ -16,7 +16,7 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: Poedit 1.8.9\n"
|
||||
"X-Generator: Poedit 1.8.11\n"
|
||||
|
||||
#: pretix/plugins/banktransfer/static/pretixplugins/banktransfer/ui.js:53
|
||||
#: pretix/plugins/banktransfer/static/pretixplugins/banktransfer/ui.js:59
|
||||
@@ -46,7 +46,7 @@ msgstr "Gesamtumsatz"
|
||||
msgid "Contacting Stripe …"
|
||||
msgstr "Kontaktiere Stripe …"
|
||||
|
||||
#: static/pretixcontrol/js/ui/main.js:28 static/pretixpresale/js/ui/main.js:57
|
||||
#: static/pretixcontrol/js/ui/main.js:28 static/pretixpresale/js/ui/main.js:99
|
||||
msgid "Close message"
|
||||
msgstr "Schließen"
|
||||
|
||||
@@ -63,17 +63,22 @@ msgid "Count"
|
||||
msgstr "Anzahl"
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:27
|
||||
msgid "Your request has been queued on the server and will now be processed."
|
||||
#: static/pretixpresale/js/ui/asynctask.js:62
|
||||
msgid ""
|
||||
"Your request has been queued on the server and will now be processed. If "
|
||||
"this takes longer than two minutes, please contact us or go back in your "
|
||||
"browser and try again."
|
||||
msgstr ""
|
||||
"Ihre Anfrage befindet sich beim Server in der Warteschlange und wird nun "
|
||||
"verarbeitet."
|
||||
"Ihre Anfrage ist auf dem Server angekommen und wird nun verarbeitet. Wenn "
|
||||
"dies länger als zwei Minuten dauert, kontaktieren Sie uns bitte oder gehen "
|
||||
"Sie in Ihrem Browser einen Schritt zurück und versuchen es erneut."
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:40
|
||||
#: static/pretixpresale/js/ui/asynctask.js:74
|
||||
#: static/pretixpresale/js/ui/asynctask.js:41
|
||||
#: static/pretixpresale/js/ui/asynctask.js:83
|
||||
msgid "An error of type {code} occured."
|
||||
msgstr "Ein Fehler ist aufgetreten. Fehlercode: {code}"
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:43
|
||||
#: static/pretixpresale/js/ui/asynctask.js:44
|
||||
msgid ""
|
||||
"We currenctly cannot reach the server, but we keep trying. Last error code: "
|
||||
"{code}"
|
||||
@@ -81,17 +86,31 @@ msgstr ""
|
||||
"Wir können den Server aktuell nicht erreichen, versuchen es aber weiter. "
|
||||
"Letzter Fehlercode: {code}"
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:77
|
||||
#: static/pretixpresale/js/ui/asynctask.js:74
|
||||
msgid "The request took to long. Please try again."
|
||||
msgstr "Diese Anfrage hat zu lange gedauert. Bitte erneut versuchen."
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:86
|
||||
msgid ""
|
||||
"We currenctly cannot reach the server. Please try again. Error code: {code}"
|
||||
msgstr ""
|
||||
"Wir können den Server aktuell nicht erreichen. Bitte versuchen Sie es noch "
|
||||
"einmal. Fehlercode: {code}"
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:92
|
||||
#: static/pretixpresale/js/ui/asynctask.js:101
|
||||
msgid "We are processing your request …"
|
||||
msgstr "Wir verarbeiten deine Anfrage …"
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:102
|
||||
msgid ""
|
||||
"We are currently sending your request to the server. If this takes longer "
|
||||
"than one minute, please check your internet connection and then reload this "
|
||||
"page and try again."
|
||||
msgstr ""
|
||||
"Ihre Anfrage wird an den Server gesendet. Wenn dies länger als eine Minute "
|
||||
"dauert, prüfen Sie bitte Ihre Internetverbindung. Danach können Sie diese "
|
||||
"Seite neu laden und es erneut versuchen."
|
||||
|
||||
#: static/pretixpresale/js/ui/cart.js:10
|
||||
msgid "The items in your cart are no longer reserved for you."
|
||||
msgstr "Die Produkte in Ihrem Warenkorb sind nicht mehr für Sie reserviert."
|
||||
@@ -103,3 +122,9 @@ msgstr[0] ""
|
||||
"Die Produkte in Ihrem Warenkorb sind noch eine Minute für Sie reserviert."
|
||||
msgstr[1] ""
|
||||
"Die Produkte in Ihrem Warenkorb sind noch {num} Minuten für Sie reserviert."
|
||||
|
||||
#~ msgid ""
|
||||
#~ "Your request has been queued on the server and will now be processed."
|
||||
#~ msgstr ""
|
||||
#~ "Ihre Anfrage befindet sich beim Server in der Warteschlange und wird nun "
|
||||
#~ "verarbeitet."
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-11-08 19:21+0000\n"
|
||||
"PO-Revision-Date: 2016-11-08 20:22+0100\n"
|
||||
"POT-Creation-Date: 2016-11-27 18:45+0000\n"
|
||||
"PO-Revision-Date: 2016-11-27 19:52+0100\n"
|
||||
"Last-Translator: Raphael Michel <michel@rami.io>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: de\n"
|
||||
@@ -16,7 +16,7 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: Poedit 1.8.9\n"
|
||||
"X-Generator: Poedit 1.8.11\n"
|
||||
|
||||
#: pretix/plugins/banktransfer/static/pretixplugins/banktransfer/ui.js:53
|
||||
#: pretix/plugins/banktransfer/static/pretixplugins/banktransfer/ui.js:59
|
||||
@@ -46,7 +46,7 @@ msgstr "Gesamtumsatz"
|
||||
msgid "Contacting Stripe …"
|
||||
msgstr "Kontaktiere Stripe …"
|
||||
|
||||
#: static/pretixcontrol/js/ui/main.js:28 static/pretixpresale/js/ui/main.js:57
|
||||
#: static/pretixcontrol/js/ui/main.js:28 static/pretixpresale/js/ui/main.js:99
|
||||
msgid "Close message"
|
||||
msgstr "Schließen"
|
||||
|
||||
@@ -63,17 +63,22 @@ msgid "Count"
|
||||
msgstr "Anzahl"
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:27
|
||||
msgid "Your request has been queued on the server and will now be processed."
|
||||
#: static/pretixpresale/js/ui/asynctask.js:62
|
||||
msgid ""
|
||||
"Your request has been queued on the server and will now be processed. If "
|
||||
"this takes longer than two minutes, please contact us or go back in your "
|
||||
"browser and try again."
|
||||
msgstr ""
|
||||
"Deine Anfrage befindet sich beim Server in der Warteschlange und wird nun "
|
||||
"verarbeitet."
|
||||
"Deine Anfrage ist auf dem Server angekommen und wird nun verarbeitet. Wenn "
|
||||
"dies länger als zwei Minuten dauert, kontaktiere uns bitte oder gehe in "
|
||||
"deinem Browser einen Schritt zurück und versuche es erneut."
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:40
|
||||
#: static/pretixpresale/js/ui/asynctask.js:74
|
||||
#: static/pretixpresale/js/ui/asynctask.js:41
|
||||
#: static/pretixpresale/js/ui/asynctask.js:83
|
||||
msgid "An error of type {code} occured."
|
||||
msgstr "Ein Fehler ist aufgetreten. Fehlercode: {code}"
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:43
|
||||
#: static/pretixpresale/js/ui/asynctask.js:44
|
||||
msgid ""
|
||||
"We currenctly cannot reach the server, but we keep trying. Last error code: "
|
||||
"{code}"
|
||||
@@ -81,17 +86,31 @@ msgstr ""
|
||||
"Wir können den Server aktuell nicht erreichen, versuchen es aber weiter. "
|
||||
"Letzter Fehlercode: {code}"
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:77
|
||||
#: static/pretixpresale/js/ui/asynctask.js:74
|
||||
msgid "The request took to long. Please try again."
|
||||
msgstr "Diese Anfrage hat zu lange gedauert. Bitte erneut versuchen."
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:86
|
||||
msgid ""
|
||||
"We currenctly cannot reach the server. Please try again. Error code: {code}"
|
||||
msgstr ""
|
||||
"Wir können den Server aktuell nicht erreichen. Bitte versuche es noch "
|
||||
"einmal. Fehlercode: {code}"
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:92
|
||||
#: static/pretixpresale/js/ui/asynctask.js:101
|
||||
msgid "We are processing your request …"
|
||||
msgstr "Wir verarbeiten deine Anfrage …"
|
||||
|
||||
#: static/pretixpresale/js/ui/asynctask.js:102
|
||||
msgid ""
|
||||
"We are currently sending your request to the server. If this takes longer "
|
||||
"than one minute, please check your internet connection and then reload this "
|
||||
"page and try again."
|
||||
msgstr ""
|
||||
"Deine Anfrage wird an den Server gesendet. Wenn dies länger als eine Minute "
|
||||
"dauert, prüfe bitte deine Internetverbindung. Danach kannst du diese Seite "
|
||||
"neu laden und es erneut versuchen."
|
||||
|
||||
#: static/pretixpresale/js/ui/cart.js:10
|
||||
msgid "The items in your cart are no longer reserved for you."
|
||||
msgstr "Die Produkte in deinem Warenkorb sind nicht mehr für dich reserviert."
|
||||
@@ -103,3 +122,9 @@ msgstr[0] ""
|
||||
"Die Produkte in deinem Warenkorb sind noch eine Minute für dich reserviert."
|
||||
msgstr[1] ""
|
||||
"Die Produkte in deinem Warenkorb sind noch {num} Minuten für dich reserviert."
|
||||
|
||||
#~ msgid ""
|
||||
#~ "Your request has been queued on the server and will now be processed."
|
||||
#~ msgstr ""
|
||||
#~ "Deine Anfrage befindet sich beim Server in der Warteschlange und wird nun "
|
||||
#~ "verarbeitet."
|
||||
|
||||
@@ -64,23 +64,6 @@ class Paypal(BasePaymentProvider):
|
||||
|
||||
def checkout_prepare(self, request, cart):
|
||||
self.init_api()
|
||||
items = []
|
||||
for cp in cart['positions']:
|
||||
items.append({
|
||||
"name": str(cp.item.name),
|
||||
"description": str(cp.variation) if cp.variation else "",
|
||||
"quantity": cp.count,
|
||||
"price": str(cp.price),
|
||||
"currency": request.event.currency
|
||||
})
|
||||
if cart['payment_fee']:
|
||||
items.append({
|
||||
"name": __('Payment method fee'),
|
||||
"description": "",
|
||||
"quantity": 1,
|
||||
"currency": request.event.currency,
|
||||
"price": str(cart['payment_fee'])
|
||||
})
|
||||
payment = paypalrestsdk.Payment({
|
||||
'intent': 'sale',
|
||||
'payer': {
|
||||
@@ -93,13 +76,20 @@ class Paypal(BasePaymentProvider):
|
||||
"transactions": [
|
||||
{
|
||||
"item_list": {
|
||||
"items": items
|
||||
"items": [
|
||||
{
|
||||
"name": __('Order for %s') % str(request.event),
|
||||
"quantity": 1,
|
||||
"price": str(cart['total']),
|
||||
"currency": request.event.currency
|
||||
}
|
||||
]
|
||||
},
|
||||
"amount": {
|
||||
"currency": request.event.currency,
|
||||
"total": str(cart['total'])
|
||||
},
|
||||
"description": __('Event tickets for %s') % request.event.name
|
||||
"description": __('Event tickets for {event}').format(event=request.event.name)
|
||||
}
|
||||
]
|
||||
})
|
||||
@@ -114,7 +104,6 @@ class Paypal(BasePaymentProvider):
|
||||
logger.error('Invalid payment state: ' + str(payment))
|
||||
return
|
||||
request.session['payment_paypal_id'] = payment.id
|
||||
request.session['payment_paypal_event'] = self.event.id
|
||||
for link in payment.links:
|
||||
if link.method == "REDIRECT" and link.rel == "approval_url":
|
||||
return str(link.href)
|
||||
@@ -164,6 +153,30 @@ class Paypal(BasePaymentProvider):
|
||||
return self._execute_payment(payment, request, order)
|
||||
|
||||
def _execute_payment(self, payment, request, order):
|
||||
payment.replace([
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/transactions/0/item_list",
|
||||
"value": {
|
||||
"items": [
|
||||
{
|
||||
"name": __('Order {slug}-{code}').format(slug=self.event.slug.upper(), code=order.code),
|
||||
"quantity": 1,
|
||||
"price": str(order.total),
|
||||
"currency": order.event.currency
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"op": "replace",
|
||||
"path": "/transactions/0/description",
|
||||
"value": __('Order {order} for {event}').format(
|
||||
event=request.event.name,
|
||||
order=order.code
|
||||
)
|
||||
}
|
||||
])
|
||||
payment.execute({"payer_id": request.session.get('payment_paypal_payer')})
|
||||
|
||||
if payment.state == 'pending':
|
||||
@@ -262,7 +275,7 @@ class Paypal(BasePaymentProvider):
|
||||
"item_list": {
|
||||
"items": [
|
||||
{
|
||||
"name": 'Order %s' % order.code,
|
||||
"name": __('Order {slug}-{code}').format(slug=self.event.slug.upper(), code=order.code),
|
||||
"quantity": 1,
|
||||
"price": str(order.total),
|
||||
"currency": order.event.currency
|
||||
@@ -273,7 +286,10 @@ class Paypal(BasePaymentProvider):
|
||||
"currency": request.event.currency,
|
||||
"total": str(order.total)
|
||||
},
|
||||
"description": __('Event tickets for %s') % request.event.name
|
||||
"description": __('Order {order} for {event}').format(
|
||||
event=request.event.name,
|
||||
order=order.code
|
||||
)
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
@@ -4,41 +4,48 @@ from django.contrib import messages
|
||||
from django.shortcuts import redirect
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from pretix.base.models import Event, Order
|
||||
from pretix.base.models import Order
|
||||
from pretix.multidomain.urlreverse import eventreverse
|
||||
from pretix.plugins.paypal.payment import Paypal
|
||||
from pretix.presale.utils import event_view
|
||||
|
||||
logger = logging.getLogger('pretix.plugins.paypal')
|
||||
|
||||
|
||||
def success(request, organizer=None, event=None):
|
||||
@event_view(require_live=False)
|
||||
def success(request, *args, **kwargs):
|
||||
pid = request.GET.get('paymentId')
|
||||
token = request.GET.get('token')
|
||||
payer = request.GET.get('PayerID')
|
||||
if pid == request.session.get('payment_paypal_id', None):
|
||||
request.session['payment_paypal_token'] = token
|
||||
request.session['payment_paypal_payer'] = payer
|
||||
try:
|
||||
event = Event.objects.get(id=request.session['payment_paypal_event'])
|
||||
if request.session.get('payment_paypal_order'):
|
||||
prov = Paypal(event)
|
||||
order = Order.objects.get(pk=request.session.get('payment_paypal_order'))
|
||||
resp = prov.payment_perform(request, order)
|
||||
return redirect(resp or eventreverse(event, 'presale:event.order', kwargs={
|
||||
'order': order.code,
|
||||
'secret': order.secret
|
||||
}) + '?paid=yes')
|
||||
return redirect(eventreverse(event, 'presale:event.checkout', kwargs={'step': 'confirm'}))
|
||||
except Event.DoesNotExist:
|
||||
pass # TODO: Handle this
|
||||
request.session['payment_paypal_token'] = token
|
||||
request.session['payment_paypal_payer'] = payer
|
||||
|
||||
if request.session.get('payment_paypal_order'):
|
||||
order = Order.objects.get(pk=request.session.get('payment_paypal_order'))
|
||||
else:
|
||||
pass # TODO: Handle this
|
||||
order = None
|
||||
|
||||
if pid == request.session.get('payment_paypal_id', None):
|
||||
if order:
|
||||
prov = Paypal(request.event)
|
||||
resp = prov.payment_perform(request, order)
|
||||
if resp:
|
||||
return resp
|
||||
else:
|
||||
messages.error(request, _('Invalid response from PayPal received.'))
|
||||
logger.error('Session did not contain payment_paypal_id')
|
||||
return redirect(eventreverse(request.event, 'presale:event.checkout', kwargs={'step': 'payment'}))
|
||||
|
||||
if order:
|
||||
return redirect(eventreverse(request.event, 'presale:event.order', kwargs={
|
||||
'order': order.code,
|
||||
'secret': order.secret
|
||||
}) + ('?paid=yes' if order.status == Order.STATUS_PAID else ''))
|
||||
else:
|
||||
return redirect(eventreverse(request.event, 'presale:event.checkout', kwargs={'step': 'confirm'}))
|
||||
|
||||
|
||||
def abort(request, organizer=None, event=None):
|
||||
@event_view(require_live=False)
|
||||
def abort(request, *args, **kwargs):
|
||||
messages.error(request, _('It looks like you canceled the PayPal payment'))
|
||||
try:
|
||||
event = Event.objects.get(id=request.session['payment_paypal_event'])
|
||||
return redirect(eventreverse(event, 'presale:event.checkout', kwargs={'step': 'payment'}))
|
||||
except Event.DoesNotExist:
|
||||
pass # TODO: Handle this
|
||||
return redirect(eventreverse(request.event, 'presale:event.checkout', kwargs={'step': 'payment'}))
|
||||
|
||||
@@ -219,8 +219,8 @@ class OverviewReport(Report):
|
||||
str(total['num_canceled'][0]), str(total['num_canceled'][1]),
|
||||
str(total['num_refunded'][0]), str(total['num_refunded'][1]),
|
||||
str(total['num_expired'][0]), str(total['num_expired'][1]),
|
||||
str(total['num_paid'][0]), str(total['num_paid'][1]),
|
||||
str(total['num_pending'][0]), str(total['num_pending'][1]),
|
||||
str(total['num_paid'][0]), str(total['num_paid'][1]),
|
||||
str(total['num_total'][0]), str(total['num_total'][1]),
|
||||
])
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.decorators.http import require_POST
|
||||
|
||||
from pretix.base.models import Order
|
||||
from pretix.base.services.orders import mark_order_refunded
|
||||
from pretix.base.services.orders import mark_order_paid, mark_order_refunded
|
||||
from pretix.plugins.stripe.payment import Stripe
|
||||
from pretix.presale.utils import event_view
|
||||
|
||||
@@ -54,7 +54,10 @@ def webhook(request, *args, **kwargs):
|
||||
|
||||
order.log_action('pretix.plugins.stripe.event', data=event_json)
|
||||
|
||||
if order.status == Order.STATUS_PAID and (charge['refunds']['total_count'] or charge['dispute']):
|
||||
is_refund = charge['refunds']['total_count'] or charge['dispute']
|
||||
if order.status == Order.STATUS_PAID and is_refund:
|
||||
mark_order_refunded(order, user=None)
|
||||
elif order.status == Order.STATUS_PENDING and charge['status'] == 'succeeded' and not is_refund:
|
||||
mark_order_paid(order, user=None)
|
||||
|
||||
return HttpResponse(status=200)
|
||||
|
||||
@@ -198,20 +198,16 @@ class RedeemView(EventViewMixin, TemplateView):
|
||||
item.cached_availability = (Quota.AVAILABILITY_OK, 1)
|
||||
else:
|
||||
item.cached_availability = item.check_quotas()
|
||||
if self.voucher.price is not None:
|
||||
item.price = self.voucher.price
|
||||
else:
|
||||
item.price = item.default_price
|
||||
item.price = self.voucher.calculate_price(item.default_price)
|
||||
else:
|
||||
for var in item.available_variations:
|
||||
if self.voucher.allow_ignore_quota or self.voucher.block_quota:
|
||||
var.cached_availability = (Quota.AVAILABILITY_OK, 1)
|
||||
else:
|
||||
var.cached_availability = list(var.check_quotas())
|
||||
if self.voucher.price is not None:
|
||||
var.price = self.voucher.price
|
||||
else:
|
||||
var.price = var.default_price if var.default_price is not None else item.default_price
|
||||
var.price = self.voucher.calculate_price(
|
||||
var.default_price if var.default_price is not None else item.default_price
|
||||
)
|
||||
|
||||
if len(item.available_variations) > 0:
|
||||
item.min_price = min([v.price for v in item.available_variations])
|
||||
|
||||
@@ -401,6 +401,8 @@ class OrderModify(EventViewMixin, OrderDetailMixin, QuestionsViewMixin, Template
|
||||
success_message = ('Your invoice address has been updated. Please contact us if you need us '
|
||||
'to regenerate your invoice.')
|
||||
messages.success(self.request, _(success_message))
|
||||
|
||||
CachedTicket.objects.filter(order_position__order=self.order).delete()
|
||||
return redirect(self.get_order_url())
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
||||
@@ -96,8 +96,7 @@ METRICS_PASSPHRASE = config.get('metrics', 'passphrase', fallback="")
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||
'LOCATION': 'unique-snowflake',
|
||||
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
|
||||
}
|
||||
}
|
||||
REAL_CACHE_USED = False
|
||||
@@ -194,6 +193,7 @@ INSTALLED_APPS = [
|
||||
'django_otp.plugins.otp_totp',
|
||||
'django_otp.plugins.otp_static',
|
||||
'statici18n',
|
||||
'capture_tag',
|
||||
]
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
paypalrestsdk>=1.9,<1.10,<2.0
|
||||
paypalrestsdk==1.12.*
|
||||
pycparser==2.13 # https://github.com/eliben/pycparser/issues/147
|
||||
|
||||
@@ -17,6 +17,7 @@ python-u2flib-server==4.*
|
||||
# https://github.com/celery/celery/pull/3199
|
||||
git+https://github.com/pretix/celery.git@pretix#egg=celery
|
||||
django-statici18n==1.2.*
|
||||
django-capture-tag==1.0
|
||||
|
||||
# Deployment / static file compilation requirements
|
||||
BeautifulSoup4
|
||||
|
||||
@@ -62,7 +62,8 @@ setup(
|
||||
'easy-thumbnails>=2.2,<3'
|
||||
'PyPDF2', 'BeautifulSoup4', 'html5lib',
|
||||
'slimit', 'lxml', 'static3==0.6.1', 'dj-static', 'chardet',
|
||||
'csscompressor', 'mt-940', 'django-markup', 'markdown'
|
||||
'csscompressor', 'mt-940', 'django-markup', 'markdown',
|
||||
'django-capture-tag'
|
||||
],
|
||||
extras_require={
|
||||
'dev': ['django-debug-toolbar>=1.3.0,<2.0'],
|
||||
|
||||
82
src/static/pretixcontrol/js/ui/voucher.js
Normal file
82
src/static/pretixcontrol/js/ui/voucher.js
Normal file
@@ -0,0 +1,82 @@
|
||||
/*globals $, Morris, gettext*/
|
||||
$(function () {
|
||||
if (!$("#voucher-create").length) {
|
||||
return;
|
||||
}
|
||||
|
||||
function show_step(state_el) {
|
||||
var was_visible = state_el.is(':visible');
|
||||
state_el.animate({
|
||||
'height': 'show',
|
||||
'opacity': 'show',
|
||||
'padding-top': 'show',
|
||||
'padding-bottom': 'show',
|
||||
'margin-top': 'show',
|
||||
'margin-bottom': 'show'
|
||||
}, 400);
|
||||
var offset = state_el.offset();
|
||||
var body = $("html, body");
|
||||
if (!was_visible && offset.top > $("body").scrollTop() + $(window).height() - 160) {
|
||||
body.animate({scrollTop: offset.top + 200}, '400', 'swing');
|
||||
}
|
||||
}
|
||||
|
||||
if ($(".alert-danger").length === 0) {
|
||||
$(".wizard-step, .wizard-advanced, #step-save").hide();
|
||||
$(".wizard-step").first().show();
|
||||
}
|
||||
|
||||
$("#id_number, #id_max_usages").on("change keydown keyup", function () {
|
||||
if ($("#id_number").val() && $("#id_max_usages").val()) {
|
||||
show_step($("#step-valid"));
|
||||
}
|
||||
});
|
||||
|
||||
$("#id_valid_until").on("focus change", function () {
|
||||
$("input[name=has_valid_until][value=no]").prop("checked", false);
|
||||
$("input[name=has_valid_until][value=yes]").prop("checked", true);
|
||||
}).on("change dp.change", function () {
|
||||
if ($("input[name=has_valid_until][value=no]").prop("checked") || $("#id_valid_until").val()) {
|
||||
show_step($("#step-products"));
|
||||
}
|
||||
});
|
||||
|
||||
$("input[name=has_valid_until]").on("change", function () {
|
||||
if ($("input[name=has_valid_until]").not("[value=on]").prop("checked") || $("#id_valid_until").val()) {
|
||||
show_step($("#step-products"));
|
||||
} else {
|
||||
$("#id_valid_until").focus();
|
||||
}
|
||||
});
|
||||
|
||||
$("input[name=itemvar]").on("change", function () {
|
||||
show_step($("#step-price"));
|
||||
});
|
||||
|
||||
$("#step-price input").on("change keydown keyup", function () {
|
||||
var mode = $("input[name=price_mode]:checked").val();
|
||||
var show_next = (mode === 'none' || $("input[name='value_" + mode + "']").val());
|
||||
if (show_next) {
|
||||
show_step($("#step-block"));
|
||||
} else {
|
||||
$("input[name='value_" + mode + "']").focus();
|
||||
}
|
||||
});
|
||||
$("#step-price input[type=text]").on("focus change keyup keydown", function () {
|
||||
$("#step-price input[type=radio]").prop("checked", false);
|
||||
$(this).closest(".radio").find("input[type=radio]").prop("checked", true);
|
||||
});
|
||||
|
||||
$("input[name=block_quota]").on("change", function () {
|
||||
show_step($("#step-advanced"));
|
||||
show_step($("#step-save"));
|
||||
});
|
||||
|
||||
$("#wizard-advanced-show").on("click", function (e) {
|
||||
show_step($(".wizard-advanced"));
|
||||
$(this).animate({'opacity': '0'}, 400);
|
||||
e.preventDefault();
|
||||
return true;
|
||||
});
|
||||
|
||||
});
|
||||
@@ -117,3 +117,4 @@ div[data-formset-body], div[data-formset-form], div[data-nested-formset-form], d
|
||||
.ticketoutput-panel .panel-title {
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
|
||||
35
src/static/pretixcontrol/scss/_vouchers.scss
Normal file
35
src/static/pretixcontrol/scss/_vouchers.scss
Normal file
@@ -0,0 +1,35 @@
|
||||
#voucher-create {
|
||||
.wizard-step {
|
||||
}
|
||||
.wizard-step-inner {
|
||||
padding: 20px 0;
|
||||
}
|
||||
#id_number, #id_max_usages {
|
||||
width: 75px;
|
||||
}
|
||||
.price {
|
||||
width: 100px;
|
||||
}
|
||||
.form-options {
|
||||
list-style: none;
|
||||
padding: 10px;
|
||||
}
|
||||
.radio {
|
||||
display: block;
|
||||
line-height: 24px;
|
||||
}
|
||||
.radio-alt {
|
||||
line-height: 40px;
|
||||
}
|
||||
.radio .help-block {
|
||||
margin: 0;
|
||||
padding-left: 17px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.comment {
|
||||
display: block;
|
||||
textarea {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ $fa-font-path: static("fontawesome/fonts");
|
||||
@import "_flags.scss";
|
||||
@import "_orders.scss";
|
||||
@import "_dashboard.scss";
|
||||
@import "_vouchers.scss";
|
||||
@import "../../pretixbase/scss/webfont.scss";
|
||||
|
||||
footer {
|
||||
|
||||
@@ -135,7 +135,6 @@ def test_metrics_view(monkeypatch, client):
|
||||
metricsview.metrics.http_requests_total.inc(counter_value, code="200", handler="/foo", method="GET")
|
||||
|
||||
# test unauthorized-page
|
||||
assert "You are not authorized" in metricsview.serve_metrics(None).content.decode('utf-8')
|
||||
assert "You are not authorized" in client.get('/metrics').content.decode('utf-8')
|
||||
assert "{} {}".format(fullname, counter_value) not in client.get('/metrics')
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import datetime
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.files.storage import default_storage
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
@@ -244,6 +247,8 @@ class QuotaTestCase(BaseQuotaTestCase):
|
||||
self.assertEqual(self.var1.check_quotas(), (Quota.AVAILABILITY_ORDERED, 0))
|
||||
|
||||
def test_voucher_multiuse_count_overredeemed(self):
|
||||
if 'sqlite' not in settings.DATABASES['default']['ENGINE']:
|
||||
pytest.xfail('This should raise a type error on most databases')
|
||||
Voucher.objects.create(quota=self.quota, event=self.event, block_quota=True, max_usages=2, redeemed=4)
|
||||
self.assertEqual(self.quota.count_blocking_vouchers(), 0)
|
||||
|
||||
@@ -402,6 +407,29 @@ class QuotaTestCase(BaseQuotaTestCase):
|
||||
v.clean()
|
||||
|
||||
|
||||
class VoucherTestCase(BaseQuotaTestCase):
|
||||
|
||||
def test_calculate_price_none(self):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='none', value=Decimal('10.00'))
|
||||
v.calculate_price(Decimal('23.42')) == Decimal('23.42')
|
||||
|
||||
def test_calculate_price_set_empty(self):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='set')
|
||||
v.calculate_price(Decimal('23.42')) == Decimal('23.42')
|
||||
|
||||
def test_calculate_price_set(self):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='set', value=Decimal('10.00'))
|
||||
v.calculate_price(Decimal('23.42')) == Decimal('10.00')
|
||||
|
||||
def test_calculate_price_subtract(self):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='subtract', value=Decimal('10.00'))
|
||||
v.calculate_price(Decimal('23.42')) == Decimal('13.42')
|
||||
|
||||
def test_calculate_price_percent(self):
|
||||
v = Voucher.objects.create(event=self.event, price_mode='percent', value=Decimal('23.00'))
|
||||
v.calculate_price(Decimal('100.00')) == Decimal('77.00')
|
||||
|
||||
|
||||
class OrderTestCase(BaseQuotaTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@@ -2,6 +2,7 @@ from datetime import datetime, timedelta
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
import pytz
|
||||
from django.test import TestCase
|
||||
from django.utils.timezone import make_aware, now
|
||||
|
||||
@@ -70,6 +71,19 @@ def test_expiry_last(event):
|
||||
assert (order.expires - today).days == 5
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_expiry_dst(event):
|
||||
event.settings.set('timezone', 'Europe/Berlin')
|
||||
tz = pytz.timezone('Europe/Berlin')
|
||||
utc = pytz.timezone('UTC')
|
||||
today = tz.localize(datetime(2016, 10, 29, 12, 0, 0)).astimezone(utc)
|
||||
order = _create_order(event, email='dummy@example.org', positions=[],
|
||||
now_dt=today, payment_provider=FreeOrderProvider(event),
|
||||
locale='de')
|
||||
localex = order.expires.astimezone(tz)
|
||||
assert (localex.hour, localex.minute) == (23, 59)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_expiring(event):
|
||||
o1 = Order.objects.create(
|
||||
|
||||
@@ -80,9 +80,9 @@ class VoucherFormTest(SoupTest):
|
||||
def test_csv(self):
|
||||
self.event.vouchers.create(item=self.ticket, code='ABCDEFG')
|
||||
doc = self.client.get('/control/event/%s/%s/vouchers/?download=yes' % (self.orga.slug, self.event.slug))
|
||||
assert doc.content.strip() == '"Voucher code","Valid until","Product","Reserve quota","Bypass quota","Price",' \
|
||||
'"Tag","Redeemed","Maximum usages"\r\n"ABCDEFG","","Early-bird ticket","No",' \
|
||||
'"No","","","0","1"'.encode('utf-8')
|
||||
assert doc.content.strip() == '"Voucher code","Valid until","Product","Reserve quota","Bypass quota",' \
|
||||
'"Price effect","Value","Tag","Redeemed","Maximum usages"\r\n"ABCDEFG","",' \
|
||||
'"Early-bird ticket","No","No","Set product price to","","","0","1"'.encode('utf-8')
|
||||
|
||||
def test_filter_status_valid(self):
|
||||
v = self.event.vouchers.create(item=self.ticket)
|
||||
|
||||
@@ -121,6 +121,39 @@ def test_webhook_all_good(env, client, monkeypatch):
|
||||
assert order.status == Order.STATUS_PAID
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_webhook_mark_paid(env, client, monkeypatch):
|
||||
order = env[1]
|
||||
order.status = Order.STATUS_PENDING
|
||||
order.save()
|
||||
|
||||
charge = get_test_charge(env[1])
|
||||
monkeypatch.setattr("stripe.Charge.retrieve", lambda *args: charge)
|
||||
|
||||
client.post('/dummy/dummy/stripe/webhook/', json.dumps(
|
||||
{
|
||||
"id": "evt_18otImGGWE2Ias8TUyVRDB1G",
|
||||
"object": "event",
|
||||
"api_version": "2016-03-07",
|
||||
"created": 1472729052,
|
||||
"data": {
|
||||
"object": {
|
||||
"id": "ch_18TY6GGGWE2Ias8TZHanef25",
|
||||
"object": "charge",
|
||||
# Rest of object is ignored anway
|
||||
}
|
||||
},
|
||||
"livemode": True,
|
||||
"pending_webhooks": 1,
|
||||
"request": "req_977XOWC8zk51Z9",
|
||||
"type": "charge.succeeded"
|
||||
}
|
||||
), content_type='application_json')
|
||||
|
||||
order.refresh_from_db()
|
||||
assert order.status == Order.STATUS_PAID
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_webhook_partial_refund(env, client, monkeypatch):
|
||||
charge = get_test_charge(env[1])
|
||||
|
||||
@@ -488,7 +488,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
event=self.event, cart_id=self.session_key, item=self.shirt, variation=self.shirt_red,
|
||||
price=14, expires=now() + timedelta(minutes=10)
|
||||
)
|
||||
v = Voucher.objects.create(item=self.shirt, variation=self.shirt_red, price=Decimal('10.00'), event=self.event)
|
||||
v = Voucher.objects.create(item=self.shirt, variation=self.shirt_red, value=Decimal('10.00'), event=self.event)
|
||||
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'variation_%d_%d_voucher' % (self.shirt.id, self.shirt_red.id): v.code,
|
||||
}, follow=True)
|
||||
@@ -594,7 +594,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
self.assertEqual(len(objs), 0)
|
||||
|
||||
def test_voucher_price(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event)
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event)
|
||||
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
'_voucher_code': v.code,
|
||||
@@ -605,8 +605,76 @@ class CartTest(CartTestMixin, TestCase):
|
||||
self.assertIsNone(objs[0].variation)
|
||||
self.assertEqual(objs[0].price, Decimal('12.00'))
|
||||
|
||||
def test_voucher_price_percent(self):
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('10.00'), price_mode='percent', event=self.event)
|
||||
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
'_voucher_code': v.code,
|
||||
}, follow=True)
|
||||
objs = list(CartPosition.objects.filter(cart_id=self.session_key, event=self.event))
|
||||
self.assertEqual(len(objs), 1)
|
||||
self.assertEqual(objs[0].item, self.ticket)
|
||||
self.assertIsNone(objs[0].variation)
|
||||
self.assertEqual(objs[0].price, Decimal('20.70'))
|
||||
|
||||
def test_voucher_price_subtract(self):
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('10.00'), price_mode='subtract', event=self.event)
|
||||
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
'_voucher_code': v.code,
|
||||
}, follow=True)
|
||||
objs = list(CartPosition.objects.filter(cart_id=self.session_key, event=self.event))
|
||||
self.assertEqual(len(objs), 1)
|
||||
self.assertEqual(objs[0].item, self.ticket)
|
||||
self.assertIsNone(objs[0].variation)
|
||||
self.assertEqual(objs[0].price, Decimal('13.00'))
|
||||
|
||||
def test_voucher_free_price(self):
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('10.00'), price_mode='percent', event=self.event)
|
||||
self.ticket.free_price = True
|
||||
self.ticket.save()
|
||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
'price_%d' % self.ticket.id: '21.00',
|
||||
'_voucher_code': v.code,
|
||||
}, follow=True)
|
||||
self.assertRedirects(response, '/%s/%s/' % (self.orga.slug, self.event.slug),
|
||||
target_status_code=200)
|
||||
doc = BeautifulSoup(response.rendered_content, "lxml")
|
||||
self.assertIn('Early-bird', doc.select('.cart .cart-row')[0].select('strong')[0].text)
|
||||
self.assertIn('1', doc.select('.cart .cart-row')[0].select('.count')[0].text)
|
||||
self.assertIn('21', doc.select('.cart .cart-row')[0].select('.price')[0].text)
|
||||
self.assertIn('21', doc.select('.cart .cart-row')[0].select('.price')[1].text)
|
||||
objs = list(CartPosition.objects.filter(cart_id=self.session_key, event=self.event))
|
||||
self.assertEqual(len(objs), 1)
|
||||
self.assertEqual(objs[0].item, self.ticket)
|
||||
self.assertIsNone(objs[0].variation)
|
||||
self.assertEqual(objs[0].price, Decimal('21.00'))
|
||||
|
||||
def test_voucher_free_price_lower_bound(self):
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('10.00'), price_mode='percent', event=self.event)
|
||||
self.ticket.free_price = False
|
||||
self.ticket.save()
|
||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
'price_%d' % self.ticket.id: '20.00',
|
||||
'_voucher_code': v.code,
|
||||
}, follow=True)
|
||||
self.assertRedirects(response, '/%s/%s/' % (self.orga.slug, self.event.slug),
|
||||
target_status_code=200)
|
||||
doc = BeautifulSoup(response.rendered_content, "lxml")
|
||||
self.assertIn('Early-bird', doc.select('.cart .cart-row')[0].select('strong')[0].text)
|
||||
self.assertIn('1', doc.select('.cart .cart-row')[0].select('.count')[0].text)
|
||||
self.assertIn('20.70', doc.select('.cart .cart-row')[0].select('.price')[0].text)
|
||||
self.assertIn('20.70', doc.select('.cart .cart-row')[0].select('.price')[1].text)
|
||||
objs = list(CartPosition.objects.filter(cart_id=self.session_key, event=self.event))
|
||||
self.assertEqual(len(objs), 1)
|
||||
self.assertEqual(objs[0].item, self.ticket)
|
||||
self.assertIsNone(objs[0].variation)
|
||||
self.assertEqual(objs[0].price, Decimal('20.70'))
|
||||
|
||||
def test_voucher_redemed(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event, redeemed=1)
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event, redeemed=1)
|
||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
'_voucher_code': v.code,
|
||||
@@ -616,7 +684,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
self.assertFalse(CartPosition.objects.filter(cart_id=self.session_key, event=self.event).exists())
|
||||
|
||||
def test_voucher_expired(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() - timedelta(days=2))
|
||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
@@ -638,7 +706,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
def test_voucher_quota_empty(self):
|
||||
self.quota_tickets.size = 0
|
||||
self.quota_tickets.save()
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event)
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event)
|
||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
'_voucher_code': v.code,
|
||||
@@ -650,7 +718,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
def test_voucher_quota_ignore(self):
|
||||
self.quota_tickets.size = 0
|
||||
self.quota_tickets.save()
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
allow_ignore_quota=True)
|
||||
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
@@ -665,7 +733,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
def test_voucher_quota_block(self):
|
||||
self.quota_tickets.size = 1
|
||||
self.quota_tickets.save()
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
block_quota=True)
|
||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
@@ -684,7 +752,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
self.assertEqual(objs[0].price, Decimal('12.00'))
|
||||
|
||||
def test_voucher_doubled(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event)
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event)
|
||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
'_voucher_code': v.code,
|
||||
@@ -758,7 +826,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
self.assertEqual(len(objs), 0)
|
||||
|
||||
def test_voucher_multiuse_ok(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
max_usages=2, redeemed=0)
|
||||
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '2',
|
||||
@@ -769,7 +837,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
assert all(cp.voucher == v for cp in positions)
|
||||
|
||||
def test_voucher_multiuse_multiprod_ok(self):
|
||||
v = Voucher.objects.create(quota=self.quota_all, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(quota=self.quota_all, value=Decimal('12.00'), event=self.event,
|
||||
max_usages=2, redeemed=0)
|
||||
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
@@ -781,7 +849,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
assert all(cp.voucher == v for cp in positions)
|
||||
|
||||
def test_voucher_multiuse_partially(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
max_usages=2, redeemed=1)
|
||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '2',
|
||||
@@ -793,7 +861,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
assert not positions.exists()
|
||||
|
||||
def test_voucher_multiuse_multiprod_partially(self):
|
||||
v = Voucher.objects.create(quota=self.quota_all, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(quota=self.quota_all, value=Decimal('12.00'), event=self.event,
|
||||
max_usages=2, redeemed=1)
|
||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
@@ -807,7 +875,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
assert all(cp.voucher == v for cp in positions)
|
||||
|
||||
def test_voucher_multiuse_redeemed(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
max_usages=2, redeemed=2)
|
||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '2',
|
||||
@@ -819,7 +887,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
assert not positions.exists()
|
||||
|
||||
def test_voucher_multiuse_multiprod_redeemed(self):
|
||||
v = Voucher.objects.create(quota=self.quota_all, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(quota=self.quota_all, value=Decimal('12.00'), event=self.event,
|
||||
max_usages=2, redeemed=2)
|
||||
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||
'item_%d' % self.ticket.id: '1',
|
||||
@@ -832,7 +900,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
assert not positions.exists()
|
||||
|
||||
def test_voucher_multiuse_redeemed_in_my_cart(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
max_usages=2, redeemed=1)
|
||||
CartPosition.objects.create(
|
||||
expires=now() - timedelta(minutes=10), item=self.ticket, voucher=v, price=Decimal('12.00'),
|
||||
@@ -848,7 +916,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
assert positions.count() == 1
|
||||
|
||||
def test_voucher_multiuse_redeemed_in_other_cart(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
max_usages=2, redeemed=1)
|
||||
CartPosition.objects.create(
|
||||
expires=now() + timedelta(minutes=10), item=self.ticket, voucher=v, price=Decimal('12.00'),
|
||||
@@ -864,7 +932,7 @@ class CartTest(CartTestMixin, TestCase):
|
||||
assert not positions.exists()
|
||||
|
||||
def test_voucher_multiuse_redeemed_in_other_expired_cart(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
max_usages=2, redeemed=1)
|
||||
CartPosition.objects.create(
|
||||
expires=now() - timedelta(minutes=10), item=self.ticket, voucher=v, price=Decimal('12.00'),
|
||||
|
||||
@@ -294,7 +294,7 @@ class CheckoutTestCase(TestCase):
|
||||
self.assertEqual(cr1.price, 24)
|
||||
|
||||
def test_voucher(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() + timedelta(days=2))
|
||||
cr1 = CartPosition.objects.create(
|
||||
event=self.event, cart_id=self.session_key, item=self.ticket,
|
||||
@@ -312,7 +312,7 @@ class CheckoutTestCase(TestCase):
|
||||
self.assertEqual(Voucher.objects.get(pk=v.pk).redeemed, 1)
|
||||
|
||||
def test_voucher_required(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() + timedelta(days=2))
|
||||
self.ticket.require_voucher = True
|
||||
self.ticket.save()
|
||||
@@ -341,7 +341,7 @@ class CheckoutTestCase(TestCase):
|
||||
assert doc.select(".alert-danger")
|
||||
|
||||
def test_voucher_price_changed(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() + timedelta(days=2))
|
||||
cr1 = CartPosition.objects.create(
|
||||
event=self.event, cart_id=self.session_key, item=self.ticket,
|
||||
@@ -355,20 +355,8 @@ class CheckoutTestCase(TestCase):
|
||||
cr1 = CartPosition.objects.get(id=cr1.id)
|
||||
self.assertEqual(cr1.price, Decimal('12.00'))
|
||||
|
||||
def test_voucher_expired(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() - timedelta(days=2))
|
||||
CartPosition.objects.create(
|
||||
event=self.event, cart_id=self.session_key, item=self.ticket,
|
||||
price=12, expires=now() - timedelta(minutes=10), voucher=v
|
||||
)
|
||||
self._set_session('payment', 'banktransfer')
|
||||
response = self.client.post('/%s/%s/checkout/confirm/' % (self.orga.slug, self.event.slug), follow=True)
|
||||
doc = BeautifulSoup(response.rendered_content, "lxml")
|
||||
self.assertIn("expired", doc.select(".alert-danger")[0].text)
|
||||
|
||||
def test_voucher_redeemed(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() + timedelta(days=2), redeemed=1)
|
||||
CartPosition.objects.create(
|
||||
event=self.event, cart_id=self.session_key, item=self.ticket,
|
||||
@@ -380,7 +368,7 @@ class CheckoutTestCase(TestCase):
|
||||
self.assertIn("has already been", doc.select(".alert-danger")[0].text)
|
||||
|
||||
def test_voucher_multiuse_redeemed(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() + timedelta(days=2), max_usages=3, redeemed=3)
|
||||
CartPosition.objects.create(
|
||||
event=self.event, cart_id=self.session_key, item=self.ticket,
|
||||
@@ -392,7 +380,7 @@ class CheckoutTestCase(TestCase):
|
||||
self.assertIn("has already been", doc.select(".alert-danger")[0].text)
|
||||
|
||||
def test_voucher_multiuse_partially(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() + timedelta(days=2), max_usages=3, redeemed=2)
|
||||
CartPosition.objects.create(
|
||||
event=self.event, cart_id=self.session_key, item=self.ticket,
|
||||
@@ -409,7 +397,7 @@ class CheckoutTestCase(TestCase):
|
||||
assert CartPosition.objects.filter(cart_id=self.session_key).count() == 1
|
||||
|
||||
def test_voucher_multiuse_ok(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() + timedelta(days=2), max_usages=3, redeemed=1)
|
||||
CartPosition.objects.create(
|
||||
event=self.event, cart_id=self.session_key, item=self.ticket,
|
||||
@@ -430,7 +418,7 @@ class CheckoutTestCase(TestCase):
|
||||
assert v.redeemed == 3
|
||||
|
||||
def test_voucher_multiuse_in_other_cart_expired(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() + timedelta(days=2), max_usages=3, redeemed=1)
|
||||
CartPosition.objects.create(
|
||||
event=self.event, cart_id='other', item=self.ticket,
|
||||
@@ -455,7 +443,7 @@ class CheckoutTestCase(TestCase):
|
||||
assert v.redeemed == 3
|
||||
|
||||
def test_voucher_multiuse_in_other_cart(self):
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() + timedelta(days=2), max_usages=3, redeemed=1)
|
||||
CartPosition.objects.create(
|
||||
event=self.event, cart_id='other', item=self.ticket,
|
||||
@@ -478,7 +466,7 @@ class CheckoutTestCase(TestCase):
|
||||
def test_voucher_ignore_quota(self):
|
||||
self.quota_tickets.size = 0
|
||||
self.quota_tickets.save()
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() + timedelta(days=2), allow_ignore_quota=True)
|
||||
cr1 = CartPosition.objects.create(
|
||||
event=self.event, cart_id=self.session_key, item=self.ticket,
|
||||
@@ -496,7 +484,7 @@ class CheckoutTestCase(TestCase):
|
||||
def test_voucher_block_quota(self):
|
||||
self.quota_tickets.size = 1
|
||||
self.quota_tickets.save()
|
||||
v = Voucher.objects.create(item=self.ticket, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(item=self.ticket, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() + timedelta(days=2), block_quota=True)
|
||||
cr1 = CartPosition.objects.create(
|
||||
event=self.event, cart_id=self.session_key, item=self.ticket,
|
||||
@@ -523,7 +511,7 @@ class CheckoutTestCase(TestCase):
|
||||
self.quota_tickets.save()
|
||||
q2 = self.event.quotas.create(name='Testquota', size=0)
|
||||
q2.items.add(self.ticket)
|
||||
v = Voucher.objects.create(quota=self.quota_tickets, price=Decimal('12.00'), event=self.event,
|
||||
v = Voucher.objects.create(quota=self.quota_tickets, value=Decimal('12.00'), event=self.event,
|
||||
valid_until=now() + timedelta(days=2), block_quota=True)
|
||||
CartPosition.objects.create(
|
||||
event=self.event, cart_id=self.session_key, item=self.ticket,
|
||||
|
||||
@@ -285,19 +285,27 @@ class VoucherRedeemItemDisplayTest(EventTestMixin, SoupTest):
|
||||
html = self.client.get('/%s/%s/redeem?voucher=%s' % (self.orga.slug, self.event.slug, self.v.code))
|
||||
assert "_voucher_item" in html.rendered_content
|
||||
|
||||
def test_special_price(self):
|
||||
self.v.price = Decimal("10.00")
|
||||
def test_voucher_price(self):
|
||||
self.v.value = Decimal("10.00")
|
||||
self.v.save()
|
||||
html = self.client.get('/%s/%s/redeem?voucher=%s' % (self.orga.slug, self.event.slug, self.v.code))
|
||||
assert "Early-bird" in html.rendered_content
|
||||
assert "10.00" in html.rendered_content
|
||||
|
||||
def test_special_price_variations(self):
|
||||
def test_voucher_price_percentage(self):
|
||||
self.v.value = Decimal("10.00")
|
||||
self.v.price_mode = 'percent'
|
||||
self.v.save()
|
||||
html = self.client.get('/%s/%s/redeem?voucher=%s' % (self.orga.slug, self.event.slug, self.v.code))
|
||||
assert "Early-bird" in html.rendered_content
|
||||
assert "10.80" in html.rendered_content
|
||||
|
||||
def test_voucher_price_variations(self):
|
||||
var1 = ItemVariation.objects.create(item=self.item, value='Red', default_price=14, position=1)
|
||||
var2 = ItemVariation.objects.create(item=self.item, value='Black', position=2)
|
||||
self.q.variations.add(var1)
|
||||
self.q.variations.add(var2)
|
||||
self.v.price = Decimal("10.00")
|
||||
self.v.value = Decimal("10.00")
|
||||
self.v.save()
|
||||
html = self.client.get('/%s/%s/redeem?voucher=%s' % (self.orga.slug, self.event.slug, self.v.code))
|
||||
assert "Early-bird" in html.rendered_content
|
||||
|
||||
Reference in New Issue
Block a user