pretix-servicefees/pretix_servicefees/views.py

58 lines
2.2 KiB
Python
Raw Normal View History

2018-02-27 23:12:01 +01:00
from django import forms
from django.urls import reverse
2018-03-05 12:37:50 +01:00
from django.utils.translation import ugettext_lazy as _
2018-02-27 23:12:01 +01:00
from pretix.base.forms import SettingsForm
from pretix.base.models import Event
from pretix.control.views.event import EventSettingsViewMixin, EventSettingsFormView
2019-05-20 14:54:27 +02:00
from pretix.helpers.money import change_decimal_field
2018-02-27 23:12:01 +01:00
2018-10-25 14:26:21 +02:00
2018-02-27 23:12:01 +01:00
class ServiceFeeSettingsForm(SettingsForm):
2019-05-29 09:27:24 +02:00
service_fee_abs = forms.DecimalField(
label=_('Fixed fee per order'),
required=False
)
2019-04-03 15:31:16 +02:00
service_fee_percent = forms.DecimalField(
2019-05-20 14:54:27 +02:00
label=_('Percentual fee per order'),
2019-04-03 15:31:16 +02:00
help_text=_('Percentage of the order total. Note that this percentage will currently only '
'be calculated on the summed price of sold tickets, not on other fees like e.'
2019-05-29 09:27:24 +02:00
'g. shipping fees, if there are any.'),
required=False
2019-04-03 15:31:16 +02:00
)
2019-05-20 14:54:27 +02:00
service_fee_per_ticket = forms.DecimalField(
label=_('Fixed fee per ticket'),
2019-05-29 09:27:24 +02:00
help_text=_('This fee will be added for each ticket sold, except for free items and addons.'),
required=False
2019-05-20 14:54:27 +02:00
)
2019-05-29 09:27:24 +02:00
service_fee_abs_resellers = forms.DecimalField(
label=_('Fixed fee per order'),
required=False
)
2019-04-03 15:31:16 +02:00
service_fee_percent_resellers = forms.DecimalField(
2019-05-20 14:54:27 +02:00
label=_('Percentual fee per order'),
2019-04-03 15:31:16 +02:00
help_text=_('Percentage of the order total. Note that this percentage will currently only '
'be calculated on the summed price of sold tickets, not on other fees like e.'
2019-05-29 09:27:24 +02:00
'g. shipping fees, if there are any.'),
required=False
2019-04-03 15:31:16 +02:00
)
2019-05-20 14:54:27 +02:00
service_fee_per_ticket_resellers = forms.DecimalField(
label=_('Fixed fee per ticket'),
2019-05-29 09:27:24 +02:00
required=False,
2019-05-20 14:54:27 +02:00
help_text=_('This fee will be added for each ticket sold, except for free items and addons.')
)
2018-02-27 23:12:01 +01:00
class SettingsView(EventSettingsViewMixin, EventSettingsFormView):
model = Event
form_class = ServiceFeeSettingsForm
template_name = 'pretix_servicefees/settings.html'
permission = 'can_change_event_settings'
def get_success_url(self) -> str:
return reverse('plugins:pretix_servicefees:settings', kwargs={
'organizer': self.request.event.organizer.slug,
'event': self.request.event.slug
})