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
be9a8444
Commit
be9a8444
authored
Jun 21, 2017
by
Awais
Committed by
Awais Qureshi
Jun 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update script to import the short-desc-override.
Add property to show the override value. EDUCATOR-704
parent
9bd338d0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
3 deletions
+40
-3
course_discovery/apps/publisher/dataloader/create_courses.py
+2
-1
course_discovery/apps/publisher/management/commands/tests/test_import_courses.py
+5
-1
course_discovery/apps/publisher/models.py
+9
-0
course_discovery/apps/publisher/tests/factories.py
+1
-0
course_discovery/apps/publisher/tests/test_model.py
+9
-0
course_discovery/apps/publisher/tests/test_views.py
+13
-0
course_discovery/templates/publisher/course_detail.html
+1
-1
No files found.
course_discovery/apps/publisher/dataloader/create_courses.py
View file @
be9a8444
...
@@ -98,7 +98,8 @@ def create_course_runs(meta_data_course, publisher_course):
...
@@ -98,7 +98,8 @@ def create_course_runs(meta_data_course, publisher_course):
'language'
:
canonical_course_run
.
language
,
'pacing_type'
:
canonical_course_run
.
pacing_type
,
'language'
:
canonical_course_run
.
language
,
'pacing_type'
:
canonical_course_run
.
pacing_type
,
'length'
:
canonical_course_run
.
weeks_to_complete
,
'length'
:
canonical_course_run
.
weeks_to_complete
,
'card_image_url'
:
canonical_course_run
.
card_image_url
,
'card_image_url'
:
canonical_course_run
.
card_image_url
,
'lms_course_id'
:
canonical_course_run
.
key
'lms_course_id'
:
canonical_course_run
.
key
,
'short_description_override'
:
canonical_course_run
.
short_description_override
}
}
publisher_course_run
,
created
=
CourseRun
.
objects
.
update_or_create
(
publisher_course_run
,
created
=
CourseRun
.
objects
.
update_or_create
(
...
...
course_discovery/apps/publisher/management/commands/tests/test_import_courses.py
View file @
be9a8444
...
@@ -106,7 +106,8 @@ class CreateCoursesTests(TestCase):
...
@@ -106,7 +106,8 @@ class CreateCoursesTests(TestCase):
# create multiple course-runs against course.
# create multiple course-runs against course.
course_runs
=
CourseRunFactory
.
create_batch
(
course_runs
=
CourseRunFactory
.
create_batch
(
3
,
course
=
self
.
course
,
transcript_languages
=
transcript_languages
,
3
,
course
=
self
.
course
,
transcript_languages
=
transcript_languages
,
language
=
transcript_languages
[
0
]
language
=
transcript_languages
[
0
],
short_description_override
=
'Testing description'
)
)
canonical_course_run
=
course_runs
[
0
]
canonical_course_run
=
course_runs
[
0
]
...
@@ -274,6 +275,9 @@ class CreateCoursesTests(TestCase):
...
@@ -274,6 +275,9 @@ class CreateCoursesTests(TestCase):
self
.
assertEqual
(
publisher_course_run
.
card_image_url
,
metadata_course_run
.
card_image_url
)
self
.
assertEqual
(
publisher_course_run
.
card_image_url
,
metadata_course_run
.
card_image_url
)
self
.
assertEqual
(
publisher_course_run
.
language
,
metadata_course_run
.
language
)
self
.
assertEqual
(
publisher_course_run
.
language
,
metadata_course_run
.
language
)
self
.
assertEqual
(
publisher_course_run
.
lms_course_id
,
metadata_course_run
.
key
)
self
.
assertEqual
(
publisher_course_run
.
lms_course_id
,
metadata_course_run
.
key
)
self
.
assertEqual
(
publisher_course_run
.
short_description_override
,
metadata_course_run
.
short_description_override
)
# assert ManytoMany fields.
# assert ManytoMany fields.
self
.
assertEqual
(
self
.
assertEqual
(
...
...
course_discovery/apps/publisher/models.py
View file @
be9a8444
...
@@ -204,6 +204,15 @@ class Course(TimeStampedModel, ChangedByMixin):
...
@@ -204,6 +204,15 @@ class Course(TimeStampedModel, ChangedByMixin):
return
None
return
None
@property
def
course_short_description
(
self
):
course_run
=
self
.
course_runs
.
filter
(
course_run_state__name
=
CourseRunStateChoices
.
Published
)
.
first
()
if
course_run
and
course_run
.
short_description_override
:
return
course_run
.
short_description_override
return
self
.
short_description
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/factories.py
View file @
be9a8444
...
@@ -55,6 +55,7 @@ class CourseRunFactory(factory.DjangoModelFactory):
...
@@ -55,6 +55,7 @@ class CourseRunFactory(factory.DjangoModelFactory):
preview_url
=
FuzzyText
(
prefix
=
'https://example.com/'
)
preview_url
=
FuzzyText
(
prefix
=
'https://example.com/'
)
contacted_partner_manager
=
FuzzyChoice
((
True
,
False
))
contacted_partner_manager
=
FuzzyChoice
((
True
,
False
))
video_language
=
factory
.
Iterator
(
LanguageTag
.
objects
.
all
())
video_language
=
factory
.
Iterator
(
LanguageTag
.
objects
.
all
())
short_description_override
=
FuzzyText
()
class
Meta
:
class
Meta
:
model
=
CourseRun
model
=
CourseRun
...
...
course_discovery/apps/publisher/tests/test_model.py
View file @
be9a8444
...
@@ -345,6 +345,15 @@ class CourseTests(TestCase):
...
@@ -345,6 +345,15 @@ class CourseTests(TestCase):
# Verify that property returns course image field url.
# Verify that property returns course image field url.
self
.
assertEqual
(
self
.
course
.
course_image_url
,
self
.
course
.
image
.
url
)
self
.
assertEqual
(
self
.
course
.
course_image_url
,
self
.
course
.
image
.
url
)
def
test_short_description_override
(
self
):
""" Verify that the property returns the 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
)
factories
.
CourseRunStateFactory
(
course_run
=
course_run
,
name
=
CourseRunStateChoices
.
Published
)
self
.
assertEqual
(
self
.
course
.
course_short_description
,
course_run
.
short_description_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 @
be9a8444
...
@@ -2011,6 +2011,19 @@ class CourseDetailViewTests(TestCase):
...
@@ -2011,6 +2011,19 @@ 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
):
"""
Test that pages shows the override short description.
"""
description
=
'Testing short description'
self
.
_assign_user_permission
()
course_run
=
factories
.
CourseRunFactory
(
course
=
self
.
course
,
short_description_override
=
description
)
factories
.
CourseRunStateFactory
(
course_run
=
course_run
,
name
=
CourseRunStateChoices
.
Published
)
response
=
self
.
client
.
get
(
self
.
detail_page_url
)
self
.
assertContains
(
response
,
description
)
def
_assign_user_permission
(
self
):
def
_assign_user_permission
(
self
):
""" Assign permissions."""
""" Assign permissions."""
self
.
user
.
groups
.
add
(
self
.
organization_extension
.
group
)
self
.
user
.
groups
.
add
(
self
.
organization_extension
.
group
)
...
...
course_discovery/templates/publisher/course_detail.html
View file @
be9a8444
...
@@ -76,7 +76,7 @@
...
@@ -76,7 +76,7 @@
{% trans "Short Description" %}
{% trans "Short Description" %}
</div>
</div>
<div
class=
"current short_description"
>
<div
class=
"current short_description"
>
{% with object.short_description as field %}
{% with object.
course_
short_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