0032_chequepayment_comnpaypayment.py 2.58 KB
Newer Older
1
# -*- coding: utf-8 -*-
2
# Generated by Django 1.10.7 on 2018-07-02 18:56
3 4
from __future__ import unicode_literals

5
import re2o.aes_field
6
import cotisations.payment_methods.mixins
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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()
33
    payment.moyen = "ComnPay"
34

35
    payment.save()
36 37 38 39 40


class Migration(migrations.Migration):

    dependencies = [
41
        ('preferences', '0044_remove_payment_pass'),
42 43 44 45 46 47 48 49
        ('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')),
50
                ('payment', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='payment_method', to='cotisations.Paiement')),
51
            ],
52
            bases=(cotisations.payment_methods.mixins.PaymentMethodMixin, models.Model),
53 54 55 56 57
        ),
        migrations.CreateModel(
            name='ComnpayPayment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
58
                ('payment_credential', models.CharField(blank=True, default='', max_length=255)),
59
                ('payment_pass', re2o.aes_field.AESEncryptedField(blank=True, max_length=255, null=True)),
60
                ('payment', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='payment_method', to='cotisations.Paiement')),
61
            ],
62
            bases=(cotisations.payment_methods.mixins.PaymentMethodMixin, models.Model),
63
        ),
64 65
        # migrations.RunPython(add_comnpay),
        # migrations.RunPython(add_cheque),
66
    ]