Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ares
re2o-ares-admin
Commits
cb5df29e
Commit
cb5df29e
authored
Jul 25, 2016
by
chirac
Browse files
Creation et modification des users du ldap avec re2o
parent
acde0322
Changes
2
Hide whitespace changes
Inline
Side-by-side
machines/models.py
View file @
cb5df29e
from
django.db
import
models
from
django.db.models.signals
import
post_save
,
post_delete
from
django.dispatch
import
receiver
from
django.forms
import
ValidationError
from
macaddress.fields
import
MACAddressField
class
Machine
(
models
.
Model
):
user
=
models
.
ForeignKey
(
'users.User'
,
on_delete
=
models
.
PROTECT
)
name
=
models
.
CharField
(
max_length
=
255
,
help_text
=
"Optionnel"
,
blank
=
True
,
null
=
True
)
...
...
@@ -38,6 +43,11 @@ class Interface(models.Model):
user
=
self
.
machine
.
user
return
machine
.
active
and
user
.
has_access
()
#def save(self, *args, **kwargs):
# user = self.machine.user
# user.ldap_sync(base=False, access_refresh=False, mac_refresh=True)
# super(Interface, self).save(*args, **kwargs)
def
__str__
(
self
):
return
self
.
dns
...
...
@@ -47,3 +57,13 @@ class IpList(models.Model):
def
__str__
(
self
):
return
self
.
ipv4
@
receiver
(
post_save
,
sender
=
Interface
)
def
interface_post_save
(
sender
,
**
kwargs
):
user
=
kwargs
[
'instance'
].
machine
.
user
user
.
ldap_sync
(
base
=
False
,
access_refresh
=
False
,
mac_refresh
=
True
)
@
receiver
(
post_delete
,
sender
=
Interface
)
def
interface_post_delete
(
sender
,
**
kwargs
):
user
=
kwargs
[
'instance'
].
machine
.
user
user
.
ldap_sync
(
base
=
False
,
access_refresh
=
False
,
mac_refresh
=
True
)
re2o/settings.py
View file @
cb5df29e
...
...
@@ -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
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
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
...
...
@@ -102,6 +102,8 @@ USE_L10N = True
USE_TZ
=
True
DATABASE_ROUTERS
=
[
'ldapdb.router.Router'
]
# django-bootstrap3 config dictionnary
BOOTSTRAP3
=
{
...
...
Write
Preview
Supports
Markdown
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