mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
parent
be7ffbcb90
commit
60186071db
17 changed files with 32 additions and 59 deletions
|
@ -513,9 +513,8 @@ 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.User.STATE_EMAIL_NOT_YET_CONFIRMED)
|
||||
| Q(state=users.STATE_EMAIL_NOT_YET_CONFIRMED)
|
||||
| Q(state=users.User.STATE_FULL_ARCHIVE)
|
||||
| Q(state=users.User.STATE_SUSPENDED)
|
||||
)
|
||||
serializer_class = serializers.BasicUserSerializer
|
||||
|
||||
|
|
|
@ -247,10 +247,6 @@ 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"
|
||||
|
|
|
@ -270,16 +270,6 @@ 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(),
|
||||
|
|
|
@ -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["suspend_emailnotyetconfirmed"].label = _("Delay before suspending accounts without a verified email")
|
||||
self.fields["disable_emailnotyetconfirmed"].label = _("Delay before disabling 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")
|
||||
|
|
|
@ -287,11 +287,11 @@ msgstr ""
|
|||
|
||||
#: preferences/models.py:111
|
||||
msgid ""
|
||||
"Users with an email address not yet confirmed will be suspended after"
|
||||
"Users with an email address not yet confirmed will be disabled after"
|
||||
" this number of days."
|
||||
msgstr ""
|
||||
"Les utilisateurs n'ayant pas confirmé leur addresse mail seront"
|
||||
" suspendus après ce nombre de jours"
|
||||
" désactivés 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 suspending accounts without a verified email"
|
||||
msgstr "Délai avant la suspension des comptes sans adresse mail confirmé"
|
||||
msgid "Delay before disabling accounts without a verified email"
|
||||
msgstr "Délai avant la désactivation des comptes sans adresse mail confirmé"
|
||||
|
||||
#: preferences/templates/preferences/display_preferences.html:136
|
||||
msgid "Users general permissions"
|
||||
|
|
|
@ -14,8 +14,8 @@ class Migration(migrations.Migration):
|
|||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='optionaluser',
|
||||
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.')
|
||||
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.')
|
||||
),
|
||||
]
|
||||
|
||||
|
|
|
@ -107,10 +107,10 @@ class OptionalUser(AclMixin, PreferencesModel):
|
|||
"Not yet active users will be deleted after this number of days."
|
||||
),
|
||||
)
|
||||
suspend_emailnotyetconfirmed = models.IntegerField(
|
||||
disable_emailnotyetconfirmed = models.IntegerField(
|
||||
default=2,
|
||||
help_text=_(
|
||||
"Users with an email address not yet confirmed will be suspended after this number of days."
|
||||
"Users with an email address not yet confirmed will be disabled after this number of days."
|
||||
),
|
||||
)
|
||||
self_adhesion = models.BooleanField(
|
||||
|
|
|
@ -131,8 +131,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<tr>
|
||||
<th>{% trans "Allow directly entering a password during account creation" %}</th>
|
||||
<td>{{ useroptions.allow_set_password_during_user_creation|tick }}</td>
|
||||
<th>{% trans "Delay before suspending accounts without a verified email" %}</th>
|
||||
<td>{% blocktrans with suspend_emailnotyetconfirmed=useroptions.suspend_emailnotyetconfirmed %}{{ suspend_emailnotyetconfirmed }} days{% endblocktrans %}</td>
|
||||
<th>{% trans "Delay before disabling accounts without a verified email" %}</th>
|
||||
<td>{% blocktrans with disable_emailnotyetconfirmed=useroptions.disable_emailnotyetconfirmed %}{{ disable_emailnotyetconfirmed }} days{% endblocktrans %}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ CHOICES_USER = (
|
|||
("3", _("Not yet active")),
|
||||
("4", _("Fully archived")),
|
||||
("5", _("Waiting for email confirmation")),
|
||||
("6", _("Suspended")),
|
||||
)
|
||||
|
||||
CHOICES_AFF = (
|
||||
|
|
|
@ -54,10 +54,6 @@ 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"
|
||||
|
|
|
@ -388,13 +388,9 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
|||
|
||||
if not self.is_anon and self.initial["email"] and user.email != self.initial["email"]:
|
||||
# Send a confirmation email
|
||||
# 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:
|
||||
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
|
||||
self.should_send_confirmation_email = True
|
||||
|
||||
# Always keep the oldest change date
|
||||
if user.email_change_date is None:
|
||||
|
|
|
@ -28,13 +28,13 @@ from django.utils import timezone
|
|||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Delete non members users (not yet active or suspended too long ago without an invoice)."
|
||||
help = "Delete non members users (not yet active or disabled 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("delete_notyetactive")
|
||||
days = OptionalUser.get_cached_value("disable_emailnotyetconfirmed")
|
||||
users_to_delete = (
|
||||
User.objects.filter(Q(state=User.STATE_NOT_YET_ACTIVE) | Q(state=User.STATE_SUSPENDED))
|
||||
User.objects.filter(Q(state=User.STATE_NOT_YET_ACTIVE) | Q(state=User.STATE_DISABLED))
|
||||
.filter(registered__lte=timezone.now() - timedelta(days=days))
|
||||
.exclude(facture__valid=True)
|
||||
.distinct()
|
||||
|
|
|
@ -25,19 +25,19 @@ from django.utils import timezone
|
|||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Suspend users who haven't confirmed their email."
|
||||
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("suspend_emailnotyetconfirmed")
|
||||
users_to_suspend = (
|
||||
days = OptionalUser.get_cached_value("disable_emailnotyetconfirmed")
|
||||
users_to_disable = (
|
||||
User.objects.filter(state=User.STATE_EMAIL_NOT_YET_CONFIRMED)
|
||||
.filter(email_change_date__lte=timezone.now() - timedelta(days=days))
|
||||
.distinct()
|
||||
)
|
||||
print("Suspending " + str(users_to_suspend.count()) + " users.")
|
||||
print("Disabling " + str(users_to_disable.count()) + " users.")
|
||||
|
||||
for user in users_to_suspend:
|
||||
user.state = User.STATE_SUSPENDED
|
||||
user.notif_suspension()
|
||||
for user in users_to_disable:
|
||||
user.state = User.STATE_DISABLED
|
||||
user.notif_disable()
|
||||
user.save()
|
||||
|
|
|
@ -174,13 +174,12 @@ class User(
|
|||
Champs principaux : name, surnname, pseudo, email, room, password
|
||||
Herite du django BaseUser et du système d'auth django"""
|
||||
|
||||
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_ACTIVE = 0
|
||||
STATE_DISABLED = 1
|
||||
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")),
|
||||
|
@ -188,7 +187,6 @@ class User(
|
|||
(3, _("Not yet active")),
|
||||
(4, _("Fully archived")),
|
||||
(5, _("Waiting for email confirmation")),
|
||||
(5, _("Suspended")),
|
||||
)
|
||||
|
||||
surname = models.CharField(max_length=255)
|
||||
|
@ -397,7 +395,7 @@ class User(
|
|||
@cached_property
|
||||
def get_shadow_expire(self):
|
||||
"""Return the shadow_expire value for the user"""
|
||||
if self.state == self.STATE_DISABLED or self.STATE_SUSPENDED:
|
||||
if self.state == self.STATE_DISABLED:
|
||||
return str(0)
|
||||
else:
|
||||
return None
|
||||
|
@ -692,7 +690,6 @@ 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:
|
||||
|
@ -813,7 +810,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("suspend_emailnotyetconfirmed")
|
||||
days = OptionalUser.get_cached_value("disable_emailnotyetconfirmed")
|
||||
return self.email_change_date + timedelta(days=days)
|
||||
|
||||
def confirm_email_address_mail(self, request):
|
||||
|
@ -900,9 +897,9 @@ class User(
|
|||
)
|
||||
return
|
||||
|
||||
def notif_suspension(self):
|
||||
def notif_disable(self):
|
||||
"""Envoi un mail de notification informant que l'adresse mail n'a pas été confirmée"""
|
||||
template = loader.get_template("users/email_suspension_notif")
|
||||
template = loader.get_template("users/email_disable_notif")
|
||||
context = {
|
||||
"name": self.get_full_name(),
|
||||
"asso_name": AssoOption.get_cached_value("name"),
|
||||
|
|
|
@ -50,7 +50,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% blocktrans %}Didn't receive the email?{% endblocktrans %}
|
||||
</a>
|
||||
</div>
|
||||
{% elif users.state == users.STATE_SUSPENDED %}
|
||||
{% elif users.state == users.STATE_DISABLED %}
|
||||
<div class="alert alert-danger">
|
||||
{% blocktrans %}Your account has been suspended.{% endblocktrans %}
|
||||
</div>
|
||||
|
|
|
@ -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, User.STATE_SUSPENDED],
|
||||
state__in=[User.STATE_ACTIVE, User.STATE_NOT_YET_ACTIVE, User.STATE_EMAIL_NOT_YET_CONFIRMED],
|
||||
)
|
||||
except User.DoesNotExist:
|
||||
messages.error(request, _("The user doesn't exist."))
|
||||
|
|
Loading…
Reference in a new issue