Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uffd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luca (strifel)
uffd
Commits
6e7947d3
Verified
Commit
6e7947d3
authored
4 years ago
by
nd
Browse files
Options
Downloads
Patches
Plain Diff
remove all class attributes which are actualy instance attributes
parent
ffd888b1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
uffd/user/models.py
+8
-13
8 additions, 13 deletions
uffd/user/models.py
with
8 additions
and
13 deletions
uffd/user/models.py
+
8
−
13
View file @
6e7947d3
...
@@ -7,30 +7,29 @@ from flask import current_app
...
@@ -7,30 +7,29 @@ from flask import current_app
from
uffd
import
ldap
from
uffd
import
ldap
class
User
():
class
User
():
uid
=
None
loginname
=
None
displayname
=
None
mail
=
None
newpassword
=
None
def
__init__
(
self
,
uid
=
None
,
loginname
=
''
,
displayname
=
''
,
mail
=
''
,
groups
=
None
):
def
__init__
(
self
,
uid
=
None
,
loginname
=
''
,
displayname
=
''
,
mail
=
''
,
groups
=
None
):
self
.
uid
=
uid
self
.
uid
=
uid
self
.
loginname
=
loginname
self
.
loginname
=
loginname
self
.
displayname
=
displayname
self
.
displayname
=
displayname
self
.
mail
=
mail
self
.
mail
=
mail
if
isinstance
(
groups
,
str
):
groups
=
[
groups
]
self
.
groups_ldap
=
groups
or
[]
self
.
groups_ldap
=
groups
or
[]
self
.
_groups
=
None
self
.
_groups
=
None
self
.
newpassword
=
None
@classmethod
@classmethod
def
from_ldap
(
cls
,
ldapobject
):
def
from_ldap
(
cls
,
ldapobject
):
# if you are in no groups, the "memberOf" attribute does not exist
# if you are only in one group, ldap returns a string not an array with one element
# we sanitize this to always be an array
sanitized_groups
=
ldapobject
[
'
memberOf
'
].
value
if
'
memberOf
'
in
ldapobject
else
[]
if
isinstance
(
sanitized_groups
,
str
):
sanitized_groups
=
[
sanitized_groups
]
return
User
(
return
User
(
uid
=
ldapobject
[
'
uidNumber
'
].
value
,
uid
=
ldapobject
[
'
uidNumber
'
].
value
,
loginname
=
ldapobject
[
'
uid
'
].
value
,
loginname
=
ldapobject
[
'
uid
'
].
value
,
displayname
=
ldapobject
[
'
cn
'
].
value
,
displayname
=
ldapobject
[
'
cn
'
].
value
,
mail
=
ldapobject
[
'
mail
'
].
value
,
mail
=
ldapobject
[
'
mail
'
].
value
,
groups
=
ldapobject
[
'
memberOf
'
].
value
if
'
memberOf
'
in
ldapobject
else
[]
,
groups
=
sanitized_groups
,
)
)
@classmethod
@classmethod
...
@@ -118,10 +117,6 @@ class User():
...
@@ -118,10 +117,6 @@ class User():
return
True
return
True
class
Group
():
class
Group
():
gid
=
None
name
=
None
description
=
None
def
__init__
(
self
,
gid
=
None
,
name
=
''
,
members
=
None
,
description
=
''
):
def
__init__
(
self
,
gid
=
None
,
name
=
''
,
members
=
None
,
description
=
''
):
self
.
gid
=
gid
self
.
gid
=
gid
self
.
name
=
name
self
.
name
=
name
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment