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
8823e0d2
Commit
8823e0d2
authored
Aug 30, 2016
by
Awais Qureshi
Committed by
GitHub
Aug 30, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #283 from edx/awais786/ECOM-5387-course-runs-improve
ECOM-5387
parents
acfa0465
7ea2aa43
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
3 deletions
+15
-3
course_discovery/apps/course_metadata/admin.py
+7
-2
course_discovery/apps/course_metadata/tests/test_admin.py
+2
-0
course_discovery/apps/course_metadata/views.py
+3
-1
course_discovery/templates/metadata/admin/course_run.html
+3
-0
No files found.
course_discovery/apps/course_metadata/admin.py
View file @
8823e0d2
...
...
@@ -67,7 +67,7 @@ class ProgramAdmin(admin.ModelAdmin):
list_display
=
(
'id'
,
'uuid'
,
'title'
,
'category'
,
'type'
,
'partner'
,
'status'
,)
list_filter
=
(
'partner'
,
'type'
,)
ordering
=
(
'uuid'
,
'title'
,
'status'
)
readonly_fields
=
(
'uuid'
,
'c
ourse_runs
'
,
'excluded_course_runs'
,)
readonly_fields
=
(
'uuid'
,
'c
ustom_course_runs_display
'
,
'excluded_course_runs'
,)
search_fields
=
(
'uuid'
,
'title'
,
'marketing_slug'
)
...
...
@@ -79,11 +79,16 @@ class ProgramAdmin(admin.ModelAdmin):
'banner_image_url'
,
'card_image_url'
,
'overview'
,
'video'
,
)
fields
+=
(
'courses'
,
'c
ourse_runs
'
,
'excluded_course_runs'
,
'authoring_organizations'
,
'courses'
,
'c
ustom_course_runs_display
'
,
'excluded_course_runs'
,
'authoring_organizations'
,
'credit_backing_organizations'
)
fields
+=
filter_horizontal
def
custom_course_runs_display
(
self
,
obj
):
return
", "
.
join
([
str
(
run
)
for
run
in
obj
.
course_runs
])
custom_course_runs_display
.
short_description
=
"Included course runs"
def
response_add
(
self
,
request
,
obj
,
post_url_continue
=
None
):
return
HttpResponseRedirect
(
reverse
(
'admin_metadata:update_course_runs'
,
kwargs
=
{
'pk'
:
obj
.
pk
}))
...
...
course_discovery/apps/course_metadata/tests/test_admin.py
View file @
8823e0d2
...
...
@@ -34,6 +34,8 @@ class AdminTests(TestCase):
""" Verify that course selection page loads successfully. """
response
=
self
.
client
.
get
(
reverse
(
'admin_metadata:update_course_runs'
,
args
=
(
self
.
program
.
id
,)))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertContains
(
response
,
reverse
(
'admin:course_metadata_program_change'
,
args
=
(
self
.
program
.
id
,)))
self
.
assertContains
(
response
,
reverse
(
'admin:course_metadata_program_changelist'
))
def
test_custom_course_selection_page_with_invalid_id
(
self
):
""" Verify that course selection page will return 404 for invalid program id. """
...
...
course_discovery/apps/course_metadata/views.py
View file @
8823e0d2
...
...
@@ -24,7 +24,9 @@ class CourseRunSelectionAdmin(UpdateView):
def
get_context_data
(
self
,
**
kwargs
):
if
self
.
request
.
user
.
is_authenticated
()
and
self
.
request
.
user
.
is_staff
:
return
super
(
CourseRunSelectionAdmin
,
self
)
.
get_context_data
(
**
kwargs
)
context
=
super
(
CourseRunSelectionAdmin
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'program_id'
]
=
self
.
object
.
id
return
context
raise
Http404
def
form_valid
(
self
,
form
):
...
...
course_discovery/templates/metadata/admin/course_run.html
View file @
8823e0d2
...
...
@@ -23,6 +23,9 @@
<a
href=
"{% url 'admin:course_metadata_program_changelist' %}"
>
<input
type=
"button"
name=
"Cancel"
value=
"{% trans 'Cancel' %}"
>
</a>
<a
href=
"{% url 'admin:course_metadata_program_change' program_id %}"
>
<input
type=
"button"
name=
"Back"
value=
"{% trans 'Back to Program' %}"
>
</a>
<input
type=
"submit"
value=
"{% trans 'Save Course Run' %}"
class=
"default"
name=
"_save"
/>
</div>
{% endblock %}
...
...
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