Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
b57ef3ee
Commit
b57ef3ee
authored
Jul 27, 2016
by
chirac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Details, notamment pour faire plaisir à Mr Kermarec
parent
729683c9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
11 deletions
+26
-11
re2o/settings.py
re2o/settings.py
+2
-2
users/admin.py
users/admin.py
+1
-0
users/models.py
users/models.py
+21
-7
users/views.py
users/views.py
+2
-2
No files found.
re2o/settings.py
View file @
b57ef3ee
...
...
@@ -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'
],
}
...
...
users/admin.py
View file @
b57ef3ee
...
...
@@ -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
):
...
...
users/models.py
View file @
b57ef3ee
...
...
@@ -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
)
...
...
users/views.py
View file @
b57ef3ee
...
...
@@ -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
=
Edit
InfoForm
(
request
.
POST
or
None
,
instance
=
user
)
if
user
.
is_valid
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
user
.
save
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment