mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-16 00:13:12 +00:00
Defini un shell par defaut
This commit is contained in:
parent
cf286e2732
commit
51c5fc8126
5 changed files with 59 additions and 3 deletions
20
preferences/migrations/0031_auto_20180323_0218.py
Normal file
20
preferences/migrations/0031_auto_20180323_0218.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2018-03-23 01:18
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('preferences', '0030_merge_20180320_1419'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='generaloption',
|
||||
name='email_from',
|
||||
field=models.EmailField(default='www-data@example.com', max_length=254),
|
||||
),
|
||||
]
|
22
preferences/migrations/0032_optionaluser_shell_default.py
Normal file
22
preferences/migrations/0032_optionaluser_shell_default.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2018-03-24 19:22
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0070_auto_20180324_1906'),
|
||||
('preferences', '0031_auto_20180323_0218'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='optionaluser',
|
||||
name='shell_default',
|
||||
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='users.ListShell'),
|
||||
),
|
||||
]
|
|
@ -89,6 +89,12 @@ class OptionalUser(PreferencesModel):
|
|||
default=False,
|
||||
help_text="Un nouvel utilisateur peut se créer son compte sur re2o"
|
||||
)
|
||||
shell_default = models.OneToOneField(
|
||||
'users.ListShell',
|
||||
on_delete=models.PROTECT,
|
||||
blank=True,
|
||||
null=True
|
||||
)
|
||||
|
||||
class Meta:
|
||||
permissions = (
|
||||
|
|
|
@ -68,6 +68,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<tr>
|
||||
<th>Auto inscription</th>
|
||||
<td>{{ useroptions.self_adhesion }}</td>
|
||||
<th>Shell par défaut des utilisateurs</th>
|
||||
<td>{{ useroptions.shell_default }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h4>Préférences machines</h4>
|
||||
|
|
|
@ -300,6 +300,12 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
|
|||
""" Renvoie seulement le nom"""
|
||||
return self.surname
|
||||
|
||||
@property
|
||||
def get_shell(self):
|
||||
""" A utiliser de préférence, prend le shell par défaut
|
||||
si il n'est pas défini"""
|
||||
return self.shell or OptionalUser.get_cached_value('shell_default')
|
||||
|
||||
def end_adhesion(self):
|
||||
""" Renvoie la date de fin d'adhésion d'un user. Examine les objets
|
||||
cotisation"""
|
||||
|
@ -502,8 +508,8 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
|
|||
user_ldap.gid = LDAP['user_gid']
|
||||
user_ldap.user_password = self.password[:6] + self.password[7:]
|
||||
user_ldap.sambat_nt_password = self.pwd_ntlm.upper()
|
||||
if self.shell:
|
||||
user_ldap.login_shell = self.shell.shell
|
||||
if self.get_shell:
|
||||
user_ldap.login_shell = str(self.get_shell)
|
||||
if self.state == self.STATE_DISABLED:
|
||||
user_ldap.shadowexpire = str(0)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue