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
cccffba1
Commit
cccffba1
authored
Jan 18, 2017
by
Waheed Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Course run edit page scope.
ECOM-6714
parent
cd7e2d84
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
5 deletions
+54
-5
course_discovery/apps/publisher/tests/test_views.py
+49
-0
course_discovery/apps/publisher/urls.py
+1
-1
course_discovery/apps/publisher/views.py
+4
-4
No files found.
course_discovery/apps/publisher/tests/test_views.py
View file @
cccffba1
...
@@ -1674,3 +1674,52 @@ class CourseEditViewTests(TestCase):
...
@@ -1674,3 +1674,52 @@ class CourseEditViewTests(TestCase):
self
.
user
.
groups
.
add
(
Group
.
objects
.
get
(
name
=
ADMIN_GROUP_NAME
))
self
.
user
.
groups
.
add
(
Group
.
objects
.
get
(
name
=
ADMIN_GROUP_NAME
))
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
class
CourseRunEditViewTests
(
TestCase
):
""" Tests for the course run edit view. """
def
setUp
(
self
):
super
(
CourseRunEditViewTests
,
self
)
.
setUp
()
self
.
course_run
=
factories
.
CourseRunFactory
()
self
.
user
=
UserFactory
()
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
USER_PASSWORD
)
self
.
organization_extension
=
factories
.
OrganizationExtensionFactory
()
self
.
course_run
.
course
.
organizations
.
add
(
self
.
organization_extension
.
organization
)
self
.
edit_page_url
=
reverse
(
'publisher:publisher_course_runs_edit'
,
args
=
[
self
.
course_run
.
id
])
def
test_edit_page_without_permission
(
self
):
"""
Verify that user cannot access course run edit page without edit permission.
"""
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_edit_page_with_edit_permission
(
self
):
"""
Verify that user can access course run edit page with edit permission.
"""
self
.
user
.
groups
.
add
(
self
.
organization_extension
.
group
)
assign_perm
(
OrganizationExtension
.
EDIT_COURSE_RUN
,
self
.
organization_extension
.
group
,
self
.
organization_extension
)
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_edit_page_with_internal_user
(
self
):
"""
Verify that internal user can access course run edit page.
"""
self
.
user
.
groups
.
add
(
Group
.
objects
.
get
(
name
=
INTERNAL_USER_GROUP_NAME
))
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_edit_page_with_admin
(
self
):
"""
Verify that publisher admin can access course run edit page.
"""
self
.
user
.
groups
.
add
(
Group
.
objects
.
get
(
name
=
ADMIN_GROUP_NAME
))
response
=
self
.
client
.
get
(
self
.
edit_page_url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
course_discovery/apps/publisher/urls.py
View file @
cccffba1
...
@@ -18,7 +18,7 @@ urlpatterns = [
...
@@ -18,7 +18,7 @@ urlpatterns = [
name
=
'publisher_course_runs_new'
name
=
'publisher_course_runs_new'
),
),
url
(
r'^course_runs/(?P<pk>\d+)/$'
,
views
.
CourseRunDetailView
.
as_view
(),
name
=
'publisher_course_run_detail'
),
url
(
r'^course_runs/(?P<pk>\d+)/$'
,
views
.
CourseRunDetailView
.
as_view
(),
name
=
'publisher_course_run_detail'
),
url
(
r'^course_runs/(?P<pk>\d+)/edit/$'
,
views
.
UpdateCourseRun
View
.
as_view
(),
name
=
'publisher_course_runs_edit'
),
url
(
r'^course_runs/(?P<pk>\d+)/edit/$'
,
views
.
CourseRunEdit
View
.
as_view
(),
name
=
'publisher_course_runs_edit'
),
url
(
url
(
r'^course_runs/(?P<pk>\d+)/change_state/$'
,
views
.
ChangeStateView
.
as_view
(),
r'^course_runs/(?P<pk>\d+)/change_state/$'
,
views
.
ChangeStateView
.
as_view
(),
name
=
'publisher_change_state'
name
=
'publisher_change_state'
...
...
course_discovery/apps/publisher/views.py
View file @
cccffba1
...
@@ -388,17 +388,17 @@ class CreateCourseRunView(mixins.LoginRequiredMixin, CreateView):
...
@@ -388,17 +388,17 @@ class CreateCourseRunView(mixins.LoginRequiredMixin, CreateView):
return
render
(
request
,
self
.
template_name
,
context
,
status
=
400
)
return
render
(
request
,
self
.
template_name
,
context
,
status
=
400
)
class
UpdateCourseRunView
(
mixins
.
LoginRequiredMixin
,
mixins
.
PublisherPermissionMixin
,
mixins
.
FormValidMixin
,
UpdateView
):
# pylint: disable=line-too-long
class
CourseRunEditView
(
mixins
.
LoginRequiredMixin
,
mixins
.
PublisherPermissionMixin
,
mixins
.
FormValidMixin
,
UpdateView
):
"""
Update Course Run
View."""
"""
Course Run Edit
View."""
model
=
CourseRun
model
=
CourseRun
form_class
=
CourseRunForm
form_class
=
CourseRunForm
permission
=
OrganizationExtension
.
VIEW_COURSE
permission
=
OrganizationExtension
.
EDIT_COURSE_RUN
template_name
=
'publisher/course_run_form.html'
template_name
=
'publisher/course_run_form.html'
success_url
=
'publisher:publisher_course_runs_edit'
success_url
=
'publisher:publisher_course_runs_edit'
change_state
=
True
change_state
=
True
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UpdateCourseRun
View
,
self
)
.
get_context_data
(
**
kwargs
)
context
=
super
(
CourseRunEdit
View
,
self
)
.
get_context_data
(
**
kwargs
)
if
not
self
.
object
:
if
not
self
.
object
:
self
.
object
=
self
.
get_object
()
self
.
object
=
self
.
get_object
()
context
[
'workflow_state'
]
=
self
.
object
.
current_state
context
[
'workflow_state'
]
=
self
.
object
.
current_state
...
...
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