Commit 51c5fc81 authored by Gabriel Detraz's avatar Gabriel Detraz Committed by chirac

Defini un shell par defaut

parent cf286e27
# -*- 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),
),
]
# -*- 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,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' %}">
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment