From d34aaeb7c54040995fac8cef2df51b04adb78c19 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 2 Apr 2020 22:03:17 +0200 Subject: [PATCH 1/2] misc: style, PEP8 (#41284) --- .../management/commands/clean-unused-accounts.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/authentic2/management/commands/clean-unused-accounts.py b/src/authentic2/management/commands/clean-unused-accounts.py index 51445f97..6a0ce2f0 100644 --- a/src/authentic2/management/commands/clean-unused-accounts.py +++ b/src/authentic2/management/commands/clean-unused-accounts.py @@ -1,5 +1,5 @@ # authentic2 - versatile identity manager -# Copyright (C) 2010-2019 Entr'ouvert +# Copyright (C) 2010-2020 Entr'ouvert # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU Affero General Public License as published @@ -16,16 +16,14 @@ from __future__ import print_function -import json import logging import smtplib from datetime import timedelta from django.contrib.auth import get_user_model -from django.core.management.base import BaseCommand, CommandError +from django.core.management.base import BaseCommand from django.utils import timezone from django.utils.six.moves.urllib import parse as urlparse -from django.template.loader import render_to_string from django_rbac.utils import get_ou_model from authentic2.models import DeletedUser @@ -72,11 +70,10 @@ class Command(BaseCommand): for ou in get_ou_model().objects.filter(clean_unused_accounts_alert__isnull=False): alert_delay = timedelta(days=ou.clean_unused_accounts_alert) deletion_delay = timedelta(days=ou.clean_unused_accounts_deletion) - users = User.objects.filter(ou=ou, last_login__lte=now-alert_delay) + users = User.objects.filter(ou=ou, last_login__lte=now - alert_delay) for user in users.filter(last_account_deletion_alert__isnull=True): - logger.info('%s last login %d days ago, sending alert', user, - ou.clean_unused_accounts_alert) + logger.info('%s last login %d days ago, sending alert', user, ou.clean_unused_accounts_alert) self.send_alert(user) to_delete = users.filter( @@ -85,8 +82,9 @@ class Command(BaseCommand): last_account_deletion_alert__lte=now - (deletion_delay - alert_delay) ) for user in to_delete: - logger.info('%s last login more than %d days ago, deleting user', - user, ou.clean_unused_accounts_deletion) + logger.info( + '%s last login more than %d days ago, deleting user', user, + ou.clean_unused_accounts_deletion) self.delete_user(user) def send_alert(self, user): -- 2.24.0