first commit
This commit is contained in:
commit
b54624be96
226 files changed
+108840
No files matched your search
@@ -0,0 +1,45 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def migrate_legacy_statuses(apps, schema_editor):
|
||||
User = apps.get_model("accounts", "User")
|
||||
for user in User.objects.all():
|
||||
if user.status == "superadmin":
|
||||
new_status = "director_admin"
|
||||
flags = {"is_active": True, "is_staff": True, "is_superuser": True}
|
||||
elif user.status == "active":
|
||||
new_status = "gm"
|
||||
flags = {"is_active": True, "is_staff": False, "is_superuser": False}
|
||||
elif user.status == "inactive":
|
||||
new_status = "inactive"
|
||||
flags = {"is_active": False, "is_staff": False, "is_superuser": False}
|
||||
else:
|
||||
continue
|
||||
User.objects.filter(pk=user.pk).update(status=new_status, **flags)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("accounts", "0004_sync_status_flags"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="user",
|
||||
name="status",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
("inactive", "Inactive"),
|
||||
("gm", "GM"),
|
||||
("gm_admin", "GM Admin"),
|
||||
("buh", "BUH"),
|
||||
("bu_admin", "BU Admin"),
|
||||
("director", "Director"),
|
||||
("director_admin", "Director Admin"),
|
||||
],
|
||||
default="gm",
|
||||
max_length=30,
|
||||
),
|
||||
),
|
||||
migrations.RunPython(migrate_legacy_statuses, migrations.RunPython.noop),
|
||||
]
|
||||
Reference in new issue
Block a user