Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
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
ecommerce
Commits
86efd275
Commit
86efd275
authored
Jul 22, 2015
by
Nickersoft
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Course list view now populates using API over AJAX
parent
94647fd5
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
81 additions
and
49 deletions
+81
-49
ecommerce/static/js/collections/course_collection.js
+12
-0
ecommerce/static/js/models/course-model.js
+0
-10
ecommerce/static/js/pages/course_list_page.js
+5
-2
ecommerce/static/js/pages/credit_checkout.js
+1
-1
ecommerce/static/js/views/course_list_view.js
+52
-5
ecommerce/static/templates/course_list.html
+10
-0
ecommerce/templates/courses/course_list.html
+1
-31
No files found.
ecommerce/static/js/collections/course_collection.js
0 → 100644
View file @
86efd275
define
([
'underscore'
,
'collections/drf_pageable_collection'
,
'models/course_model'
],
function
(
_
,
DrfPageableCollection
,
CourseModel
)
{
return
DrfPageableCollection
.
extend
({
model
:
CourseModel
,
url
:
'/api/v2/courses/'
,
});
});
ecommerce/static/js/models/course-model.js
deleted
100644 → 0
View file @
94647fd5
define
([
'backbone'
],
function
(
Backbone
)
{
'use strict'
;
/**
* Stores our course id information.
*/
return
Backbone
.
Model
.
extend
({
});
});
ecommerce/static/js/pages/course_list_page.js
View file @
86efd275
require
([
require
([
'collections/course_collection'
,
'views/course_list_view'
'views/course_list_view'
],
],
function
(
CourseListView
)
{
function
(
Course
Collection
,
Course
ListView
)
{
return
new
CourseListView
();
return
new
CourseListView
({
collection
:
new
CourseCollection
()
});
}
}
);
);
ecommerce/static/js/pages/credit_checkout.js
View file @
86efd275
...
@@ -3,7 +3,7 @@ require([
...
@@ -3,7 +3,7 @@ require([
'backbone'
,
'backbone'
,
'js/models/user-model'
,
'js/models/user-model'
,
'js/models/tracking-model'
,
'js/models/tracking-model'
,
'js/models/course
-
model'
,
'js/models/course
_
model'
,
'js/views/clickable-view'
,
'js/views/clickable-view'
,
'js/views/analytics_view'
,
'js/views/analytics_view'
,
'js/views/payment_button_view'
,
'js/views/payment_button_view'
,
...
...
ecommerce/static/js/views/course_list_view.js
View file @
86efd275
define
([
define
([
'jquery'
,
'jquery'
,
'underscore'
,
'underscore'
,
'underscore.string'
,
'backbone'
,
'backbone'
,
'moment'
,
'text!templates/course_list.html'
,
'dataTablesBootstrap'
'dataTablesBootstrap'
],
],
function
(
$
,
_
,
Backbon
e
)
{
function
(
$
,
_
,
_s
,
Backbone
,
moment
,
courseListViewTemplat
e
)
{
'use strict'
;
'use strict'
;
...
@@ -12,23 +15,59 @@ define([
...
@@ -12,23 +15,59 @@ define([
el
:
'#course-list-view'
,
el
:
'#course-list-view'
,
initialize
:
function
()
{
template
:
_
.
template
(
courseListViewTemplate
),
this
.
render
();
initialize
:
function
(
options
)
{
this
.
listenTo
(
this
.
collection
,
'add remove change'
,
this
.
render
);
this
.
collection
.
fetch
();
},
},
render
:
function
()
{
render
CourseTable
:
function
()
{
var
filterPlaceholder
=
gettext
(
'Filter by org or course ID'
),
var
tableData
=
[],
filterPlaceholder
=
gettext
(
'Filter by org or course ID'
),
$emptyLabel
=
'<label class="sr">'
+
filterPlaceholder
+
'</label>'
;
$emptyLabel
=
'<label class="sr">'
+
filterPlaceholder
+
'</label>'
;
this
.
collection
.
each
(
function
(
value
)
{
tableData
.
push
(
{
id
:
value
.
get
(
'id'
),
name
:
value
.
get
(
'name'
),
last_edited
:
moment
(
value
.
get
(
'last_edited'
)).
format
(
'MMMM DD, YYYY, h:mm A'
)
}
);
});
if
(
!
$
.
fn
.
dataTable
.
isDataTable
(
'#courseTable'
))
{
this
.
$el
.
find
(
'#courseTable'
).
DataTable
({
this
.
$el
.
find
(
'#courseTable'
).
DataTable
({
autoWidth
:
false
,
data
:
tableData
,
info
:
false
,
info
:
false
,
paging
:
false
,
paging
:
false
,
oLanguage
:
{
oLanguage
:
{
sSearch
:
''
sSearch
:
''
},
columns
:
[
{
title
:
gettext
(
'ID'
),
data
:
'id'
,
fnCreatedCell
:
function
(
nTd
,
sData
,
oData
,
iRow
,
iCol
)
{
$
(
nTd
).
html
(
_s
.
sprintf
(
'<a href=
\'
/courses/%s
\'
>%s</a>'
,
oData
.
id
,
oData
.
id
));
}
},
{
title
:
gettext
(
'Name'
),
data
:
'name'
},
{
title
:
gettext
(
'Last Edited'
),
data
:
'last_edited'
}
}
]
});
});
// NOTE: #courseTable_filter is generated by dataTables
this
.
$el
.
find
(
'#courseTable_filter label'
).
prepend
(
$emptyLabel
);
this
.
$el
.
find
(
'#courseTable_filter label'
).
prepend
(
$emptyLabel
);
this
.
$el
.
find
(
'#courseTable_filter input'
)
this
.
$el
.
find
(
'#courseTable_filter input'
)
...
@@ -36,6 +75,14 @@ define([
...
@@ -36,6 +75,14 @@ define([
.
addClass
(
'field-input input-text'
)
.
addClass
(
'field-input input-text'
)
.
removeClass
(
'form-control input-sm'
);
.
removeClass
(
'form-control input-sm'
);
}
},
render
:
function
()
{
this
.
$el
.
html
(
this
.
template
);
this
.
renderCourseTable
();
return
this
;
return
this
;
}
}
...
...
ecommerce/static/templates/course_list.html
0 → 100644
View file @
86efd275
<div
class=
"page-header"
>
<h1
class=
"hd-1 emphasized"
>
<
%
-
gettext
('
Courses
')
%
>
<button
class=
"btn btn-primary btn-small"
><
%
-
gettext
('
Add
New
Course
')
%
></button>
</h1>
</div>
<table
id=
"courseTable"
class=
"copy copy-base table table-striped table-bordered"
cellspacing=
"0"
>
<caption
class=
"sr-only"
>
Current Courses
</caption>
</table>
ecommerce/templates/courses/course_list.html
View file @
86efd275
...
@@ -5,37 +5,7 @@
...
@@ -5,37 +5,7 @@
{% block title %}{% trans "Courses" %}{% endblock %}
{% block title %}{% trans "Courses" %}{% endblock %}
{% block content %}
{% block content %}
<div
class=
"container"
id=
"course-list-view"
>
<div
class=
"container"
id=
"course-list-view"
></div>
<div
class=
"page-header"
>
<h1
class=
"hd-1 emphasized"
>
{% trans "Courses" %}
<button
class=
"btn btn-primary btn-small"
>
{% trans "Add New Course" %}
</button>
</h1>
</div>
<table
id=
"courseTable"
class=
"copy copy-base table table-striped table-bordered"
cellspacing=
"0"
>
<caption
class=
"sr-only"
>
Current Courses
</caption>
<thead>
<tr>
<th>
{% trans "ID" %}
</th>
<th>
{% trans "Name" %}
</th>
<th>
{% trans "Last Edited" %}
</th>
</tr>
</thead>
<tbody>
{% for course in courses %}
<tr>
<td><a
href=
"{% url 'courses:detail' course.id %}"
>
{{ course.id }}
</a></td>
<td>
{{ course.name }}
</td>
<td
data-sort=
"{{ course.history.latest.history_date|date:'U' }}"
>
{{ course.history.latest.history_date }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
{% endblock %}
{% block javascript %}
{% block javascript %}
...
...
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