Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
36cf540f
authored
Feb 11, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add group profile
Closes
#52
parent
61deebe3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
circle/dashboard/migrations/0004_auto__add_groupprofile.py
+0
-0
circle/dashboard/models.py
+31
-2
No files found.
circle/dashboard/migrations/0004_auto__add_groupprofile.py
0 → 100644
View file @
36cf540f
This diff is collapsed.
Click to expand it.
circle/dashboard/models.py
View file @
36cf540f
from
itertools
import
chain
from
logging
import
getLogger
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
,
Group
from
django.contrib.auth.signals
import
user_logged_in
from
django.db.models
import
(
Model
,
ForeignKey
,
OneToOneField
,
CharField
,
IntegerField
Model
,
ForeignKey
,
OneToOneField
,
CharField
,
IntegerField
,
TextField
)
from
django.utils.translation
import
ugettext_lazy
as
_
from
vm.models
import
Instance
from
acl.models
import
AclBase
logger
=
getLogger
(
__name__
)
...
...
@@ -30,6 +32,33 @@ class Profile(Model):
instance_limit
=
IntegerField
(
default
=
5
)
class
GroupProfile
(
AclBase
):
ACL_LEVELS
=
(
(
'operator'
,
_
(
'operator'
)),
(
'owner'
,
_
(
'owner'
)),
)
group
=
OneToOneField
(
Group
)
org_id
=
CharField
(
unique
=
True
,
blank
=
True
,
null
=
True
,
max_length
=
64
,
help_text
=
_
(
'Unique identifier of the group at the organization.'
))
description
=
TextField
()
@classmethod
def
search
(
cls
,
name
):
try
:
return
cls
.
objects
.
get
(
org_id
=
name
)
.
group
except
cls
.
DoesNotExist
:
return
Group
.
objects
.
get
(
name
=
name
)
def
get_or_create_profile
(
self
):
obj
,
created
=
GroupProfile
.
objects
.
get_or_create
(
pk
=
self
.
pk
)
return
obj
Group
.
profile
=
property
(
get_or_create_profile
)
def
create_profile
(
sender
,
user
,
request
,
**
kwargs
):
if
not
user
.
pk
:
return
False
...
...
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