Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
bf44109b
Commit
bf44109b
authored
Jun 05, 2017
by
Awais
Committed by
Awais Qureshi
Jun 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding new groups for publisher app.
Assign permissions also. ECOM-7857
parent
b65e75a6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
3 deletions
+45
-3
course_discovery/apps/publisher/assign_permissions.py
+8
-3
course_discovery/apps/publisher/constants.py
+3
-0
course_discovery/apps/publisher/migrations/0054_auto_20170605_0953.py
+34
-0
No files found.
course_discovery/apps/publisher/assign_permissions.py
View file @
bf44109b
from
django.contrib.auth.models
import
Group
from
django.contrib.auth.models
import
Group
from
guardian.shortcuts
import
assign_perm
from
guardian.shortcuts
import
assign_perm
from
course_discovery.apps.publisher.constants
import
(
LEGAL_TEAM_GROUP_NAME
,
PROJECT_COORDINATOR_GROUP_NAME
,
from
course_discovery.apps.publisher.constants
import
(
GENERAL_STAFF_GROUP_NAME
,
LEGAL_TEAM_GROUP_NAME
,
PARTNER_SUPPORT_GROUP_NAME
,
PROJECT_COORDINATOR_GROUP_NAME
,
REVIEWER_GROUP_NAME
)
REVIEWER_GROUP_NAME
)
from
course_discovery.apps.publisher.models
import
OrganizationExtension
from
course_discovery.apps.publisher.models
import
OrganizationExtension
...
@@ -32,12 +33,16 @@ def assign_permissions(organization_extension):
...
@@ -32,12 +33,16 @@ def assign_permissions(organization_extension):
assign_permissions_to_group
(
organization_extension
,
Group
.
objects
.
get
(
name
=
PROJECT_COORDINATOR_GROUP_NAME
),
assign_permissions_to_group
(
organization_extension
,
Group
.
objects
.
get
(
name
=
PROJECT_COORDINATOR_GROUP_NAME
),
pc_permissions
)
pc_permissions
)
# Assign view permissions to Legal Team group.
# Assign view permissions to Legal Team group.
legal_team
_permissions
=
[
view
_permissions
=
[
OrganizationExtension
.
VIEW_COURSE
,
OrganizationExtension
.
VIEW_COURSE
,
OrganizationExtension
.
VIEW_COURSE_RUN
OrganizationExtension
.
VIEW_COURSE_RUN
]
]
assign_permissions_to_group
(
organization_extension
,
Group
.
objects
.
get
(
name
=
LEGAL_TEAM_GROUP_NAME
),
assign_permissions_to_group
(
organization_extension
,
Group
.
objects
.
get
(
name
=
LEGAL_TEAM_GROUP_NAME
),
legal_team_permissions
)
view_permissions
)
assign_permissions_to_group
(
organization_extension
,
Group
.
objects
.
get
(
name
=
GENERAL_STAFF_GROUP_NAME
),
view_permissions
)
assign_permissions_to_group
(
organization_extension
,
Group
.
objects
.
get
(
name
=
PARTNER_SUPPORT_GROUP_NAME
),
view_permissions
)
def
assign_permissions_to_group
(
organization_extension
,
group
,
permissions
):
def
assign_permissions_to_group
(
organization_extension
,
group
,
permissions
):
...
...
course_discovery/apps/publisher/constants.py
View file @
bf44109b
...
@@ -9,5 +9,8 @@ REVIEWER_GROUP_NAME = 'Marketing Reviewers'
...
@@ -9,5 +9,8 @@ REVIEWER_GROUP_NAME = 'Marketing Reviewers'
PUBLISHER_GROUP_NAME
=
'Publishers'
PUBLISHER_GROUP_NAME
=
'Publishers'
LEGAL_TEAM_GROUP_NAME
=
'Legal Team Members'
LEGAL_TEAM_GROUP_NAME
=
'Legal Team Members'
GENERAL_STAFF_GROUP_NAME
=
'General Staff'
PARTNER_SUPPORT_GROUP_NAME
=
'Partner Support Members'
# Being used in old migration `0019_create_user_groups`.
# Being used in old migration `0019_create_user_groups`.
PARTNER_COORDINATOR_GROUP_NAME
=
'Partner Coordinators'
PARTNER_COORDINATOR_GROUP_NAME
=
'Partner Coordinators'
course_discovery/apps/publisher/migrations/0054_auto_20170605_0953.py
0 → 100644
View file @
bf44109b
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-06-05 09:53
from
__future__
import
unicode_literals
from
django.db
import
migrations
from
course_discovery.apps.publisher.constants
import
GENERAL_STAFF_GROUP_NAME
,
PARTNER_SUPPORT_GROUP_NAME
GROUPS
=
[
GENERAL_STAFF_GROUP_NAME
,
PARTNER_SUPPORT_GROUP_NAME
]
def
create_groups
(
apps
,
schema_editor
):
Group
=
apps
.
get_model
(
'auth'
,
'Group'
)
for
group
in
GROUPS
:
Group
.
objects
.
get_or_create
(
name
=
group
)
def
remove_groups
(
apps
,
schema_editor
):
Group
=
apps
.
get_model
(
'auth'
,
'Group'
)
for
group
in
GROUPS
:
Group
.
objects
.
filter
(
name
=
group
)
.
delete
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'publisher'
,
'0053_auto_20170604_1502'
),
]
operations
=
[
migrations
.
RunPython
(
create_groups
,
remove_groups
)
]
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