mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-09-12 09:13:08 +00:00
Add option enabling regular users to take a disabled user's room
This commit is contained in:
parent
4017850e7e
commit
ae7f1aaf38
5 changed files with 58 additions and 2 deletions
|
@ -268,6 +268,10 @@ msgstr "Les utilisateurs peuvent créer un adhérent."
|
||||||
msgid "Users can edit their shell."
|
msgid "Users can edit their shell."
|
||||||
msgstr "Les utilisateurs peuvent modifier leur interface en ligne de commande."
|
msgstr "Les utilisateurs peuvent modifier leur interface en ligne de commande."
|
||||||
|
|
||||||
|
#: preferences/models.py:92
|
||||||
|
msgid "Users can select a room occupied by a user with a disabled connection."
|
||||||
|
msgstr "Les utilisateurs peuvent sélectionner la chambre d'un adhérent dont la connexion est désactivée."
|
||||||
|
|
||||||
#: preferences/models.py:90
|
#: preferences/models.py:90
|
||||||
msgid "Users can edit their room."
|
msgid "Users can edit their room."
|
||||||
msgstr "Les utilisateurs peuvent modifier leur chambre."
|
msgstr "Les utilisateurs peuvent modifier leur chambre."
|
||||||
|
@ -1111,6 +1115,10 @@ msgstr "Les utilisateurs peuvent modifier leur interface en ligne de commande"
|
||||||
msgid "Users can edit their room"
|
msgid "Users can edit their room"
|
||||||
msgstr "Les utilisateurs peuvent modifier leur chambre"
|
msgstr "Les utilisateurs peuvent modifier leur chambre"
|
||||||
|
|
||||||
|
#: preferences/templates/preferences/display_preferences.html:144
|
||||||
|
msgid "Users can select a room occupied by a user with a disabled connection"
|
||||||
|
msgstr "Les utilisateurs peuvent sélectionner la chambre d'un adhérent dont la connexion est désactivée"
|
||||||
|
|
||||||
#: preferences/templates/preferences/display_preferences.html:154
|
#: preferences/templates/preferences/display_preferences.html:154
|
||||||
msgid "GPG fingerprint field"
|
msgid "GPG fingerprint field"
|
||||||
msgstr "Champ empreinte GPG"
|
msgstr "Champ empreinte GPG"
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.28 on 2020-04-15 16:35
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('preferences', '0067_auto_20191120_0159'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='optionaluser',
|
||||||
|
name='self_force_move_disabled_user_room',
|
||||||
|
field=models.BooleanField(default=False, help_text='Users can select a room occupied by a user with a dissabled connection.'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -89,6 +89,9 @@ class OptionalUser(AclMixin, PreferencesModel):
|
||||||
self_change_room = models.BooleanField(
|
self_change_room = models.BooleanField(
|
||||||
default=False, help_text=_("Users can edit their room.")
|
default=False, help_text=_("Users can edit their room.")
|
||||||
)
|
)
|
||||||
|
self_force_move_disabled_user_room = models.BooleanField(
|
||||||
|
default=False, help_text=_("Users can select a room occupied by a user with a disabled connection.")
|
||||||
|
)
|
||||||
local_email_accounts_enabled = models.BooleanField(
|
local_email_accounts_enabled = models.BooleanField(
|
||||||
default=False, help_text=_("Enable local email accounts for users.")
|
default=False, help_text=_("Enable local email accounts for users.")
|
||||||
)
|
)
|
||||||
|
|
|
@ -147,10 +147,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Users can edit their room" %}</th>
|
<th>{% trans "Users can edit their room" %}</th>
|
||||||
<td>{{ useroptions.self_change_room|tick }}</td>
|
<td>{{ useroptions.self_change_room|tick }}</td>
|
||||||
<th>{% trans "Telephone number required" %}</th>
|
<th>{% trans "Users can select a room occupied by a user with a disabled connection" %}</th>
|
||||||
<td>{{ useroptions.is_tel_mandatory|tick }}</td>
|
<td>{{ useroptions.self_force_move_disabled_user_room|tick }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>{% trans "Telephone number required" %}</th>
|
||||||
|
<td>{{ useroptions.is_tel_mandatory|tick }}</td>
|
||||||
<th>{% trans "GPG fingerprint field" %}</th>
|
<th>{% trans "GPG fingerprint field" %}</th>
|
||||||
<td>{{ useroptions.gpg_fingerprint|tick }}</td>
|
<td>{{ useroptions.gpg_fingerprint|tick }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -351,6 +351,29 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
||||||
label=_("Force the move?"), initial=False, required=False
|
label=_("Force the move?"), initial=False, required=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
# Handle case where regular users can force move
|
||||||
|
can_force_move = OptionalUser.get_cached_value("self_force_move_disabled_user_room")
|
||||||
|
if not can_force_move:
|
||||||
|
return super(AdherentForm, self).clean()
|
||||||
|
|
||||||
|
# Ensure the user entered a proper room
|
||||||
|
room = self.cleaned_data.get("room")
|
||||||
|
if not room:
|
||||||
|
return super(AdherentForm, self).clean()
|
||||||
|
|
||||||
|
try:
|
||||||
|
# If a user already is register for this room
|
||||||
|
# but their connection has expired, allow force move
|
||||||
|
user = Adherent.objects.get(room=room)
|
||||||
|
if user and not user.is_connected():
|
||||||
|
remove_user_room(room)
|
||||||
|
except Adherent.DoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Run standard clean process
|
||||||
|
return super(AdherentForm, self).clean()
|
||||||
|
|
||||||
def clean_email(self):
|
def clean_email(self):
|
||||||
if not OptionalUser.objects.first().local_email_domain in self.cleaned_data.get(
|
if not OptionalUser.objects.first().local_email_domain in self.cleaned_data.get(
|
||||||
"email"
|
"email"
|
||||||
|
|
Loading…
Reference in a new issue