From ca649d3c33a8c660d6bf06eba75d17649b311589 Mon Sep 17 00:00:00 2001 From: Jason Bau Date: Fri, 14 Jun 2013 22:12:35 -0700 Subject: [PATCH] Turn off Agreement to Terms of Service for Stanford shib As stipulated by Stanford's office of general counsel --- common/djangoapps/external_auth/views.py | 5 +++++ common/djangoapps/student/views.py | 20 +++++++++++++++----- lms/templates/register.html | 5 +++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/common/djangoapps/external_auth/views.py b/common/djangoapps/external_auth/views.py index d4a0b56293..097cdefe77 100644 --- a/common/djangoapps/external_auth/views.py +++ b/common/djangoapps/external_auth/views.py @@ -239,8 +239,13 @@ def signup(request, eamap=None): 'extauth_email': eamap.external_email, 'extauth_username': username, 'extauth_name': eamap.external_name, + 'ask_for_tos': True, } + # Can't have terms of service for Stanford users, according to Stanford's Office of General Counsel + if settings.MITX_FEATURES['AUTH_USE_SHIB'] and ('stanford' in eamap.external_domain): + context['ask_for_tos'] = False + # detect if full name is blank and ask for it from user context['ask_for_fullname'] = eamap.external_name.strip() == '' diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index 98587cd782..8bc29fa671 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -613,17 +613,27 @@ def create_account(request, post_override=None): js['field'] = 'honor_code' return HttpResponse(json.dumps(js)) - if post_vars.get('terms_of_service', 'false') != u'true': - js['value'] = "You must accept the terms of service.".format(field=a) - js['field'] = 'terms_of_service' - return HttpResponse(json.dumps(js)) + # Can't have terms of service for Stanford users, according to Stanford's Office of General Counsel + if settings.MITX_FEATURES.get("AUTH_USE_SHIB") and DoExternalAuth and ("stanford" in eamap.external_domain): + pass + else: + if post_vars.get('terms_of_service', 'false') != u'true': + js['value'] = "You must accept the terms of service.".format(field=a) + js['field'] = 'terms_of_service' + return HttpResponse(json.dumps(js)) # Confirm appropriate fields are there. # TODO: Check e-mail format is correct. # TODO: Confirm e-mail is not from a generic domain (mailinator, etc.)? Not sure if # this is a good idea # TODO: Check password is sane - for a in ['username', 'email', 'name', 'password', 'terms_of_service', 'honor_code']: + + required_post_vars = ['username', 'email', 'name', 'password', 'terms_of_service', 'honor_code'] + if settings.MITX_FEATURES.get("AUTH_USE_SHIB") and DoExternalAuth and ("stanford" in eamap.external_domain): + # Can't have terms of service for Stanford users, according to Stanford's Office of General Counsel + required_post_vars = ['username', 'email', 'name', 'password', 'honor_code'] + + for a in required_post_vars: if len(post_vars[a]) < 2: error_str = {'username': 'Username must be minimum of two characters long.', 'email': 'A properly formatted e-mail is required.', diff --git a/lms/templates/register.html b/lms/templates/register.html index 2cad6955eb..1a42d402e5 100644 --- a/lms/templates/register.html +++ b/lms/templates/register.html @@ -231,11 +231,16 @@
  1. + + % if has_extauth_info is UNDEFINED or ask_for_tos : +
    + % endif +
    <%