mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-12 23:27:22 +00:00
Merge branch 'v1.9.11'
This commit is contained in:
commit
bb0579f9f4
@ -16,9 +16,44 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from indico_payment_manual import _
|
||||
from indico.util.placeholders import Placeholder
|
||||
from decimal import Decimal
|
||||
from urllib import quote_plus
|
||||
|
||||
from indico.modules.events.registration.placeholders.registrations import IDPlaceholder
|
||||
from indico.util.placeholders import ParametrizedPlaceholder, Placeholder
|
||||
|
||||
from indico_payment_manual import _
|
||||
|
||||
|
||||
class EscapablePlaceholder(ParametrizedPlaceholder):
|
||||
param_required = False
|
||||
param_restricted = True
|
||||
field = None
|
||||
basic_description = None
|
||||
|
||||
@classmethod
|
||||
def render(cls, param, regform, registration):
|
||||
rv = getattr(registration, cls.field)
|
||||
if param == 'url':
|
||||
rv = quote_plus(rv.encode('utf-8')).decode('utf-8')
|
||||
return rv
|
||||
|
||||
@classmethod
|
||||
def iter_param_info(cls, regform, registration):
|
||||
yield None, cls.basic_description
|
||||
yield 'url', '{} ({})'.format(cls.basic_description, _('escaped for URLs'))
|
||||
|
||||
|
||||
class FirstNamePlaceholder(EscapablePlaceholder):
|
||||
name = 'first_name'
|
||||
basic_description = _("First name of the registrant")
|
||||
field = 'first_name'
|
||||
|
||||
|
||||
class LastNamePlaceholder(EscapablePlaceholder):
|
||||
name = 'last_name'
|
||||
basic_description = _("Last name of the registrant")
|
||||
field = 'last_name'
|
||||
|
||||
|
||||
class RegistrationIDPlaceholder(IDPlaceholder):
|
||||
@ -32,3 +67,33 @@ class EventIDPlaceholder(Placeholder):
|
||||
@classmethod
|
||||
def render(cls, regform, registration):
|
||||
return registration.registration_form.event.id
|
||||
|
||||
|
||||
class PricePlaceholder(ParametrizedPlaceholder):
|
||||
param_required = False
|
||||
param_restricted = True
|
||||
name = 'price'
|
||||
|
||||
@classmethod
|
||||
def render(cls, param, regform, registration):
|
||||
if param == 'int':
|
||||
return unicode(int(registration.price * 100))
|
||||
elif param == 'short' and int(registration.price) == registration.price:
|
||||
return unicode(int(registration.price))
|
||||
else:
|
||||
return unicode(registration.price.quantize(Decimal('.01')))
|
||||
|
||||
@classmethod
|
||||
def iter_param_info(cls, regform, registration):
|
||||
yield None, _("The price the registrant needs to pay (e.g. 100.00 or 100.25)")
|
||||
yield 'short', _("The price without cents if possible (e.g. 100 or 100.25)")
|
||||
yield 'int', _("The price formatted as an integer (e.g. 10000 or 10025)")
|
||||
|
||||
|
||||
class CurrencyPlaceholder(Placeholder):
|
||||
name = 'currency'
|
||||
description = _("The currency used in the registration")
|
||||
|
||||
@classmethod
|
||||
def render(cls, regform, registration):
|
||||
return registration.currency
|
||||
|
||||
@ -29,8 +29,9 @@ from indico.web.forms.validators import UsedIf
|
||||
from indico_payment_manual import _
|
||||
|
||||
|
||||
DETAILS_DESC = _('The details the user needs to make their payment. This usually includes the bank account details '
|
||||
'the IBAN and payment reference.')
|
||||
DETAILS_DESC = _('The details the user needs to make their payment. This usually includes the bank account details, '
|
||||
'the IBAN and payment reference. You can also link to a custom payment site. In this case make sure '
|
||||
'to use the URL-escaped versions of the placeholders where available.')
|
||||
|
||||
|
||||
class PluginSettingsForm(PaymentPluginSettingsFormBase):
|
||||
@ -72,13 +73,15 @@ class ManualPaymentPlugin(PaymentPluginMixin, IndicoPlugin):
|
||||
self.connect(signals.get_placeholders, self._get_details_placeholders, sender='manual-payment-details')
|
||||
|
||||
def _get_details_placeholders(self, sender, regform, registration, **kwargs):
|
||||
from indico.modules.events.registration.placeholders.registrations import (FirstNamePlaceholder,
|
||||
LastNamePlaceholder)
|
||||
from indico_payment_manual.placeholders import RegistrationIDPlaceholder, EventIDPlaceholder
|
||||
from indico_payment_manual.placeholders import (FirstNamePlaceholder, LastNamePlaceholder,
|
||||
RegistrationIDPlaceholder, EventIDPlaceholder, PricePlaceholder,
|
||||
CurrencyPlaceholder)
|
||||
yield FirstNamePlaceholder
|
||||
yield LastNamePlaceholder
|
||||
yield RegistrationIDPlaceholder
|
||||
yield EventIDPlaceholder
|
||||
yield PricePlaceholder
|
||||
yield CurrencyPlaceholder
|
||||
|
||||
@property
|
||||
def logo_url(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user