diff --git a/api/views.py b/api/views.py
index 58730754..5dae2bba 100644
--- a/api/views.py
+++ b/api/views.py
@@ -513,8 +513,9 @@ class HomeCreationViewSet(viewsets.ReadOnlyModelViewSet):
queryset = users.User.objects.exclude(
Q(state=users.User.STATE_DISABLED)
| Q(state=users.User.STATE_NOT_YET_ACTIVE)
- | Q(state=users.STATE_EMAIL_NOT_YET_CONFIRMED)
+ | Q(state=users.User.STATE_EMAIL_NOT_YET_CONFIRMED)
| Q(state=users.User.STATE_FULL_ARCHIVE)
+ | Q(state=users.User.STATE_SUSPENDED)
)
serializer_class = serializers.BasicUserSerializer
diff --git a/logs/locale/fr/LC_MESSAGES/django.po b/logs/locale/fr/LC_MESSAGES/django.po
index 92dbb89b..6268b05b 100644
--- a/logs/locale/fr/LC_MESSAGES/django.po
+++ b/logs/locale/fr/LC_MESSAGES/django.po
@@ -247,6 +247,10 @@ msgstr "Utilisateurs pas encore actifs"
msgid "Waiting for email confirmation users"
msgstr "Utilisateurs en attente de confirmation d'email"
+#: logs/views.py:273
+msgid "Suspended users"
+msgstr "Utilisateurs suspendus"
+
#: logs/views.py:273
msgid "Contributing members"
msgstr "Adhérents cotisants"
diff --git a/logs/views.py b/logs/views.py
index 615fb69b..69ec5635 100644
--- a/logs/views.py
+++ b/logs/views.py
@@ -270,6 +270,16 @@ def stats_general(request):
),
Club.objects.filter(state=Club.STATE_EMAIL_NOT_YET_CONFIRMED).count(),
],
+ "suspended_users": [
+ _("Suspended users"),
+ User.objects.filter(state=User.STATE_SUSPENDED).count(),
+ (
+ Adherent.objects.filter(
+ state=Adherent.STATE_SUSPENDED
+ ).count()
+ ),
+ Club.objects.filter(state=Club.STATE_SUSPENDED).count(),
+ ],
"adherent_users": [
_("Contributing members"),
_all_adherent.count(),
diff --git a/preferences/forms.py b/preferences/forms.py
index b296c0d4..1fdefa6a 100644
--- a/preferences/forms.py
+++ b/preferences/forms.py
@@ -66,7 +66,7 @@ class EditOptionalUserForm(ModelForm):
self.fields["gpg_fingerprint"].label = _("GPG fingerprint")
self.fields["all_can_create_club"].label = _("All can create a club")
self.fields["all_can_create_adherent"].label = _("All can create a member")
- self.fields["disable_emailnotyetconfirmed"].label = _("Delay before disabling accounts without a verified email")
+ self.fields["suspend_emailnotyetconfirmed"].label = _("Delay before suspending accounts without a verified email")
self.fields["self_adhesion"].label = _("Self registration")
self.fields["shell_default"].label = _("Default shell")
self.fields["allow_set_password_during_user_creation"].label = _("Allow directly setting a password during account creation")
diff --git a/preferences/locale/fr/LC_MESSAGES/django.po b/preferences/locale/fr/LC_MESSAGES/django.po
index e7ac2e66..caa5719c 100644
--- a/preferences/locale/fr/LC_MESSAGES/django.po
+++ b/preferences/locale/fr/LC_MESSAGES/django.po
@@ -287,11 +287,11 @@ msgstr ""
#: preferences/models.py:111
msgid ""
-"Users with an email address not yet confirmed will be disabled after"
+"Users with an email address not yet confirmed will be suspended after"
" this number of days."
msgstr ""
"Les utilisateurs n'ayant pas confirmé leur addresse mail seront"
-" désactivés après ce nombre de jours"
+" suspendus après ce nombre de jours"
#: preferences/models.py:114
msgid "A new user can create their account on Re2o."
@@ -1083,8 +1083,8 @@ msgid "Allow directly entering a password during account creation"
msgstr "Permettre le choix d'un mot de passe directement lors de la création du compte"
#: preferences/templates/preferences/display_preferences.html:136
-msgid "Delay before disabling accounts without a verified email"
-msgstr "Délai avant la désactivation des comptes sans adresse mail confirmé"
+msgid "Delay before suspending accounts without a verified email"
+msgstr "Délai avant la suspension des comptes sans adresse mail confirmé"
#: preferences/templates/preferences/display_preferences.html:136
msgid "Users general permissions"
diff --git a/preferences/migrations/0069_optionaluser_disable_emailnotyetconfirmed.py b/preferences/migrations/0069_optionaluser_disable_emailnotyetconfirmed.py
index 3cc12081..137211ff 100644
--- a/preferences/migrations/0069_optionaluser_disable_emailnotyetconfirmed.py
+++ b/preferences/migrations/0069_optionaluser_disable_emailnotyetconfirmed.py
@@ -14,8 +14,8 @@ class Migration(migrations.Migration):
operations = [
migrations.AddField(
model_name='optionaluser',
- name='disable_emailnotyetconfirmed',
- field=models.IntegerField(default=2, help_text='Users with an email address not yet confirmed will be disabled after this number of days.')
+ name='suspend_emailnotyetconfirmed',
+ field=models.IntegerField(default=2, help_text='Users with an email address not yet confirmed will be suspended after this number of days.')
),
]
diff --git a/preferences/models.py b/preferences/models.py
index e470303d..360f2e51 100644
--- a/preferences/models.py
+++ b/preferences/models.py
@@ -107,10 +107,10 @@ class OptionalUser(AclMixin, PreferencesModel):
"Not yet active users will be deleted after this number of days."
),
)
- disable_emailnotyetconfirmed = models.IntegerField(
+ suspend_emailnotyetconfirmed = models.IntegerField(
default=2,
help_text=_(
- "Users with an email address not yet confirmed will be disabled after this number of days."
+ "Users with an email address not yet confirmed will be suspended after this number of days."
),
)
self_adhesion = models.BooleanField(
diff --git a/preferences/templates/preferences/display_preferences.html b/preferences/templates/preferences/display_preferences.html
index 8eb75918..6ccb1b2f 100644
--- a/preferences/templates/preferences/display_preferences.html
+++ b/preferences/templates/preferences/display_preferences.html
@@ -131,8 +131,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% trans "Allow directly entering a password during account creation" %} |
{{ useroptions.allow_set_password_during_user_creation|tick }} |
- {% trans "Delay before disabling accounts without a verified email" %} |
- {% blocktrans with disable_emailnotyetconfirmed=useroptions.disable_emailnotyetconfirmed %}{{ disable_emailnotyetconfirmed }} days{% endblocktrans %} |
+ {% trans "Delay before suspending accounts without a verified email" %} |
+ {% blocktrans with suspend_emailnotyetconfirmed=useroptions.suspend_emailnotyetconfirmed %}{{ suspend_emailnotyetconfirmed }} days{% endblocktrans %} |
diff --git a/search/forms.py b/search/forms.py
index 741a15e8..a49b92e7 100644
--- a/search/forms.py
+++ b/search/forms.py
@@ -36,6 +36,7 @@ CHOICES_USER = (
("3", _("Not yet active")),
("4", _("Fully archived")),
("5", _("Waiting for email confirmation")),
+ ("6", _("Suspended")),
)
CHOICES_AFF = (
diff --git a/search/locale/fr/LC_MESSAGES/django.po b/search/locale/fr/LC_MESSAGES/django.po
index 6da1a477..4c34f29d 100644
--- a/search/locale/fr/LC_MESSAGES/django.po
+++ b/search/locale/fr/LC_MESSAGES/django.po
@@ -54,6 +54,10 @@ msgstr "Complètement archivés"
msgid "Waiting for email confirmation"
msgstr "En attente de confirmation d'email"
+#: search/forms.py:39
+msgid "Suspended"
+msgstr "Suspendu"
+
#: search/forms.py:41
msgid "Users"
msgstr "Utilisateurs"
diff --git a/users/forms.py b/users/forms.py
index ad5c3708..52f4232b 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -388,10 +388,14 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
if not self.is_anon and self.initial["email"] and user.email != self.initial["email"]:
# Send a confirmation email
- if user.state in [User.STATE_ACTIVE, User.STATE_DISABLED, User.STATE_NOT_YET_ACTIVE, User.STATE_EMAIL_NOT_YET_CONFIRMED]:
- user.state = User.STATE_EMAIL_NOT_YET_CONFIRMED
+ # Don't do this for archived or disabled users
+ if user.state not in [User.STATE_ARCHIVE, User.STATE_FULL_ARCHIVE, User.STATE_DISABLED]:
self.should_send_confirmation_email = True
+ # Suspend users stay suspended
+ if user.state == User.STATE_SUSPENDED:
+ user.state = User.STATE_EMAIL_NOT_YET_CONFIRMED
+
# Always keep the oldest change date
if user.email_change_date is None:
user.email_change_date = timezone.now()
diff --git a/users/management/commands/clean_notyetactive.py b/users/management/commands/clean_notyetactive.py
index d1857096..5ca68827 100644
--- a/users/management/commands/clean_notyetactive.py
+++ b/users/management/commands/clean_notyetactive.py
@@ -28,13 +28,13 @@ from django.utils import timezone
class Command(BaseCommand):
- help = "Delete non members users (not yet active or disabled too long ago without an invoice)."
+ help = "Delete non members users (not yet active or suspended too long ago without an invoice)."
def handle(self, *args, **options):
"""First deleting invalid invoices, and then deleting the users"""
- days = OptionalUser.get_cached_value("disable_emailnotyetconfirmed")
+ days = OptionalUser.get_cached_value("delete_notyetactive")
users_to_delete = (
- User.objects.filter(Q(state=User.STATE_NOT_YET_ACTIVE) | Q(state=User.STATE_DISABLED))
+ User.objects.filter(Q(state=User.STATE_NOT_YET_ACTIVE) | Q(state=User.STATE_SUSPENDED))
.filter(registered__lte=timezone.now() - timedelta(days=days))
.exclude(facture__valid=True)
.distinct()
diff --git a/users/management/commands/disable_emailnotyetconfirmed.py b/users/management/commands/disable_emailnotyetconfirmed.py
index 955234e5..e0cd6d5e 100644
--- a/users/management/commands/disable_emailnotyetconfirmed.py
+++ b/users/management/commands/disable_emailnotyetconfirmed.py
@@ -25,19 +25,19 @@ from django.utils import timezone
class Command(BaseCommand):
- help = "Disable users who haven't confirmed their email."
+ help = "Suspend 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("disable_emailnotyetconfirmed")
- users_to_disable = (
+ days = OptionalUser.get_cached_value("suspend_emailnotyetconfirmed")
+ users_to_suspend = (
User.objects.filter(state=User.STATE_EMAIL_NOT_YET_CONFIRMED)
.filter(email_change_date__lte=timezone.now() - timedelta(days=days))
.distinct()
)
- print("Disabling " + str(users_to_disable.count()) + " users.")
+ print("Suspending " + str(users_to_suspend.count()) + " users.")
- for user in users_to_disable:
- user.state = User.STATE_DISABLED
- user.notif_disable()
+ for user in users_to_suspend:
+ user.state = User.STATE_SUSPENDED
+ user.notif_suspension()
user.save()
diff --git a/users/models.py b/users/models.py
index 397dc7f3..36884115 100755
--- a/users/models.py
+++ b/users/models.py
@@ -174,12 +174,13 @@ class User(
Champs principaux : name, surnname, pseudo, email, room, password
Herite du django BaseUser et du système d'auth django"""
- STATE_ACTIVE = 0
- STATE_DISABLED = 1
+ STATE_ACTIVE = 0 # Can login and has Internet (if invoice is valid)
+ STATE_DISABLED = 1 # Cannot login to Re2o and doesn't have Internet
STATE_ARCHIVE = 2
STATE_NOT_YET_ACTIVE = 3
STATE_FULL_ARCHIVE = 4
STATE_EMAIL_NOT_YET_CONFIRMED = 5
+ STATE_SUSPENDED = 6 # Can login to Re2o but doesn't have Internet
STATES = (
(0, _("Active")),
(1, _("Disabled")),
@@ -187,6 +188,7 @@ class User(
(3, _("Not yet active")),
(4, _("Fully archived")),
(5, _("Waiting for email confirmation")),
+ (5, _("Suspended")),
)
surname = models.CharField(max_length=255)
@@ -395,7 +397,7 @@ class User(
@cached_property
def get_shadow_expire(self):
"""Return the shadow_expire value for the user"""
- if self.state == self.STATE_DISABLED:
+ if self.state == self.STATE_DISABLED or self.STATE_SUSPENDED:
return str(0)
else:
return None
@@ -690,6 +692,7 @@ class User(
or self.state == self.STATE_EMAIL_NOT_YET_CONFIRMED
or self.state == self.STATE_ARCHIVE
or self.state == self.STATE_DISABLED
+ or self.state == self.STATE_SUSPENDED
):
self.refresh_from_db()
try:
@@ -810,7 +813,7 @@ class User(
if self.email_change_date is None or self.state != self.STATE_EMAIL_NOT_YET_CONFIRMED:
return None
- days = OptionalUser.get_cached_value("disable_emailnotyetconfirmed")
+ days = OptionalUser.get_cached_value("suspend_emailnotyetconfirmed")
return self.email_change_date + timedelta(days=days)
def confirm_email_address_mail(self, request):
@@ -897,9 +900,9 @@ class User(
)
return
- def notif_disable(self):
+ def notif_suspension(self):
"""Envoi un mail de notification informant que l'adresse mail n'a pas été confirmée"""
- template = loader.get_template("users/email_disable_notif")
+ template = loader.get_template("users/email_suspension_notif")
context = {
"name": self.get_full_name(),
"asso_name": AssoOption.get_cached_value("name"),
diff --git a/users/templates/users/email_disable_notif b/users/templates/users/email_suspension_notif
similarity index 100%
rename from users/templates/users/email_disable_notif
rename to users/templates/users/email_suspension_notif
diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html
index ed613537..e6878927 100644
--- a/users/templates/users/profil.html
+++ b/users/templates/users/profil.html
@@ -50,7 +50,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% blocktrans %}Didn't receive the email?{% endblocktrans %}
-{% elif users.state == users.STATE_DISABLED %}
+{% elif users.state == users.STATE_SUSPENDED %}
{% blocktrans %}Your account has been suspended.{% endblocktrans %}
diff --git a/users/views.py b/users/views.py
index fb5f8d73..0f7fee24 100644
--- a/users/views.py
+++ b/users/views.py
@@ -981,7 +981,7 @@ def reset_password(request):
user = User.objects.get(
pseudo=userform.cleaned_data["pseudo"],
email=userform.cleaned_data["email"],
- state__in=[User.STATE_ACTIVE, User.STATE_NOT_YET_ACTIVE, User.STATE_EMAIL_NOT_YET_CONFIRMED],
+ state__in=[User.STATE_ACTIVE, User.STATE_NOT_YET_ACTIVE, User.STATE_EMAIL_NOT_YET_CONFIRMED, User.STATE_SUSPENDED],
)
except User.DoesNotExist:
messages.error(request, _("The user doesn't exist."))