Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
937bd0de
Commit
937bd0de
authored
Jun 10, 2016
by
Bill DeRusha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add csv download link to catalog list page
parent
81e5be22
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletions
+28
-1
lms/templates/api_admin/catalogs/list.html
+1
-0
openedx/core/djangoapps/api_admin/urls.py
+10
-1
openedx/core/djangoapps/api_admin/views.py
+17
-0
No files found.
lms/templates/api_admin/catalogs/list.html
View file @
937bd0de
...
...
@@ -26,6 +26,7 @@ CatalogPreviewFactory({
% for catalog in catalogs:
<li>
<a
href=
"${reverse('api_admin:catalog-edit', args=(catalog.id,))}"
>
${catalog.name}
</a>
<a
href=
"${reverse('api_admin:catalog-csv', args=(catalog.id,))}"
>
download CSV
</a>
</li>
% endfor
</ul>
...
...
openedx/core/djangoapps/api_admin/urls.py
View file @
937bd0de
...
...
@@ -6,7 +6,7 @@ from django.contrib.auth.decorators import login_required
from
openedx.core.djangoapps.api_admin.decorators
import
api_access_enabled_or_404
from
openedx.core.djangoapps.api_admin.views
import
(
ApiRequestView
,
ApiRequestStatusView
,
ApiTosView
,
CatalogListView
,
CatalogEditView
,
ApiRequestView
,
ApiRequestStatusView
,
ApiTosView
,
Catalog
CSVView
,
Catalog
ListView
,
CatalogEditView
,
CatalogPreviewView
,
CatalogSearchView
)
...
...
@@ -49,6 +49,15 @@ urlpatterns = (
name
=
'catalog-edit'
,
),
url
(
r'^catalogs/(?P<catalog_id>\d+)/csv$'
,
staff_member_required
(
api_access_enabled_or_404
(
CatalogCSVView
.
as_view
()),
login_url
=
'dashboard'
,
redirect_field_name
=
None
),
name
=
'catalog-csv'
,
),
url
(
r'^catalogs/$'
,
staff_member_required
(
api_access_enabled_or_404
(
CatalogSearchView
.
as_view
()),
...
...
openedx/core/djangoapps/api_admin/views.py
View file @
937bd0de
"""Views for API management."""
from
datetime
import
datetime
import
logging
from
django.conf
import
settings
from
django.contrib.sites.shortcuts
import
get_current_site
from
django.core.urlresolvers
import
reverse_lazy
,
reverse
from
django.http
import
HttpResponse
from
django.http.response
import
JsonResponse
from
django.shortcuts
import
redirect
from
django.utils.translation
import
ugettext
as
_
...
...
@@ -232,3 +234,18 @@ class CatalogPreviewView(View):
else
:
results
=
{
'count'
:
0
,
'results'
:
[],
'next'
:
None
,
'prev'
:
None
}
return
JsonResponse
(
results
)
class
CatalogCSVView
(
View
):
"""View to download a CSV of catalog courses."""
def
get
(
self
,
request
,
catalog_id
):
"""Download a CSV of course_runs in this catalog."""
client
=
course_discovery_api_client
(
request
.
user
)
data
=
client
.
api
.
v1
.
catalogs
(
catalog_id
)
.
csv
.
get
()
response
=
HttpResponse
(
data
,
content_type
=
'text/csv'
)
response
[
'Content-Disposition'
]
=
'attachment; filename="catalog_{id}_{date}.csv"'
.
format
(
id
=
catalog_id
,
date
=
datetime
.
utcnow
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
)
return
response
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