8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 15:33:45 +00:00

Merge branch 'fix_online_payment' into crans

This commit is contained in:
Gabriel Detraz 2018-07-11 17:28:53 +02:00
commit f0156270f9
3 changed files with 11 additions and 12 deletions

View file

@ -27,7 +27,6 @@ def add_comnpay(apps, schema_editor):
) )
comnpay = ComnpayPayment() comnpay = ComnpayPayment()
comnpay.payment_user = options.payment_id comnpay.payment_user = options.payment_id
comnpay.payment_pass = options.payment_pass
comnpay.payment = payment comnpay.payment = payment
comnpay.save() comnpay.save()
payment.moyen = "ComnPay" payment.moyen = "ComnPay"
@ -61,6 +60,6 @@ class Migration(migrations.Migration):
], ],
bases=(cotisations.payment_methods.mixins.PaymentMethodMixin, models.Model), bases=(cotisations.payment_methods.mixins.PaymentMethodMixin, models.Model),
), ),
# migrations.RunPython(add_comnpay), migrations.RunPython(add_comnpay),
# migrations.RunPython(add_cheque), migrations.RunPython(add_cheque),
] ]

View file

@ -421,7 +421,8 @@ def add_paiement(request):
return form({ return form({
'factureform': payment, 'factureform': payment,
'payment_method': payment_method, 'payment_method': payment_method,
'action_name': _("Add") 'action_name': _("Add"),
'title': _("New payment method")
}, 'cotisations/facture.html', request) }, 'cotisations/facture.html', request)

View file

@ -72,9 +72,10 @@ class AESEncryptedFormField(forms.CharField):
class AESEncryptedField(models.CharField): class AESEncryptedField(models.CharField):
""" A Field that can be used in forms for adding the support """ A Field that can be used in forms for adding the support
of AES ecnrypted fields """ of AES ecnrypted fields """
def save_form_data(self, instance, data): def save_form_data(self, instance, data):
setattr(instance, self.name, setattr(instance, self.name, binascii.b2a_base64(
binascii.b2a_base64(encrypt(settings.AES_KEY, data))) encrypt(settings.AES_KEY, data)).decode('utf-8'))
def to_python(self, value): def to_python(self, value):
if value is None: if value is None:
@ -83,18 +84,16 @@ class AESEncryptedField(models.CharField):
return decrypt(settings.AES_KEY, return decrypt(settings.AES_KEY,
binascii.a2b_base64(value)).decode('utf-8') binascii.a2b_base64(value)).decode('utf-8')
except Exception as e: except Exception as e:
v = decrypt(settings.AES_KEY, binascii.a2b_base64(value)) raise ValueError(value)
raise ValueError(v)
def from_db_value(self, value, *args, **kwargs): def from_db_value(self, value, *args, **kwargs):
if value is None: if value is None:
return value return value
try: try:
return decrypt(settings.AES_KEY, return decrypt(settings.AES_KEY,
binascii.a2b_base64(value)).decode('utf-8') binascii.a2b_base64(value)).decode('utf-8')
except Exception as e: except Exception as e:
v = decrypt(settings.AES_KEY, binascii.a2b_base64(value)) raise ValueError(value)
raise ValueError(v)
def get_prep_value(self, value): def get_prep_value(self, value):
if value is None: if value is None:
@ -102,7 +101,7 @@ class AESEncryptedField(models.CharField):
return binascii.b2a_base64(encrypt( return binascii.b2a_base64(encrypt(
settings.AES_KEY, settings.AES_KEY,
value value
)) )).decode('utf-8')
def formfield(self, **kwargs): def formfield(self, **kwargs):
defaults = {'form_class': AESEncryptedFormField} defaults = {'form_class': AESEncryptedFormField}