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
1156bd67
Commit
1156bd67
authored
Jul 04, 2017
by
Awais
Committed by
Awais Qureshi
Jul 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding properties to show override fields on course detail pages.
EDUCATOR-818
parent
988b3a58
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
9 deletions
+50
-9
course_discovery/apps/publisher/models.py
+18
-0
course_discovery/apps/publisher/tests/test_model.py
+16
-1
course_discovery/apps/publisher/tests/test_views.py
+13
-5
course_discovery/apps/publisher/views.py
+1
-1
course_discovery/templates/publisher/course_detail.html
+2
-2
No files found.
course_discovery/apps/publisher/models.py
View file @
1156bd67
...
@@ -213,6 +213,24 @@ class Course(TimeStampedModel, ChangedByMixin):
...
@@ -213,6 +213,24 @@ class Course(TimeStampedModel, ChangedByMixin):
return
self
.
short_description
return
self
.
short_description
@property
def
course_full_description
(
self
):
course_run
=
self
.
course_runs
.
filter
(
course_run_state__name
=
CourseRunStateChoices
.
Published
)
.
first
()
if
course_run
and
course_run
.
full_description_override
:
return
course_run
.
full_description_override
return
self
.
full_description
@property
def
course_title
(
self
):
course_run
=
self
.
course_runs
.
filter
(
course_run_state__name
=
CourseRunStateChoices
.
Published
)
.
first
()
if
course_run
and
course_run
.
title_override
:
return
course_run
.
title_override
return
self
.
title
class
CourseRun
(
TimeStampedModel
,
ChangedByMixin
):
class
CourseRun
(
TimeStampedModel
,
ChangedByMixin
):
""" Publisher CourseRun model. It contains fields related to the course run intake form."""
""" Publisher CourseRun model. It contains fields related to the course run intake form."""
...
...
course_discovery/apps/publisher/tests/test_model.py
View file @
1156bd67
...
@@ -349,11 +349,26 @@ class CourseTests(TestCase):
...
@@ -349,11 +349,26 @@ class CourseTests(TestCase):
""" Verify that the property returns the short_description. """
""" Verify that the property returns the short_description. """
self
.
assertEqual
(
self
.
course
.
short_description
,
self
.
course
.
course_short_description
)
self
.
assertEqual
(
self
.
course
.
short_description
,
self
.
course
.
course_short_description
)
# Create a published course-run with card_image_url.
course_run
=
factories
.
CourseRunFactory
(
course
=
self
.
course
)
course_run
=
factories
.
CourseRunFactory
(
course
=
self
.
course
)
factories
.
CourseRunStateFactory
(
course_run
=
course_run
,
name
=
CourseRunStateChoices
.
Published
)
factories
.
CourseRunStateFactory
(
course_run
=
course_run
,
name
=
CourseRunStateChoices
.
Published
)
self
.
assertEqual
(
self
.
course
.
course_short_description
,
course_run
.
short_description_override
)
self
.
assertEqual
(
self
.
course
.
course_short_description
,
course_run
.
short_description_override
)
def
test_full_description_override
(
self
):
""" Verify that the property returns the full_description. """
self
.
assertEqual
(
self
.
course
.
full_description
,
self
.
course
.
course_full_description
)
course_run
=
factories
.
CourseRunFactory
(
course
=
self
.
course
)
factories
.
CourseRunStateFactory
(
course_run
=
course_run
,
name
=
CourseRunStateChoices
.
Published
)
self
.
assertEqual
(
self
.
course
.
course_full_description
,
course_run
.
full_description_override
)
def
test_title_override
(
self
):
""" Verify that the property returns the title. """
self
.
assertEqual
(
self
.
course
.
title
,
self
.
course
.
course_title
)
course_run
=
factories
.
CourseRunFactory
(
course
=
self
.
course
)
factories
.
CourseRunStateFactory
(
course_run
=
course_run
,
name
=
CourseRunStateChoices
.
Published
)
self
.
assertEqual
(
self
.
course
.
course_title
,
course_run
.
title_override
)
class
SeatTests
(
TestCase
):
class
SeatTests
(
TestCase
):
""" Tests for the publisher `Seat` model. """
""" Tests for the publisher `Seat` model. """
...
...
course_discovery/apps/publisher/tests/test_views.py
View file @
1156bd67
...
@@ -1728,6 +1728,7 @@ class CourseDetailViewTests(TestCase):
...
@@ -1728,6 +1728,7 @@ class CourseDetailViewTests(TestCase):
self
.
assertContains
(
response
,
self
.
course
.
faq
)
self
.
assertContains
(
response
,
self
.
course
.
faq
)
self
.
assertContains
(
response
,
self
.
course
.
video_link
)
self
.
assertContains
(
response
,
self
.
course
.
video_link
)
self
.
assertContains
(
response
,
self
.
course
.
syllabus
)
self
.
assertContains
(
response
,
self
.
course
.
syllabus
)
self
.
assertEqual
(
response
.
context
[
'breadcrumbs'
][
1
][
'slug'
],
self
.
course
.
title
)
def
test_details_page_with_course_runs_lms_id
(
self
):
def
test_details_page_with_course_runs_lms_id
(
self
):
""" Test that user can see course runs with lms-id on course detail page. """
""" Test that user can see course runs with lms-id on course detail page. """
...
@@ -2013,18 +2014,25 @@ class CourseDetailViewTests(TestCase):
...
@@ -2013,18 +2014,25 @@ class CourseDetailViewTests(TestCase):
self
.
assertEqual
(
response
.
context
[
'most_recent_revision_id'
],
current_user_revision
)
self
.
assertEqual
(
response
.
context
[
'most_recent_revision_id'
],
current_user_revision
)
self
.
assertTrue
(
response
.
context
[
'accept_all_button'
])
self
.
assertTrue
(
response
.
context
[
'accept_all_button'
])
def
test_detail_page_with_override_
short_description
(
self
):
def
test_detail_page_with_override_
values
(
self
):
"""
"""
Test that pages shows the override short description.
Test that pages shows the override short description
, full description and title
.
"""
"""
description
=
'Testing short description'
short_description
=
'Testing short description'
full_description
=
'Testing full description'
title
=
'Testing title'
self
.
_assign_user_permission
()
self
.
_assign_user_permission
()
course_run
=
factories
.
CourseRunFactory
(
course_run
=
factories
.
CourseRunFactory
(
course
=
self
.
course
,
short_description_override
=
description
course
=
self
.
course
,
short_description_override
=
short_description
,
full_description_override
=
full_description
,
title_override
=
title
)
)
factories
.
CourseRunStateFactory
(
course_run
=
course_run
,
name
=
CourseRunStateChoices
.
Published
)
factories
.
CourseRunStateFactory
(
course_run
=
course_run
,
name
=
CourseRunStateChoices
.
Published
)
response
=
self
.
client
.
get
(
self
.
detail_page_url
)
response
=
self
.
client
.
get
(
self
.
detail_page_url
)
self
.
assertContains
(
response
,
description
)
self
.
assertContains
(
response
,
short_description
)
self
.
assertContains
(
response
,
full_description
)
self
.
assertContains
(
response
,
title
)
self
.
assertEqual
(
response
.
context
[
'breadcrumbs'
][
1
][
'slug'
],
title
)
def
_assign_user_permission
(
self
):
def
_assign_user_permission
(
self
):
""" Assign permissions."""
""" Assign permissions."""
...
...
course_discovery/apps/publisher/views.py
View file @
1156bd67
...
@@ -446,7 +446,7 @@ class CourseDetailView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMixi
...
@@ -446,7 +446,7 @@ class CourseDetailView(mixins.LoginRequiredMixin, mixins.PublisherPermissionMixi
context
[
'breadcrumbs'
]
=
make_bread_crumbs
(
context
[
'breadcrumbs'
]
=
make_bread_crumbs
(
[
[
(
reverse
(
'publisher:publisher_courses'
),
'Courses'
),
(
reverse
(
'publisher:publisher_courses'
),
'Courses'
),
(
None
,
course
.
title
),
(
None
,
course
.
course_
title
),
]
]
)
)
context
[
'comment_object'
]
=
course
context
[
'comment_object'
]
=
course
...
...
course_discovery/templates/publisher/course_detail.html
View file @
1156bd67
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
<div
class=
"heading"
>
<div
class=
"heading"
>
{% trans "Course Title" %}
{% trans "Course Title" %}
</div>
</div>
<div
class=
"current title"
>
{{ object.title }}
</div>
<div
class=
"current title"
>
{{ object.
course_
title }}
</div>
<div
class=
"show-diff"
></div>
<div
class=
"show-diff"
></div>
</div>
</div>
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
{% trans "Long Description" %}
{% trans "Long Description" %}
</div>
</div>
<div
class=
"current full_description"
>
<div
class=
"current full_description"
>
{% with object.full_description as field %}
{% with object.
course_
full_description as field %}
{% include "publisher/_render_required_field.html" %}
{% include "publisher/_render_required_field.html" %}
{% endwith %}
{% endwith %}
</div>
</div>
...
...
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