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
e2ef4223
Commit
e2ef4223
authored
May 23, 2017
by
Asad Azam
Committed by
AsadAzam
May 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed change course admin 500 error
parent
952062f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
14 deletions
+17
-14
course_discovery/apps/publisher/tests/test_views.py
+8
-5
course_discovery/apps/publisher/views.py
+9
-9
No files found.
course_discovery/apps/publisher/tests/test_views.py
View file @
e2ef4223
...
...
@@ -1966,6 +1966,7 @@ class CourseEditViewTests(TestCase):
super
(
CourseEditViewTests
,
self
)
.
setUp
()
self
.
course
=
factories
.
CourseFactory
()
self
.
user
=
UserFactory
()
self
.
course_team_user
=
UserFactory
()
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
USER_PASSWORD
)
self
.
organization_extension
=
factories
.
OrganizationExtensionFactory
()
...
...
@@ -1974,8 +1975,10 @@ class CourseEditViewTests(TestCase):
# Initialize workflow for Course.
CourseState
.
objects
.
create
(
course
=
self
.
course
,
owner_role
=
PublisherUserRole
.
CourseTeam
)
self
.
course_team_role
=
factories
.
CourseUserRoleFactory
(
course
=
self
.
course
,
role
=
PublisherUserRole
.
CourseTeam
)
self
.
organization_extension
.
group
.
user_set
.
add
(
*
(
self
.
user
,
self
.
course_team_role
.
user
))
self
.
course_team_role
=
factories
.
CourseUserRoleFactory
(
course
=
self
.
course
,
role
=
PublisherUserRole
.
CourseTeam
,
user
=
self
.
user
)
self
.
organization_extension
.
group
.
user_set
.
add
(
*
(
self
.
user
,
self
.
course_team_user
))
self
.
edit_page_url
=
reverse
(
'publisher:publisher_courses_edit'
,
args
=
[
self
.
course
.
id
])
...
...
@@ -2079,7 +2082,7 @@ class CourseEditViewTests(TestCase):
target_status_code
=
200
)
self
.
assertEqual
(
self
.
course
.
course_team_admin
,
self
.
user
)
self
.
assertEqual
(
self
.
course
.
course_team_admin
,
self
.
course_team_
user
)
self
.
assertEqual
(
self
.
course
.
history
.
all
()
.
count
(),
2
)
def
test_update_course_organization
(
self
):
...
...
@@ -2090,7 +2093,7 @@ class CourseEditViewTests(TestCase):
# Create new OrganizationExtension and assign edit/view permissions.
organization_extension
=
factories
.
OrganizationExtensionFactory
()
organization_extension
.
group
.
user_set
.
add
(
*
(
self
.
user
,
self
.
course_team_
role
.
user
))
organization_extension
.
group
.
user_set
.
add
(
*
(
self
.
user
,
self
.
course_team_user
))
self
.
_assign_permissions
(
organization_extension
)
self
.
assertEqual
(
self
.
course
.
organizations
.
first
(),
self
.
organization_extension
.
organization
)
...
...
@@ -2120,7 +2123,7 @@ class CourseEditViewTests(TestCase):
"""
post_data
=
model_to_dict
(
self
.
course
)
post_data
.
pop
(
'image'
)
post_data
[
'team_admin'
]
=
self
.
user
.
id
post_data
[
'team_admin'
]
=
self
.
course_team_
user
.
id
post_data
[
'organization'
]
=
organization_extension
.
organization
.
id
return
post_data
...
...
course_discovery/apps/publisher/views.py
View file @
e2ef4223
...
...
@@ -377,15 +377,6 @@ class CourseEditView(mixins.PublisherPermissionMixin, UpdateView):
self
.
object
.
organizations
.
remove
(
self
.
object
.
organizations
.
first
())
self
.
object
.
organizations
.
add
(
organization_extension
.
organization
)
team_admin
=
form
.
cleaned_data
[
'team_admin'
]
if
self
.
object
.
course_team_admin
!=
team_admin
:
course_admin_role
=
get_object_or_404
(
CourseUserRole
,
course
=
self
.
object
,
role
=
PublisherUserRole
.
CourseTeam
)
course_admin_role
.
user
=
team_admin
course_admin_role
.
save
()
user_role
=
self
.
object
.
course_user_roles
.
get
(
user
=
user
)
# Change course state to draft if marketing not yet reviewed or
# if marketing person updating the course.
...
...
@@ -397,6 +388,15 @@ class CourseEditView(mixins.PublisherPermissionMixin, UpdateView):
if
self
.
object
.
course_state
.
owner_role
!=
user_role
.
role
:
self
.
object
.
course_state
.
change_owner_role
(
user_role
.
role
)
team_admin
=
form
.
cleaned_data
[
'team_admin'
]
if
self
.
object
.
course_team_admin
!=
team_admin
:
course_admin_role
=
get_object_or_404
(
CourseUserRole
,
course
=
self
.
object
,
role
=
PublisherUserRole
.
CourseTeam
)
course_admin_role
.
user
=
team_admin
course_admin_role
.
save
()
messages
.
success
(
self
.
request
,
_
(
'Course updated successfully.'
))
return
HttpResponseRedirect
(
self
.
get_success_url
())
...
...
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