8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 23:43:47 +00:00
re2o/cotisations/migrations/0001_squashed_0028_auto_20171231_0007.py
2018-03-21 18:27:20 +00:00

249 lines
11 KiB
Python

# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-03-20 19:57
from __future__ import unicode_literals
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
# Functions from the following migrations need manual copying.
# Move them and any dependencies into this file, then update the
# RunPython operations to refer to the local versions:
# cotisations.migrations.0026_auto_20171028_0126
# Imported from cotisations.migrations.0026_auto_20171028_0126
##############################################################
def create_type(apps, schema_editor):
Cotisation = apps.get_model('cotisations', 'Cotisation')
Vente = apps.get_model('cotisations', 'Vente')
Article = apps.get_model('cotisations', 'Article')
db_alias = schema_editor.connection.alias
articles = Article.objects.using(db_alias).all()
ventes = Vente.objects.using(db_alias).all()
cotisations = Cotisation.objects.using(db_alias).all()
for article in articles:
if article.iscotisation:
article.type_cotisation='All'
article.save(using=db_alias)
for vente in ventes:
if vente.iscotisation:
vente.type_cotisation='All'
vente.save(using=db_alias)
for cotisation in cotisations:
cotisation.type_cotisation='All'
cotisation.save(using=db_alias)
def delete_type(apps, schema_editor):
Vente = apps.get_model('cotisations', 'Vente')
Article = apps.get_model('cotisations', 'Article')
db_alias = schema_editor.connection.alias
articles = Articles.objects.using(db_alias).all()
ventes = Vente.objects.using(db_alias).all()
for article in articles:
if article.type_cotisation:
article.iscotisation=True
else:
article.iscotisation=False
article.save(using=db_alias)
for vente in ventes:
if vente.iscotisation:
vente.iscotisation=True
else:
vente.iscotisation=False
vente.save(using=db_alias)
class Migration(migrations.Migration):
replaces = [('cotisations', '0001_initial'), ('cotisations', '0002_remove_facture_article'), ('cotisations', '0003_auto_20160702_1448'), ('cotisations', '0004_auto_20160702_1528'), ('cotisations', '0005_auto_20160702_1532'), ('cotisations', '0006_auto_20160702_1534'), ('cotisations', '0007_auto_20160702_1543'), ('cotisations', '0008_auto_20160702_1614'), ('cotisations', '0009_remove_cotisation_user'), ('cotisations', '0010_auto_20160702_1840'), ('cotisations', '0011_auto_20160702_1911'), ('cotisations', '0012_auto_20160704_0118'), ('cotisations', '0013_auto_20160711_2240'), ('cotisations', '0014_auto_20160712_0245'), ('cotisations', '0015_auto_20160714_2142'), ('cotisations', '0016_auto_20160715_0110'), ('cotisations', '0017_auto_20170718_2329'), ('cotisations', '0018_paiement_type_paiement'), ('cotisations', '0019_auto_20170819_0055'), ('cotisations', '0020_auto_20170819_0057'), ('cotisations', '0021_auto_20170819_0104'), ('cotisations', '0022_auto_20170824_0128'), ('cotisations', '0023_auto_20170902_1303'), ('cotisations', '0024_auto_20171015_2033'), ('cotisations', '0025_article_type_user'), ('cotisations', '0026_auto_20171028_0126'), ('cotisations', '0027_auto_20171029_1156'), ('cotisations', '0028_auto_20171231_0007')]
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Article',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('prix', models.DecimalField(decimal_places=2, max_digits=5)),
],
),
migrations.CreateModel(
name='Banque',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
],
),
migrations.CreateModel(
name='Facture',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('cheque', models.CharField(max_length=255)),
('number', models.IntegerField()),
('date', models.DateTimeField(auto_now_add=True)),
('name', models.CharField(max_length=255)),
('prix', models.DecimalField(decimal_places=2, max_digits=5)),
('article', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='cotisations.Article')),
('banque', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='cotisations.Banque')),
],
),
migrations.CreateModel(
name='Paiement',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('moyen', models.CharField(max_length=255)),
('type_paiement', models.IntegerField(choices=[(0, 'Autre'), (1, 'Chèque')], default=0)),
],
),
migrations.AddField(
model_name='facture',
name='paiement',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='cotisations.Paiement'),
),
migrations.AddField(
model_name='facture',
name='user',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
),
migrations.RemoveField(
model_name='facture',
name='article',
),
migrations.AlterField(
model_name='facture',
name='banque',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='cotisations.Banque'),
),
migrations.RemoveField(
model_name='facture',
name='name',
),
migrations.RemoveField(
model_name='facture',
name='prix',
),
migrations.AlterField(
model_name='facture',
name='cheque',
field=models.CharField(blank=True, max_length=255),
),
migrations.CreateModel(
name='Cotisation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date_start', models.DateTimeField()),
('date_end', models.DateTimeField()),
],
),
migrations.AddField(
model_name='article',
name='iscotisation',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='facture',
name='valid',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='article',
name='duration',
field=models.PositiveIntegerField(blank=True, help_text='Durée exprimée en mois entiers', null=True, validators=[django.core.validators.MinValueValidator(0)]),
),
migrations.CreateModel(
name='Vente',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('prix', models.DecimalField(decimal_places=2, max_digits=5)),
('iscotisation', models.BooleanField()),
('duration', models.PositiveIntegerField(blank=True, help_text='Durée exprimée en mois entiers', null=True)),
('facture', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cotisations.Facture')),
('number', models.IntegerField(validators=[django.core.validators.MinValueValidator(1)])),
('type_cotisation', models.CharField(blank=True, choices=[('Connexion', 'Connexion'), ('Adhesion', 'Adhesion'), ('All', 'All')], max_length=255, null=True)),
],
),
migrations.RemoveField(
model_name='facture',
name='number',
),
migrations.AddField(
model_name='facture',
name='control',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='cotisation',
name='vente',
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to='cotisations.Vente'),
preserve_default=False,
),
migrations.AlterField(
model_name='article',
name='name',
field=models.CharField(max_length=255, unique=True),
),
migrations.AddField(
model_name='article',
name='type_user',
field=models.CharField(choices=[('Adherent', 'Adherent'), ('Club', 'Club'), ('All', 'All')], default='All', max_length=255),
),
migrations.AddField(
model_name='article',
name='type_cotisation',
field=models.CharField(blank=True, choices=[('Connexion', 'Connexion'), ('Adhesion', 'Adhesion'), ('All', 'All')], default=None, max_length=255, null=True),
),
migrations.AddField(
model_name='cotisation',
name='type_cotisation',
field=models.CharField(choices=[('Connexion', 'Connexion'), ('Adhesion', 'Adhesion'), ('All', 'All')], default='All', max_length=255),
),
migrations.RunPython(
code=create_type,
reverse_code=delete_type,
),
migrations.RemoveField(
model_name='article',
name='iscotisation',
),
migrations.RemoveField(
model_name='vente',
name='iscotisation',
),
migrations.AlterField(
model_name='article',
name='name',
field=models.CharField(max_length=255),
),
migrations.AlterModelOptions(
name='article',
options={'permissions': (('view_article', 'Peut voir un objet article'),)},
),
migrations.AlterModelOptions(
name='banque',
options={'permissions': (('view_banque', 'Peut voir un objet banque'),)},
),
migrations.AlterModelOptions(
name='cotisation',
options={'permissions': (('view_cotisation', 'Peut voir un objet cotisation'), ('change_all_cotisation', 'Superdroit, peut modifier toutes les cotisations'))},
),
migrations.AlterModelOptions(
name='facture',
options={'permissions': (('change_facture_control', "Peut changer l'etat de controle"), ('change_facture_pdf', 'Peut éditer une facture pdf'), ('view_facture', 'Peut voir un objet facture'), ('change_all_facture', 'Superdroit, peut modifier toutes les factures'))},
),
migrations.AlterModelOptions(
name='paiement',
options={'permissions': (('view_paiement', 'Peut voir un objet paiement'),)},
),
migrations.AlterModelOptions(
name='vente',
options={'permissions': (('view_vente', 'Peut voir un objet vente'), ('change_all_vente', 'Superdroit, peut modifier toutes les ventes'))},
),
]