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
91b7a255
Commit
91b7a255
authored
May 16, 2017
by
Waheed Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed authorized user can see edit button on course list page.
LEARNER-884
parent
7ccb4597
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
10 deletions
+35
-10
course_discovery/apps/publisher/templatetags/__init__.py
+0
-0
course_discovery/apps/publisher/templatetags/publisher_extras.py
+18
-0
course_discovery/apps/publisher/tests/test_views.py
+9
-3
course_discovery/templates/publisher/courses.html
+8
-7
No files found.
course_discovery/apps/publisher/templatetags/__init__.py
0 → 100644
View file @
91b7a255
course_discovery/apps/publisher/templatetags/publisher_extras.py
0 → 100644
View file @
91b7a255
from
django
import
template
from
course_discovery.apps.publisher.mixins
import
check_course_organization_permission
from
course_discovery.apps.publisher.models
import
OrganizationExtension
from
course_discovery.apps.publisher.utils
import
has_role_for_course
register
=
template
.
Library
()
def
can_edit
(
course
,
user
,
permission
):
return
check_course_organization_permission
(
user
,
course
,
permission
)
and
has_role_for_course
(
course
,
user
)
@register.filter
def
can_edit_course
(
course
,
user
):
return
can_edit
(
course
,
user
,
OrganizationExtension
.
EDIT_COURSE
)
course_discovery/apps/publisher/tests/test_views.py
View file @
91b7a255
...
@@ -1533,10 +1533,16 @@ class CourseListViewTests(TestCase):
...
@@ -1533,10 +1533,16 @@ class CourseListViewTests(TestCase):
def
test_page_with_disable_waffle_switch
(
self
):
def
test_page_with_disable_waffle_switch
(
self
):
"""
"""
Verify that edit button will be shown if 'publisher_hide_features_for_pilot' dectivated.
Verify that edit button will be shown if 'publisher_hide_features_for_pilot' de
a
ctivated.
"""
"""
self
.
user
.
groups
.
add
(
Group
.
objects
.
get
(
name
=
INTERNAL_USER_GROUP_NAME
))
organization_extension
=
factories
.
OrganizationExtensionFactory
()
factories
.
CourseUserRoleFactory
(
course
=
self
.
course
,
user
=
self
.
user
)
self
.
course
.
organizations
.
add
(
organization_extension
.
organization
)
self
.
user
.
groups
.
add
(
organization_extension
.
group
)
factories
.
CourseUserRoleFactory
(
course
=
self
.
course
,
user
=
self
.
user
,
role
=
PublisherUserRole
.
CourseTeam
)
assign_perm
(
OrganizationExtension
.
VIEW_COURSE
,
organization_extension
.
group
,
organization_extension
)
assign_perm
(
OrganizationExtension
.
EDIT_COURSE
,
organization_extension
.
group
,
organization_extension
)
toggle_switch
(
'publisher_hide_features_for_pilot'
,
False
)
toggle_switch
(
'publisher_hide_features_for_pilot'
,
False
)
response
=
self
.
client
.
get
(
self
.
courses_url
)
response
=
self
.
client
.
get
(
self
.
courses_url
)
self
.
assertContains
(
response
,
'Edit'
)
self
.
assertContains
(
response
,
'Edit'
)
...
...
course_discovery/templates/publisher/courses.html
View file @
91b7a255
{% extends 'publisher/base.html' %}
{% extends 'publisher/base.html' %}
{% load i18n %}
{% load i18n %}
{% load publisher_extras %}
{% block title %}
{% block title %}
{% trans "Courses" %}
{% trans "Courses" %}
...
@@ -51,13 +52,13 @@
...
@@ -51,13 +52,13 @@
<td>
<td>
{{ course.publisher_course_runs.count }}
{{ course.publisher_course_runs.count }}
</td>
</td>
{% if not publisher_hide_features_for_pilot %}
<td>
<td>
{% if not publisher_hide_features_for_pilot and course|can_edit_course:request.user %}
<a
href=
"{% url 'publisher:publisher_courses_edit' course.id %}"
class=
"btn btn-brand btn-small btn-course-edit"
>
<a
href=
"{% url 'publisher:publisher_courses_edit' course.id %}"
class=
"btn btn-brand btn-small btn-course-edit"
>
{% trans "Edit" %}
{% trans "Edit" %}
</a>
</a>
</td>
{% endif %}
{% endif %}
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</tbody>
...
...
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