From 7458b5613865382b7d99c90e653a2067826c18b9 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Sat, 11 Jan 2020 18:33:11 +0000 Subject: [PATCH] FIX: Legacy Profiles are now auto-approved correctly --- RIGS/migrations/0036_profile_is_approved.py | 3 +-- RIGS/migrations/0037_auto_20200111_1829.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 RIGS/migrations/0037_auto_20200111_1829.py diff --git a/RIGS/migrations/0036_profile_is_approved.py b/RIGS/migrations/0036_profile_is_approved.py index 61fa93a1..515e00a9 100644 --- a/RIGS/migrations/0036_profile_is_approved.py +++ b/RIGS/migrations/0036_profile_is_approved.py @@ -13,7 +13,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='profile', name='is_approved', - # Approve existing profiles automatically, new ones default false. - field=models.BooleanField(default=True), + field=models.BooleanField(default=False), ), ] diff --git a/RIGS/migrations/0037_auto_20200111_1829.py b/RIGS/migrations/0037_auto_20200111_1829.py new file mode 100644 index 00000000..72348b3f --- /dev/null +++ b/RIGS/migrations/0037_auto_20200111_1829.py @@ -0,0 +1,19 @@ +# Generated by Django 2.0.13 on 2020-01-11 18:29 +# This migration ensures that legacy Profiles from before approvals were implemented are automatically approved +from django.db import migrations + +def approve_legacy(apps, schema_editor): + Profile = apps.get_model('RIGS', 'Profile') + for person in Profile.objects.all(): + person.is_approved = True + person.save() + +class Migration(migrations.Migration): + + dependencies = [ + ('RIGS', '0036_profile_is_approved'), + ] + + operations = [ + migrations.RunPython(approve_legacy) + ]