mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-29 02:13:46 +00:00
Add option to select number of days before disabling users
This commit is contained in:
parent
4a733aaf77
commit
b991a3f45f
3 changed files with 17 additions and 8 deletions
|
@ -107,6 +107,12 @@ class OptionalUser(AclMixin, PreferencesModel):
|
|||
"Not yet active users will be deleted after this number of days."
|
||||
),
|
||||
)
|
||||
disable_emailnotyetconfirmed = models.IntegerField(
|
||||
default=2,
|
||||
help_text=_(
|
||||
"Users with an email address not yet confirmed will be disabled after this number of days."
|
||||
),
|
||||
)
|
||||
self_adhesion = models.BooleanField(
|
||||
default=False, help_text=_("A new user can create their account on Re2o.")
|
||||
)
|
||||
|
|
|
@ -125,13 +125,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<tr>
|
||||
<th>{% trans "All users are active by default" %}</th>
|
||||
<td>{{ useroptions.all_users_active|tick }}</td>
|
||||
<th>{% trans "Allow directly entering a password during account creation" %}</th>
|
||||
<td>{{ useroptions.allow_set_password_during_user_creation|tick }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "Allow archived users to log in" %}</th>
|
||||
<td>{{ useroptions.allow_archived_connexion|tick }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "Allow directly entering a password during account creation" %}</th>
|
||||
<td>{{ useroptions.allow_set_password_during_user_creation|tick }}</td>
|
||||
<th>{% trans "Disable email not yet confirmed users after" %}</th>
|
||||
<td>{% blocktrans with disable_emailnotyetconfirmed=useroptions.disable_emailnotyetconfirmed %}{{ disable_emailnotyetconfirmed }} days{% endblocktrans %}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h4 id="users">{% trans "Users general permissions" %}</h4>
|
||||
|
|
|
@ -27,16 +27,17 @@ from django.utils import timezone
|
|||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Delete non members users (not yet active)."
|
||||
help = "Disable users who haven't confirmed their email."
|
||||
|
||||
def handle(self, *args, **options):
|
||||
"""First deleting invalid invoices, and then deleting the users"""
|
||||
days = OptionalUser.get_cached_value("delete_notyetactive")
|
||||
days = OptionalUser.get_cached_value("disable_emailnotyetconfirmed")
|
||||
users_to_disable = (
|
||||
User.objects.filter(state=User.STATE_EMAIL_NOT_YET_CONFIRMED)
|
||||
.filter(registered__lte=timezone.now() - timedelta(days=days))
|
||||
.distinct()
|
||||
)
|
||||
print("Disabling " + str(users_to_disable.count()) + " users.")
|
||||
|
||||
users_to_disable.delete()
|
||||
|
||||
for user in users_to_disable:
|
||||
self.state = User.STATE_DISABLED
|
||||
|
|
Loading…
Reference in a new issue