diff --git a/club/migrations/0010_auto_20170912_2028.py b/club/migrations/0010_auto_20170912_2028.py index d6e28063..aa49fc4b 100644 --- a/club/migrations/0010_auto_20170912_2028.py +++ b/club/migrations/0010_auto_20170912_2028.py @@ -3,19 +3,6 @@ from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models -from club.models import Club -from core.operations import PsqlRunOnly - - -def generate_club_pages(apps, schema_editor): - def recursive_generate_club_page(club): - club.make_page() - for child in Club.objects.filter(parent=club).all(): - recursive_generate_club_page(child) - - for club in Club.objects.filter(parent=None).all(): - recursive_generate_club_page(club) - class Migration(migrations.Migration): dependencies = [("core", "0024_auto_20170906_1317"), ("club", "0010_club_logo")] @@ -48,11 +35,4 @@ class Migration(migrations.Migration): null=True, ), ), - PsqlRunOnly( - "SET CONSTRAINTS ALL IMMEDIATE", reverse_sql=migrations.RunSQL.noop - ), - migrations.RunPython(generate_club_pages), - PsqlRunOnly( - migrations.RunSQL.noop, reverse_sql="SET CONSTRAINTS ALL IMMEDIATE" - ), ] diff --git a/counter/migrations/0013_customer_recorded_products.py b/counter/migrations/0013_customer_recorded_products.py index f2a48ba5..72825d16 100644 --- a/counter/migrations/0013_customer_recorded_products.py +++ b/counter/migrations/0013_customer_recorded_products.py @@ -1,38 +1,6 @@ from __future__ import unicode_literals -from django.conf import settings from django.db import migrations, models -from django.utils.translation import gettext_lazy as _ - -from core.models import User -from counter.models import Counter, Customer, Product, Selling - - -def balance_ecocups(apps, schema_editor): - for customer in Customer.objects.all(): - customer.recorded_products = 0 - for selling in customer.buyings.filter( - product__id__in=[settings.SITH_ECOCUP_CONS, settings.SITH_ECOCUP_DECO] - ).all(): - if selling.product.is_record_product: - customer.recorded_products += selling.quantity - elif selling.product.is_unrecord_product: - customer.recorded_products -= selling.quantity - if customer.recorded_products < -settings.SITH_ECOCUP_LIMIT: - qt = -(customer.recorded_products + settings.SITH_ECOCUP_LIMIT) - cons = Product.objects.get(id=settings.SITH_ECOCUP_CONS) - Selling( - label=_("Ecocup regularization"), - product=cons, - unit_price=cons.selling_price, - club=cons.club, - counter=Counter.objects.filter(name="Foyer").first(), - quantity=qt, - seller=User.objects.get(id=0), - customer=customer, - ).save(allow_negative=True) - customer.recorded_products += qt - customer.save() class Migration(migrations.Migration): @@ -44,5 +12,4 @@ class Migration(migrations.Migration): name="recorded_products", field=models.IntegerField(verbose_name="recorded items", default=0), ), - migrations.RunPython(balance_ecocups), ] diff --git a/pedagogy/migrations/0002_auto_20190827_2251.py b/pedagogy/migrations/0002_auto_20190827_2251.py index 2b1f4b36..7fbe05a8 100644 --- a/pedagogy/migrations/0002_auto_20190827_2251.py +++ b/pedagogy/migrations/0002_auto_20190827_2251.py @@ -25,26 +25,11 @@ from __future__ import unicode_literals from django.db import migrations -from core.models import User - - -def remove_multiples_comments_from_same_user(apps, schema_editor): - for user in User.objects.exclude(uv_comments=None).prefetch_related("uv_comments"): - for uv in user.uv_comments.values("uv").distinct(): - last = ( - user.uv_comments.filter(uv__id=uv["uv"]) - .order_by("-publish_date") - .first() - ) - user.uv_comments.filter(uv__id=uv["uv"]).exclude(pk=last.pk).delete() - class Migration(migrations.Migration): dependencies = [("pedagogy", "0001_initial")] - operations = [ - migrations.RunPython( - remove_multiples_comments_from_same_user, - reverse_code=migrations.RunPython.noop, - ) - ] + # This migration contained just a RunPython operation + # Which has since been removed. + # The migration itself is kept in order not to break the migration tree + operations = []