2017-10-28 02:59:40 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Generated by Django 1.10.7 on 2017-10-27 23:26
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.db import migrations, models
|
|
|
|
|
|
|
|
|
|
|
|
def create_type(apps, schema_editor):
|
2019-11-04 16:55:03 +00:00
|
|
|
Cotisation = apps.get_model("cotisations", "Cotisation")
|
|
|
|
Vente = apps.get_model("cotisations", "Vente")
|
|
|
|
Article = apps.get_model("cotisations", "Article")
|
2017-10-28 02:59:40 +00:00
|
|
|
db_alias = schema_editor.connection.alias
|
2017-10-28 03:08:09 +00:00
|
|
|
articles = Article.objects.using(db_alias).all()
|
2017-10-28 02:59:40 +00:00
|
|
|
ventes = Vente.objects.using(db_alias).all()
|
|
|
|
cotisations = Cotisation.objects.using(db_alias).all()
|
|
|
|
for article in articles:
|
|
|
|
if article.iscotisation:
|
2019-11-04 16:55:03 +00:00
|
|
|
article.type_cotisation = "All"
|
2017-10-28 02:59:40 +00:00
|
|
|
article.save(using=db_alias)
|
|
|
|
for vente in ventes:
|
|
|
|
if vente.iscotisation:
|
2019-11-04 16:55:03 +00:00
|
|
|
vente.type_cotisation = "All"
|
2017-10-28 02:59:40 +00:00
|
|
|
vente.save(using=db_alias)
|
|
|
|
for cotisation in cotisations:
|
2019-11-04 16:55:03 +00:00
|
|
|
cotisation.type_cotisation = "All"
|
2017-10-28 02:59:40 +00:00
|
|
|
cotisation.save(using=db_alias)
|
|
|
|
|
2019-11-04 16:55:03 +00:00
|
|
|
|
2017-10-28 02:59:40 +00:00
|
|
|
def delete_type(apps, schema_editor):
|
2019-11-04 16:55:03 +00:00
|
|
|
Vente = apps.get_model("cotisations", "Vente")
|
|
|
|
Article = apps.get_model("cotisations", "Article")
|
2017-10-28 02:59:40 +00:00
|
|
|
db_alias = schema_editor.connection.alias
|
2019-07-14 17:55:53 +00:00
|
|
|
articles = Article.objects.using(db_alias).all()
|
2017-10-28 02:59:40 +00:00
|
|
|
ventes = Vente.objects.using(db_alias).all()
|
|
|
|
for article in articles:
|
|
|
|
if article.type_cotisation:
|
2019-11-04 16:55:03 +00:00
|
|
|
article.iscotisation = True
|
2017-10-28 02:59:40 +00:00
|
|
|
else:
|
2019-11-04 16:55:03 +00:00
|
|
|
article.iscotisation = False
|
2017-10-28 02:59:40 +00:00
|
|
|
article.save(using=db_alias)
|
|
|
|
for vente in ventes:
|
|
|
|
if vente.iscotisation:
|
2019-11-04 16:55:03 +00:00
|
|
|
vente.iscotisation = True
|
2017-10-28 02:59:40 +00:00
|
|
|
else:
|
2019-11-04 16:55:03 +00:00
|
|
|
vente.iscotisation = False
|
2017-10-28 02:59:40 +00:00
|
|
|
vente.save(using=db_alias)
|
|
|
|
|
2019-11-04 16:55:03 +00:00
|
|
|
|
2017-10-28 02:59:40 +00:00
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
2019-11-04 16:55:03 +00:00
|
|
|
dependencies = [("cotisations", "0025_article_type_user")]
|
2017-10-28 02:59:40 +00:00
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.AddField(
|
2019-11-04 16:55:03 +00:00
|
|
|
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,
|
|
|
|
),
|
2017-10-28 02:59:40 +00:00
|
|
|
),
|
|
|
|
migrations.AddField(
|
2019-11-04 16:55:03 +00:00
|
|
|
model_name="cotisation",
|
|
|
|
name="type_cotisation",
|
|
|
|
field=models.CharField(
|
|
|
|
choices=[
|
|
|
|
("Connexion", "Connexion"),
|
|
|
|
("Adhesion", "Adhesion"),
|
|
|
|
("All", "All"),
|
|
|
|
],
|
|
|
|
max_length=255,
|
|
|
|
default="All",
|
|
|
|
),
|
2017-10-28 02:59:40 +00:00
|
|
|
),
|
|
|
|
migrations.AddField(
|
2019-11-04 16:55:03 +00:00
|
|
|
model_name="vente",
|
|
|
|
name="type_cotisation",
|
|
|
|
field=models.CharField(
|
|
|
|
blank=True,
|
|
|
|
choices=[
|
|
|
|
("Connexion", "Connexion"),
|
|
|
|
("Adhesion", "Adhesion"),
|
|
|
|
("All", "All"),
|
|
|
|
],
|
|
|
|
max_length=255,
|
|
|
|
null=True,
|
|
|
|
),
|
2017-10-28 02:59:40 +00:00
|
|
|
),
|
|
|
|
migrations.RunPython(create_type, delete_type),
|
2019-11-04 16:55:03 +00:00
|
|
|
migrations.RemoveField(model_name="article", name="iscotisation"),
|
|
|
|
migrations.RemoveField(model_name="vente", name="iscotisation"),
|
2017-10-28 02:59:40 +00:00
|
|
|
]
|