mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 11:53:12 +00:00
Add self pseudo setting
This commit is contained in:
parent
bd9a227cae
commit
bcb9e097ac
6 changed files with 412 additions and 314 deletions
|
@ -66,10 +66,19 @@ class EditOptionalUserForm(ModelForm):
|
||||||
self.fields["gpg_fingerprint"].label = _("GPG fingerprint")
|
self.fields["gpg_fingerprint"].label = _("GPG fingerprint")
|
||||||
self.fields["all_can_create_club"].label = _("All can create a club")
|
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["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["self_adhesion"].label = _("Self registration")
|
|
||||||
self.fields["shell_default"].label = _("Default shell")
|
self.fields["shell_default"].label = _("Default shell")
|
||||||
self.fields["allow_set_password_during_user_creation"].label = _("Allow directly setting a password during account creation")
|
self.fields["self_change_shell"].label = _("Self change shell")
|
||||||
|
self.fields["self_change_pseudo"].label = _("Self change pseudo")
|
||||||
|
self.fields["self_room_policy"].label = _("Self room policy")
|
||||||
|
self.fields["local_email_accounts_enabled"].label = _("Local email accounts enabled")
|
||||||
|
self.fields["local_email_domain"].label = _("Local email domain")
|
||||||
|
self.fields["max_email_address"].label = _("Max local email address")
|
||||||
|
self.fields["delete_notyetactive"].label = _("Delete not yet active users")
|
||||||
|
self.fields["disable_emailnotyetconfirmed"].label = _("Disabled email not yet confirmed")
|
||||||
|
self.fields["self_adhesion"].label = _("Self registration")
|
||||||
|
self.fields["all_users_active"].label = _("All users are state active by default")
|
||||||
|
self.fields["allow_set_password_during_user_creation"].label = _("Allow set password during user creation")
|
||||||
|
self.fields["allow_archived_connexion"].label = _("Allow archived connexion")
|
||||||
|
|
||||||
|
|
||||||
class EditOptionalMachineForm(ModelForm):
|
class EditOptionalMachineForm(ModelForm):
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.28 on 2020-04-23 09:01
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('preferences', '0070_auto_20200419_0225'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='optionaluser',
|
||||||
|
name='self_change_pseudo',
|
||||||
|
field=models.BooleanField(default=True, help_text='Users can edit their pseudo.'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -99,6 +99,9 @@ class OptionalUser(AclMixin, PreferencesModel):
|
||||||
self_change_shell = models.BooleanField(
|
self_change_shell = models.BooleanField(
|
||||||
default=False, help_text=_("Users can edit their shell.")
|
default=False, help_text=_("Users can edit their shell.")
|
||||||
)
|
)
|
||||||
|
self_change_pseudo = models.BooleanField(
|
||||||
|
default=True, help_text=_("Users can edit their pseudo.")
|
||||||
|
)
|
||||||
self_room_policy = models.CharField(
|
self_room_policy = models.CharField(
|
||||||
max_length=32,
|
max_length=32,
|
||||||
choices=ROOM_POLICY,
|
choices=ROOM_POLICY,
|
||||||
|
|
|
@ -154,6 +154,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Policy for self-user room change" %}</th>
|
<th>{% trans "Policy for self-user room change" %}</th>
|
||||||
<td>{{ useroptions.self_room_policy }}</td>
|
<td>{{ useroptions.self_room_policy }}</td>
|
||||||
|
<th>{% trans "Users can edit their pseudo" %}</th>
|
||||||
|
<td>{{ useroptions.self_change_pseudo|tick }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<h4 id="users">{% trans "Local email accounts settings" %}</h4>
|
<h4 id="users">{% trans "Local email accounts settings" %}</h4>
|
||||||
|
|
|
@ -1168,6 +1168,28 @@ class User(
|
||||||
else:
|
else:
|
||||||
return True, None, None
|
return True, None, None
|
||||||
|
|
||||||
|
def can_change_pseudo(self, user_request, *_args, **_kwargs):
|
||||||
|
""" Check if a user can change a pseudo
|
||||||
|
|
||||||
|
:param user_request: The user who request
|
||||||
|
:returns: a message and a boolean which is True if the user has
|
||||||
|
the right to change a shell
|
||||||
|
"""
|
||||||
|
if not (
|
||||||
|
(
|
||||||
|
self.pk == user_request.pk
|
||||||
|
and OptionalUser.get_cached_value("self_change_pseudo")
|
||||||
|
)
|
||||||
|
or user_request.has_perm("users.change_user_shell")
|
||||||
|
):
|
||||||
|
return (
|
||||||
|
False,
|
||||||
|
_("You don't have the right to change the shell."),
|
||||||
|
("users.change_user_shell",),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return True, None, None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def can_change_local_email_redirect(user_request, *_args, **_kwargs):
|
def can_change_local_email_redirect(user_request, *_args, **_kwargs):
|
||||||
""" Check if a user can change local_email_redirect.
|
""" Check if a user can change local_email_redirect.
|
||||||
|
@ -1314,6 +1336,7 @@ class User(
|
||||||
super(User, self).__init__(*args, **kwargs)
|
super(User, self).__init__(*args, **kwargs)
|
||||||
self.field_permissions = {
|
self.field_permissions = {
|
||||||
"shell": self.can_change_shell,
|
"shell": self.can_change_shell,
|
||||||
|
"pseudo": self.can_change_pseudo,
|
||||||
"force": self.can_change_force,
|
"force": self.can_change_force,
|
||||||
"selfpasswd": self.check_selfpasswd,
|
"selfpasswd": self.check_selfpasswd,
|
||||||
"local_email_redirect": self.can_change_local_email_redirect,
|
"local_email_redirect": self.can_change_local_email_redirect,
|
||||||
|
|
Loading…
Reference in a new issue