mirror of https://gitlab.federez.net/re2o/re2o
Browse Source
This field is a boolean indicating if the article can be purshased by nonmembers.article-diff-connexion-adhesion
3 changed files with 55 additions and 3 deletions
@ -0,0 +1,20 @@ |
|||
# -*- 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', '0045_separation_membership_connection_p3'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='article', |
|||
name='need_membership', |
|||
field=models.BooleanField(default=True, verbose_name='can be purcharsed without membership'), |
|||
), |
|||
] |
|||
@ -0,0 +1,28 @@ |
|||
# -*- 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), |
|||
] |
|||
Loading…
Reference in new issue