8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-24 16:03:47 +00:00
re2o/cotisations/migrations/0047_article_need_membership_init.py

29 lines
919 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2020-09-25 16:45
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0046_article_need_membership'),
]
def init_need_membership(apps, schema_editor):
db_alias = schema_editor.connection.alias
article = apps.get_model("cotisations", "Article")
articles = article.objects.using(db_alias).all()
for art in articles:
v = False
v = v or bool(art.duration_membership)
v = v or bool(art.duration_days_membership)
v = v or not (bool(art.duration_connection) or bool(art.duration_days_connection))
art.need_membership = v
art.save()
operations = [
migrations.RunPython(init_need_membership, lambda *args, **kargs: None),
]