8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-28 09:53:47 +00:00

Defini un shell par defaut

This commit is contained in:
Gabriel Detraz 2018-03-24 21:19:52 +01:00 committed by chirac
parent cf286e2732
commit 51c5fc8126
5 changed files with 59 additions and 3 deletions

View 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),
),
]

View 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'),
),
]

View file

@ -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 = (

View file

@ -68,7 +68,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr>
<th>Auto inscription</th>
<td>{{ useroptions.self_adhesion }}</td>
</tr>
<th>Shell par défaut des utilisateurs</th>
<td>{{ useroptions.shell_default }}</td>
</tr>
</table>
<h4>Préférences machines</h4>
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'OptionalMachine' %}">

View file

@ -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: