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
1ceb8a0d
Commit
1ceb8a0d
authored
Jul 01, 2015
by
Peter Fogg
Committed by
cahrens
Jul 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize finish_auth_factory.
TNL-2602
parent
4f0ab6f9
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
148 additions
and
185 deletions
+148
-185
lms/envs/common.py
+0
-3
lms/static/js/spec/main.js
+0
-12
lms/static/js/spec/student_account/emailoptin_spec.js
+1
-1
lms/static/js/spec/student_account/enrollment_spec.js
+1
-1
lms/static/js/spec/student_account/shoppingcart_spec.js
+1
-1
lms/static/js/student_account/emailoptin.js
+27
-28
lms/static/js/student_account/enrollment.js
+55
-58
lms/static/js/student_account/shoppingcart.js
+43
-47
lms/static/js/student_account/views/FinishAuthView.js
+2
-6
lms/static/js/student_account/views/finish_auth_factory.js
+12
-0
lms/static/lms/js/build.js
+3
-2
lms/templates/student_account/finish_auth.html
+3
-26
No files found.
lms/envs/common.py
View file @
1ceb8a0d
...
@@ -1275,9 +1275,6 @@ student_account_js = [
...
@@ -1275,9 +1275,6 @@ student_account_js = [
'js/src/accessibility_tools.js'
,
'js/src/accessibility_tools.js'
,
'js/src/ie_shim.js'
,
'js/src/ie_shim.js'
,
'js/src/string_utils.js'
,
'js/src/string_utils.js'
,
'js/student_account/enrollment.js'
,
'js/student_account/emailoptin.js'
,
'js/student_account/shoppingcart.js'
,
'js/student_account/models/LoginModel.js'
,
'js/student_account/models/LoginModel.js'
,
'js/student_account/models/RegisterModel.js'
,
'js/student_account/models/RegisterModel.js'
,
'js/student_account/models/PasswordResetModel.js'
,
'js/student_account/models/PasswordResetModel.js'
,
...
...
lms/static/js/spec/main.js
View file @
1ceb8a0d
...
@@ -373,18 +373,6 @@
...
@@ -373,18 +373,6 @@
'js/models/notification'
,
'jquery.fileupload'
'js/models/notification'
,
'jquery.fileupload'
]
]
},
},
'js/student_account/enrollment'
:
{
exports
:
'edx.student.account.EnrollmentInterface'
,
deps
:
[
'jquery'
,
'jquery.cookie'
]
},
'js/student_account/emailoptin'
:
{
exports
:
'edx.student.account.EmailOptInInterface'
,
deps
:
[
'jquery'
,
'jquery.cookie'
]
},
'js/student_account/shoppingcart'
:
{
exports
:
'edx.student.account.ShoppingCartInterface'
,
deps
:
[
'jquery'
,
'jquery.cookie'
,
'underscore'
]
},
// Student account registration/login
// Student account registration/login
// Loaded explicitly until these are converted to RequireJS
// Loaded explicitly until these are converted to RequireJS
'js/student_account/views/FormView'
:
{
'js/student_account/views/FormView'
:
{
...
...
lms/static/js/spec/student_account/emailoptin_spec.js
View file @
1ceb8a0d
...
@@ -2,7 +2,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/emailoptin'],
...
@@ -2,7 +2,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/emailoptin'],
function
(
AjaxHelpers
,
EmailOptInInterface
)
{
function
(
AjaxHelpers
,
EmailOptInInterface
)
{
'use strict'
;
'use strict'
;
describe
(
'
edx.student.account.
EmailOptInInterface'
,
function
()
{
describe
(
'EmailOptInInterface'
,
function
()
{
var
COURSE_KEY
=
'edX/DemoX/Fall'
,
var
COURSE_KEY
=
'edX/DemoX/Fall'
,
EMAIL_OPT_IN
=
'True'
,
EMAIL_OPT_IN
=
'True'
,
...
...
lms/static/js/spec/student_account/enrollment_spec.js
View file @
1ceb8a0d
...
@@ -2,7 +2,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/enrollment'],
...
@@ -2,7 +2,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/enrollment'],
function
(
AjaxHelpers
,
EnrollmentInterface
)
{
function
(
AjaxHelpers
,
EnrollmentInterface
)
{
'use strict'
;
'use strict'
;
describe
(
'
edx.student.account.
EnrollmentInterface'
,
function
()
{
describe
(
'EnrollmentInterface'
,
function
()
{
var
COURSE_KEY
=
'edX/DemoX/Fall'
,
var
COURSE_KEY
=
'edX/DemoX/Fall'
,
ENROLL_URL
=
'/api/commerce/v0/baskets/'
,
ENROLL_URL
=
'/api/commerce/v0/baskets/'
,
...
...
lms/static/js/spec/student_account/shoppingcart_spec.js
View file @
1ceb8a0d
...
@@ -2,7 +2,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/shoppingcart'
...
@@ -2,7 +2,7 @@ define(['common/js/spec_helpers/ajax_helpers', 'js/student_account/shoppingcart'
function
(
AjaxHelpers
,
ShoppingCartInterface
)
{
function
(
AjaxHelpers
,
ShoppingCartInterface
)
{
'use strict'
;
'use strict'
;
describe
(
'
edx.student.account.
ShoppingCartInterface'
,
function
()
{
describe
(
'ShoppingCartInterface'
,
function
()
{
var
COURSE_KEY
=
"edX/DemoX/Fall"
,
var
COURSE_KEY
=
"edX/DemoX/Fall"
,
ADD_COURSE_URL
=
"/shoppingcart/add/course/edX/DemoX/Fall/"
,
ADD_COURSE_URL
=
"/shoppingcart/add/course/edX/DemoX/Fall/"
,
...
...
lms/static/js/student_account/emailoptin.js
View file @
1ceb8a0d
var
edx
=
edx
||
{};
;(
function
(
define
)
{
(
function
(
$
)
{
'use strict'
;
'use strict'
;
define
([
'jquery'
,
'jquery.cookie'
],
function
(
$
)
{
edx
.
student
=
edx
.
student
||
{};
var
EmailOptInInterface
=
{
edx
.
student
.
account
=
edx
.
student
.
account
||
{};
edx
.
student
.
account
.
EmailOptInInterface
=
{
urls
:
{
emailOptInUrl
:
'/user_api/v1/preferences/email_opt_in/'
},
url
s
:
{
header
s
:
{
emailOptInUrl
:
'/user_api/v1/preferences/email_opt_in/'
'X-CSRFToken'
:
$
.
cookie
(
'csrftoken'
)
},
},
headers
:
{
/**
'X-CSRFToken'
:
$
.
cookie
(
'csrftoken'
)
* Set the email opt in setting for the organization associated
},
* with this course.
* @param {string} courseKey Slash-separated course key.
* @param {string} emailOptIn The preference to opt in or out of organization emails.
*/
setPreference
:
function
(
courseKey
,
emailOptIn
)
{
return
$
.
ajax
({
url
:
this
.
urls
.
emailOptInUrl
,
type
:
'POST'
,
data
:
{
course_id
:
courseKey
,
email_opt_in
:
emailOptIn
},
headers
:
this
.
headers
});
}
};
/**
return
EmailOptInInterface
;
* Set the email opt in setting for the organization associated
});
* with this course.
}).
call
(
this
,
define
||
RequireJS
.
define
);
* @param {string} courseKey Slash-separated course key.
* @param {string} emailOptIn The preference to opt in or out of organization emails.
*/
setPreference
:
function
(
courseKey
,
emailOptIn
)
{
return
$
.
ajax
({
url
:
this
.
urls
.
emailOptInUrl
,
type
:
'POST'
,
data
:
{
course_id
:
courseKey
,
email_opt_in
:
emailOptIn
},
headers
:
this
.
headers
});
}
};
})(
jQuery
);
lms/static/js/student_account/enrollment.js
View file @
1ceb8a0d
var
edx
=
edx
||
{};
;(
function
(
define
)
{
(
function
(
$
)
{
'use strict'
;
'use strict'
;
define
([
'jquery'
,
'jquery.cookie'
],
function
(
$
)
{
edx
.
student
=
edx
.
student
||
{};
var
EnrollmentInterface
=
{
edx
.
student
.
account
=
edx
.
student
.
account
||
{};
edx
.
student
.
account
.
EnrollmentInterface
=
{
urls
:
{
urls
:
{
baskets
:
'/api/commerce/v0/baskets/'
,
baskets
:
'/api/commerce/v0/baskets/'
,
},
},
headers
:
{
headers
:
{
'X-CSRFToken'
:
$
.
cookie
(
'csrftoken'
)
'X-CSRFToken'
:
$
.
cookie
(
'csrftoken'
)
},
},
/**
/**
* Enroll a user in a course, then redirect the user.
* Enroll a user in a course, then redirect the user.
* @param {string} courseKey Slash-separated course key.
* @param {string} courseKey Slash-separated course key.
* @param {string} redirectUrl The URL to redirect to once enrollment completes.
* @param {string} redirectUrl The URL to redirect to once enrollment completes.
*/
*/
enroll
:
function
(
courseKey
,
redirectUrl
)
{
enroll
:
function
(
courseKey
,
redirectUrl
)
{
var
data_obj
=
{
course_id
:
courseKey
},
var
data_obj
=
{
course_id
:
courseKey
},
data
=
JSON
.
stringify
(
data_obj
);
data
=
JSON
.
stringify
(
data_obj
);
$
.
ajax
({
$
.
ajax
({
url
:
this
.
urls
.
baskets
,
url
:
this
.
urls
.
baskets
,
type
:
'POST'
,
type
:
'POST'
,
contentType
:
'application/json; charset=utf-8'
,
contentType
:
'application/json; charset=utf-8'
,
data
:
data
,
data
:
data
,
headers
:
this
.
headers
,
headers
:
this
.
headers
,
context
:
this
context
:
this
})
}).
fail
(
function
(
jqXHR
)
{
.
fail
(
function
(
jqXHR
)
{
var
responseData
=
JSON
.
parse
(
jqXHR
.
responseText
);
var
responseData
=
JSON
.
parse
(
jqXHR
.
responseText
);
if
(
jqXHR
.
status
===
403
&&
responseData
.
user_message_url
)
{
if
(
jqXHR
.
status
===
403
&&
responseData
.
user_message_url
)
{
// Check if we've been blocked from the course
// Check if we've been blocked from the course
// because of country access rules.
// because of country access rules.
// If so, redirect to a page explaining to the user
// If so, redirect to a page explaining to the user
// why they were blocked.
// why they were blocked.
this
.
redirect
(
responseData
.
user_message_url
);
this
.
redirect
(
responseData
.
user_message_url
);
}
else
{
}
else
{
// Otherwise, redirect the user to the next page.
// Otherwise, redirect the user to the next page.
if
(
redirectUrl
)
{
this
.
redirect
(
redirectUrl
);
}
}
}).
done
(
function
()
{
// If we successfully enrolled, redirect the user
// to the next page (usually the student dashboard or payment flow)
if
(
redirectUrl
)
{
if
(
redirectUrl
)
{
this
.
redirect
(
redirectUrl
);
this
.
redirect
(
redirectUrl
);
}
}
}
});
})
},
.
done
(
function
()
{
// If we successfully enrolled, redirect the user
/**
// to the next page (usually the student dashboard or payment flow)
* Redirect to a URL. Mainly useful for mocking out in tests.
if
(
redirectUrl
)
{
* @param {string} url The URL to redirect to.
this
.
redirect
(
redirectUrl
);
*/
}
redirect
:
function
(
url
)
{
});
window
.
location
.
href
=
url
;
},
}
};
/**
return
EnrollmentInterface
;
* Redirect to a URL. Mainly useful for mocking out in tests.
});
* @param {string} url The URL to redirect to.
}).
call
(
this
,
define
||
RequireJS
.
define
);
*/
redirect
:
function
(
url
)
{
window
.
location
.
href
=
url
;
}
};
})(
jQuery
);
lms/static/js/student_account/shoppingcart.js
View file @
1ceb8a0d
/**
/**
* Use the shopping cart to purchase courses.
* Use the shopping cart to purchase courses.
*/
*/
;(
function
(
define
)
{
var
edx
=
edx
||
{};
(
function
(
$
)
{
'use strict'
;
'use strict'
;
define
([
'jquery'
,
'jquery.cookie'
],
function
(
$
)
{
edx
.
student
=
edx
.
student
||
{};
edx
.
student
.
account
=
edx
.
student
.
account
||
{};
var
ShoppingCartInterface
=
{
urls
:
{
edx
.
student
.
account
.
ShoppingCartInterface
=
{
viewCart
:
"/shoppingcart/"
,
addCourse
:
"/shoppingcart/add/course/"
urls
:
{
},
viewCart
:
"/shoppingcart/"
,
addCourse
:
"/shoppingcart/add/course/"
headers
:
{
},
'X-CSRFToken'
:
$
.
cookie
(
'csrftoken'
)
},
headers
:
{
'X-CSRFToken'
:
$
.
cookie
(
'csrftoken'
)
/**
},
* Add a course to a cart, then redirect to the view cart page.
* @param {string} courseId The slash-separated course ID to add to the cart.
/**
*/
* Add a course to a cart, then redirect to the view cart page.
addCourseToCart
:
function
(
courseId
)
{
* @param {string} courseId The slash-separated course ID to add to the cart.
$
.
ajax
({
*/
url
:
this
.
urls
.
addCourse
+
courseId
+
"/"
,
addCourseToCart
:
function
(
courseId
)
{
type
:
'POST'
,
$
.
ajax
({
data
:
{},
url
:
this
.
urls
.
addCourse
+
courseId
+
"/"
,
headers
:
this
.
headers
,
type
:
'POST'
,
context
:
this
data
:
{},
}).
always
(
function
()
{
headers
:
this
.
headers
,
this
.
redirect
(
this
.
urls
.
viewCart
);
context
:
this
});
}).
always
(
function
()
{
},
this
.
redirect
(
this
.
urls
.
viewCart
);
});
/**
},
* Redirect to a URL. Mainly useful for mocking out in tests.
* @param {string} url The URL to redirect to.
/**
*/
* Redirect to a URL. Mainly useful for mocking out in tests.
redirect
:
function
(
url
)
{
* @param {string} url The URL to redirect to.
window
.
location
.
href
=
url
;
*/
}
redirect
:
function
(
url
)
{
};
window
.
location
.
href
=
url
;
}
return
ShoppingCartInterface
;
};
});
}).
call
(
this
,
define
||
RequireJS
.
define
);
})(
jQuery
);
lms/static/js/student_account/views/FinishAuthView.js
View file @
1ceb8a0d
...
@@ -26,18 +26,14 @@
...
@@ -26,18 +26,14 @@
;(
function
(
define
,
undefined
)
{
;(
function
(
define
,
undefined
)
{
'use strict'
;
'use strict'
;
define
([
define
([
'jquery'
,
'underscore'
,
'underscore'
,
'backbone'
,
'backbone'
,
'gettext'
,
'gettext'
,
'js/student_account/emailoptin'
,
'js/student_account/emailoptin'
,
'js/student_account/enrollment'
,
'js/student_account/enrollment'
,
'js/student_account/shoppingcart'
'js/student_account/shoppingcart'
],
function
(
_
,
Backbone
,
gettext
,
emailOptInInterface
,
enrollmentInterface
,
shoppingCartInterface
)
{
],
function
(
$
,
_
,
Backbone
,
gettext
,
emailOptInInterface
,
enrollmentInterface
,
shoppingCartInterface
)
{
// These are not yet converted to requireJS:
var
edx
=
window
.
edx
||
{};
emailOptInInterface
=
emailOptInInterface
||
edx
.
student
.
account
.
EmailOptInInterface
;
enrollmentInterface
=
enrollmentInterface
||
edx
.
student
.
account
.
EnrollmentInterface
;
shoppingCartInterface
=
shoppingCartInterface
||
edx
.
student
.
account
.
ShoppingCartInterface
;
var
FinishAuthView
=
Backbone
.
View
.
extend
({
var
FinishAuthView
=
Backbone
.
View
.
extend
({
el
:
'#finish-auth-status'
,
el
:
'#finish-auth-status'
,
...
...
lms/static/js/student_account/views/finish_auth_factory.js
0 → 100644
View file @
1ceb8a0d
(
function
(
define
)
{
'use strict'
;
define
(
"js/student_account/views/finish_auth_factory"
,
[
'jquery'
,
'underscore'
,
'backbone'
,
'js/student_account/views/FinishAuthView'
,
'utility'
],
function
(
$
,
_
,
Backbone
,
FinishAuthView
)
{
return
function
()
{
var
view
=
new
FinishAuthView
({});
view
.
render
();
};
}
);
}).
call
(
this
,
define
||
RequireJS
.
define
);
lms/static/lms/js/build.js
View file @
1ceb8a0d
...
@@ -18,9 +18,10 @@
...
@@ -18,9 +18,10 @@
* done.
* done.
*/
*/
modules
:
getModulesList
([
modules
:
getModulesList
([
'teams/js/teams_tab_factory'
,
'js/student_account/views/account_settings_factory'
,
'js/student_account/views/finish_auth_factory'
,
'js/student_profile/views/learner_profile_factory'
,
'js/student_profile/views/learner_profile_factory'
,
'
js/student_account/views/account_settings
_factory'
'
teams/js/teams_tab
_factory'
]),
]),
/**
/**
...
...
lms/templates/student_account/finish_auth.html
View file @
1ceb8a0d
...
@@ -5,32 +5,9 @@
...
@@ -5,32 +5,9 @@
<
%
block
name=
"pagetitle"
>
${_("Please Wait")}
</
%
block>
<
%
block
name=
"pagetitle"
>
${_("Please Wait")}
</
%
block>
<
%
block
name=
"headextra"
>
<
%
block
name=
"headextra"
>
<
%
static:require_module
module_name=
"js/student_account/views/finish_auth_factory"
class_name=
"FinishAuthFactory"
>
<script>
FinishAuthFactory();
(
function
(
require
,
define
)
{
</
%
static:require
_module
>
'use strict'
;
define
(
"js/student_account/views/finish_auth_factory"
,
[
'jquery'
,
'underscore'
,
'backbone'
,
'js/student_account/views/FinishAuthView'
],
function
(
$
,
_
,
Backbone
,
FinishAuthView
)
{
return
function
()
{
var
view
=
new
FinishAuthView
({});
view
.
render
();
};
}
);
require
([
"js/student_account/views/finish_auth_factory"
],
function
(
factory
)
{
factory
();
}
);
}).
call
(
this
,
require
||
RequireJS
.
require
,
define
||
RequireJS
.
define
);
</script>
</
%
block>
</
%
block>
<div
class=
"finish-auth"
>
<div
class=
"finish-auth"
>
...
...
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