Crée des utilisateurs inactifs pour les élections avec liste, pour ne pas les inclure dans la réinitialisation de mdp
This commit is contained in:
parent
870b16cea5
commit
408aa51e5b
2 changed files with 22 additions and 0 deletions
21
elections/migrations/0033_inactive_users.py
Normal file
21
elections/migrations/0033_inactive_users.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Generated by Django 3.2.6 on 2021-10-04 07:49
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def set_users_inactive(apps, schema_editor):
|
||||
db_alias = schema_editor.connection.alias
|
||||
User = apps.get_model("elections", "User")
|
||||
|
||||
User.objects.using(db_alias).filter(election__isnull=False).update(is_active=False)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("elections", "0032_auto_20210820_0023"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(set_users_inactive, migrations.RunPython.noop),
|
||||
]
|
|
@ -334,6 +334,7 @@ def create_users(election, csv_file):
|
|||
username=f"{election.id}__{username}",
|
||||
email=email,
|
||||
full_name=full_name,
|
||||
is_active=False,
|
||||
)
|
||||
for (username, full_name, email) in reader
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue