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
radiopanik
panikdb
Commits
ad74ccdd
Commit
ad74ccdd
authored
Sep 21, 2013
by
fred
Browse files
bits of permission management
parent
b3a63c86
Changes
1
Hide whitespace changes
Inline
Side-by-side
panikdb/aa/models.py
View file @
ad74ccdd
...
...
@@ -4,9 +4,19 @@ from django.contrib.auth.models import AbstractUser
from
django.core
import
validators
from
django.db
import
models
from
emissions.models
import
Emission
,
NewsCategory
from
emissions.models
import
Emission
,
Episode
,
NewsItem
,
NewsCategory
class
User
(
AbstractUser
):
emissions
=
models
.
ManyToManyField
(
Emission
,
null
=
True
,
blank
=
True
)
news_categories
=
models
.
ManyToManyField
(
NewsCategory
,
null
=
True
,
blank
=
True
)
def
can_manage
(
self
,
object
):
if
self
.
is_staff
:
return
True
if
isinstance
(
object
,
Emission
):
return
object
in
self
.
emissions
.
all
()
if
isinstance
(
object
,
Episode
):
return
object
.
emission
in
self
.
emissions
.
all
()
if
isinstance
(
object
,
NewsItem
):
return
object
.
emission
in
self
.
emissions
.
all
()
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