8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-26 06:32:26 +00:00
re2o/cotisations/migrations/0032_chequepayment_comnpaypayment.py
2018-06-28 22:46:16 +02:00

59 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-06-28 17:28
from __future__ import unicode_literals
import cotisations.payment_methods.comnpay.aes_field
from django.db import migrations, models
import django.db.models.deletion
def add_cheque(apps, schema_editor):
ChequePayment = apps.get_model('cotisations', 'ChequePayment')
Payment = apps.get_model('cotisations', 'Paiement')
for p in Payment.objects.filter(type_paiement=1):
cheque = ChequePayment()
cheque.payment = p
cheque.save()
def add_comnpay(apps, schema_editor):
ComnpayPayment = apps.get_model('cotisations', 'ComnpayPayment')
Payment = apps.get_model('cotisations', 'Paiement')
AssoOption = apps.get_model('preferences', 'AssoOption')
options, _created = AssoOption.objects.get_or_create()
payment, _created = Payment.objects.get_or_create(
moyen='Rechargement en ligne'
)
comnpay = ComnpayPayment()
comnpay.payment_user = options.payment_id
comnpay.payment_pass = options.payment_pass
comnpay.payment = payment
comnpay.save()
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0031_article_allow_self_subscription'),
]
operations = [
migrations.CreateModel(
name='ChequePayment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('payment', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='payment_method', to='cotisations.Paiement')),
],
),
migrations.CreateModel(
name='ComnpayPayment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('payment_user', models.CharField(blank=True, default='', max_length=255)),
('payment_pass', cotisations.payment_methods.comnpay.aes_field.AESEncryptedField(blank=True, max_length=255, null=True)),
('payment', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='payment_method', to='cotisations.Paiement')),
],
),
migrations.RunPython(add_cheque),
migrations.RunPython(add_comnpay),
]