Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
3c747f0e
Commit
3c747f0e
authored
May 07, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consolidate the list of permissions
parent
81ecf0c5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
common/djangoapps/django_comment_common/utils.py
+14
-12
No files found.
common/djangoapps/django_comment_common/utils.py
View file @
3c747f0e
from
django_comment_common.models
import
Role
from
django_comment_common.models
import
Role
_STUDENT_ROLE_PERMISSIONS
=
[
"vote"
,
"update_thread"
,
"follow_thread"
,
"unfollow_thread"
,
"update_comment"
,
"create_sub_comment"
,
"unvote"
,
"create_thread"
,
"follow_commentable"
,
"unfollow_commentable"
,
"create_comment"
,
]
_MODERATOR_ROLE_PERMISSIONS
=
[
"edit_content"
,
"delete_thread"
,
"openclose_thread"
,
"endorse_comment"
,
"delete_comment"
,
"see_all_cohorts"
]
_ADMINISTRATOR_ROLE_PERMISSIONS
=
[
"manage_moderator"
]
def
seed_permissions_roles
(
course_id
):
def
seed_permissions_roles
(
course_id
):
administrator_role
=
Role
.
objects
.
get_or_create
(
name
=
"Administrator"
,
course_id
=
course_id
)[
0
]
administrator_role
=
Role
.
objects
.
get_or_create
(
name
=
"Administrator"
,
course_id
=
course_id
)[
0
]
...
@@ -7,16 +15,13 @@ def seed_permissions_roles(course_id):
...
@@ -7,16 +15,13 @@ def seed_permissions_roles(course_id):
community_ta_role
=
Role
.
objects
.
get_or_create
(
name
=
"Community TA"
,
course_id
=
course_id
)[
0
]
community_ta_role
=
Role
.
objects
.
get_or_create
(
name
=
"Community TA"
,
course_id
=
course_id
)[
0
]
student_role
=
Role
.
objects
.
get_or_create
(
name
=
"Student"
,
course_id
=
course_id
)[
0
]
student_role
=
Role
.
objects
.
get_or_create
(
name
=
"Student"
,
course_id
=
course_id
)[
0
]
for
per
in
[
"vote"
,
"update_thread"
,
"follow_thread"
,
"unfollow_thread"
,
for
per
in
_STUDENT_ROLE_PERMISSIONS
:
"update_comment"
,
"create_sub_comment"
,
"unvote"
,
"create_thread"
,
"follow_commentable"
,
"unfollow_commentable"
,
"create_comment"
,
]:
student_role
.
add_permission
(
per
)
student_role
.
add_permission
(
per
)
for
per
in
[
"edit_content"
,
"delete_thread"
,
"openclose_thread"
,
for
per
in
_MODERATOR_ROLE_PERMISSIONS
:
"endorse_comment"
,
"delete_comment"
,
"see_all_cohorts"
]:
moderator_role
.
add_permission
(
per
)
moderator_role
.
add_permission
(
per
)
for
per
in
[
"manage_moderator"
]
:
for
per
in
_ADMINISTRATOR_ROLE_PERMISSIONS
:
administrator_role
.
add_permission
(
per
)
administrator_role
.
add_permission
(
per
)
moderator_role
.
inherit_permissions
(
student_role
)
moderator_role
.
inherit_permissions
(
student_role
)
...
@@ -36,18 +41,15 @@ def are_permissions_roles_seeded(course_id):
...
@@ -36,18 +41,15 @@ def are_permissions_roles_seeded(course_id):
except
:
except
:
return
False
return
False
for
per
in
[
"vote"
,
"update_thread"
,
"follow_thread"
,
"unfollow_thread"
,
for
per
in
_STUDENT_ROLE_PERMISSIONS
:
"update_comment"
,
"create_sub_comment"
,
"unvote"
,
"create_thread"
,
"follow_commentable"
,
"unfollow_commentable"
,
"create_comment"
,
]:
if
not
student_role
.
has_permission
(
per
):
if
not
student_role
.
has_permission
(
per
):
return
False
return
False
for
per
in
[
"edit_content"
,
"delete_thread"
,
"openclose_thread"
,
for
per
in
_MODERATOR_ROLE_PERMISSIONS
+
_STUDENT_ROLE_PERMISSIONS
:
"endorse_comment"
,
"delete_comment"
,
"see_all_cohorts"
]:
if
not
moderator_role
.
has_permission
(
per
):
if
not
moderator_role
.
has_permission
(
per
):
return
False
return
False
for
per
in
[
"manage_moderator"
]
:
for
per
in
_ADMINISTRATOR_ROLE_PERMISSIONS
+
_MODERATOR_ROLE_PERMISSIONS
+
_STUDENT_ROLE_PERMISSIONS
:
if
not
administrator_role
.
has_permission
(
per
):
if
not
administrator_role
.
has_permission
(
per
):
return
False
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