8
0
Fork 0
mirror of https://gitlab.federez.net/re2o/re2o synced 2024-06-25 03:58:16 +00:00

Details, notamment pour faire plaisir à Mr Kermarec

This commit is contained in:
chirac 2016-07-27 02:39:19 +02:00
parent 729683c9bb
commit b57ef3eedb
4 changed files with 26 additions and 11 deletions

View file

@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/1.8/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME, LDAP_SETTINGS
from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME, LDAP
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -129,7 +129,7 @@ STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
RIGHTS_LINK = {
'cableur' : ['bureau','infra','bofh','trésorier','bofh'],
'cableur' : ['bureau','infra','bofh','trésorier'],
'bofh' : ['bureau','trésorier'],
}

View file

@ -23,6 +23,7 @@ class UserAdmin(admin.ModelAdmin):
class LdapUserAdmin(admin.ModelAdmin):
list_display = ('name','uidNumber','loginShell')
exclude = ('user_password','sambat_nt_password')
search_fields = ('name',)
class LdapUserGroupAdmin(admin.ModelAdmin):

View file

@ -8,7 +8,7 @@ from django.dispatch import receiver
import ldapdb.models
import ldapdb.models.fields
from re2o.settings import RIGHTS_LINK, REQ_EXPIRE_HRS, LDAP_SETTINGS
from re2o.settings import RIGHTS_LINK, REQ_EXPIRE_HRS, LDAP
import re, uuid
import datetime
@ -103,7 +103,7 @@ class User(AbstractBaseUser):
pseudo = models.CharField(max_length=32, unique=True, help_text="Doit contenir uniquement des lettres, chiffres, ou tirets", validators=[linux_user_validator])
email = models.EmailField()
school = models.ForeignKey('School', on_delete=models.PROTECT, null=False, blank=False)
shell = models.ForeignKey('ListShell', on_delete=models.PROTECT, null=False, blank=False, default=1)
shell = models.ForeignKey('ListShell', on_delete=models.PROTECT, null=True, blank=True)
comment = models.CharField(help_text="Commentaire, promo", max_length=255, blank=True)
room = models.OneToOneField('topologie.Room', on_delete=models.PROTECT, blank=True, null=True)
pwd_ntlm = models.CharField(max_length=255)
@ -237,9 +237,10 @@ class User(AbstractBaseUser):
user_ldap.home_directory = '/home/' + self.pseudo
user_ldap.mail = self.email
user_ldap.given_name = str(self.surname).lower() + '_' + str(self.name).lower()[:3]
user_ldap.gid = LDAP_SETTINGS['user_gid']
user_ldap.gid = LDAP['user_gid']
user_ldap.user_password = self.password
user_ldap.sambat_nt_password = self.pwd_ntlm
user_ldap.loginShell = self.shell.shell
if access_refresh:
user_ldap.dialupAccess = str(self.has_access())
if mac_refresh:
@ -377,7 +378,7 @@ class LdapUser(ldapdb.models.Model):
Class for representing an LDAP user entry.
"""
# LDAP meta-data
base_dn = LDAP_SETTINGS['base_user_dn']
base_dn = LDAP['base_user_dn']
object_classes = ['inetOrgPerson','top','posixAccount','sambaSamAccount','radiusprofile']
# attributes
@ -386,11 +387,11 @@ class LdapUser(ldapdb.models.Model):
uid = ldapdb.models.fields.CharField(db_column='uid', max_length=200)
uidNumber = ldapdb.models.fields.IntegerField(db_column='uidNumber', unique=True)
sn = ldapdb.models.fields.CharField(db_column='sn', max_length=200)
loginShell = ldapdb.models.fields.CharField(db_column='loginShell', max_length=200, default="/bin/zsh")
loginShell = ldapdb.models.fields.CharField(db_column='loginShell', max_length=200, blank=True, null=True)
mail = ldapdb.models.fields.CharField(db_column='mail', max_length=200)
given_name = ldapdb.models.fields.CharField(db_column='givenName', max_length=200)
home_directory = ldapdb.models.fields.CharField(db_column='homeDirectory', max_length=200)
display_name = ldapdb.models.fields.CharField(db_column='displayName', max_length=200)
display_name = ldapdb.models.fields.CharField(db_column='displayName', max_length=200, blank=True, null=True)
dialupAccess = ldapdb.models.fields.CharField(db_column='dialupAccess')
sambaSID = ldapdb.models.fields.IntegerField(db_column='sambaSID', unique=True)
user_password = ldapdb.models.fields.CharField(db_column='userPassword', max_length=200, blank=True, null=True)
@ -414,7 +415,7 @@ class LdapUserGroup(ldapdb.models.Model):
Class for representing an LDAP user entry.
"""
# LDAP meta-data
base_dn = LDAP_SETTINGS['base_usergroup_dn']
base_dn = LDAP['base_usergroup_dn']
object_classes = ['posixGroup']
# attributes
@ -448,6 +449,19 @@ class BaseInfoForm(ModelForm):
'room',
]
class EditInfoForm(BaseInfoForm):
class Meta(BaseInfoForm.Meta):
fields = [
'name',
'surname',
'pseudo',
'email',
'school',
'comment',
'room',
'shell',
]
class InfoForm(BaseInfoForm):
force = forms.BooleanField(label="Forcer le déménagement ?", initial=False, required=False)

View file

@ -17,7 +17,7 @@ from django.db import transaction
from reversion import revisions as reversion
from users.models import User, Right, Ban, Whitelist, School, ListRight, Request
from users.models import DelRightForm, BanForm, WhitelistForm, DelSchoolForm, DelListRightForm, NewListRightForm
from users.models import InfoForm, BaseInfoForm, StateForm, RightForm, SchoolForm, ListRightForm
from users.models import EditInfoForm, InfoForm, BaseInfoForm, StateForm, RightForm, SchoolForm, ListRightForm
from cotisations.models import Facture
from machines.models import Machine, Interface
from users.forms import PassForm, ResetPasswordForm
@ -109,7 +109,7 @@ def edit_info(request, userid):
if not request.user.has_perms(('cableur',)):
user = BaseInfoForm(request.POST or None, instance=user)
else:
user = InfoForm(request.POST or None, instance=user)
user = EditInfoForm(request.POST or None, instance=user)
if user.is_valid():
with transaction.atomic(), reversion.create_revision():
user.save()