Commit a45fe4a6 by Calen Pennington

Merge pull request #759 from MITx/feature/victor/fix-index-js-caching

Fix login-if-?next behavior
parents 93ca4a41 0b40e751
......@@ -52,6 +52,10 @@ def csrf_token(context):
' name="csrfmiddlewaretoken" value="%s" /></div>' % (csrf_token))
# NOTE: This view is not linked to directly--it is called from
# branding/views.py:index(), which is cached for anonymous users.
# This means that it should always return the same thing for anon
# users. (in particular, no switching based on query params allowed)
def index(request, extra_context={}, user=None):
'''
Render the edX main page.
......@@ -82,8 +86,6 @@ def index(request, extra_context={}, user=None):
domain=domain)
context = {'universities': universities, 'entries': entries}
context.update(extra_context)
if request.REQUEST.get('next', False):
context['show_login_immediately'] = True
return render_to_response('index.html', context)
def course_from_id(course_id):
......
// http://james.padolsey.com/javascript/bujs-1-getparameterbyname/
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)')
.exec(window.location.search);
return match ?
decodeURIComponent(match[1].replace(/\+/g, ' '))
: null;
}
......@@ -145,12 +145,22 @@
</div>
</section>
<%block name="js_extra">
<script type="text/javascript" src="${static.url('js/query-params.js')}"></script>
<script type="text/javascript"">
$(window).load(function() {
if(getParameterByName('next')) {
$('#login').trigger("click");
}
})
</script>
</%block>
% if show_signup_immediately is not UNDEFINED:
## NOTE: This won't work in production, because anonymous views are cached, so it will
## show either with or without this extra js for 3 minutes at a time.
<script type="text/javascript">
$(window).load(function() {$('#signup_action').trigger("click");});
</script>
% elif show_login_immediately is not UNDEFINED:
<script type="text/javascript">
$(window).load(function() {$('#login').trigger("click");});
$(window).load(function() {$('#signup_action').trigger("click");});
</script>
% endif
\ No newline at end of file
% endif
......@@ -14,4 +14,17 @@
<%block name="university_description" />
</section>
</section>
<%block name="js_extra">
<script type="text/javascript" src="${static.url('js/query-params.js')}"></script>
<script type="text/javascript"">
$(window).load(function() {
if(getParameterByName('next')) {
$('#login').trigger("click");
}
})
</script>
</%block>
</section>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment