From 08dffa12cc0c67b49e37677edd6a00339ee14ca0 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Fri, 13 Sep 2013 11:12:26 -0300 Subject: [PATCH] registration-optional: Allow to hide some optional registration fields Allow to control which of the optional fields from the registration page are being displayed to the user. Added the configuration variable `REGISTRATION_OPTIONAL_FIELDS` to control which ones. The default value shows all the fields as currently; to not display some of the fields, set the configuration variable with only the fields you want to display: ``` REGISTRATION_OPTIONAL_FIELDS = [ 'level_of_education', 'gender', 'year_of_birth', 'mailing_address', 'goals' ] ``` --- lms/envs/aws.py | 1 + lms/envs/common.py | 11 +++++++++++ lms/templates/register.html | 16 ++++++++++++++-- lms/templates/signup_modal.html | 12 ++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 7fe8d8e10f..1506891051 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -119,6 +119,7 @@ EMAIL_USE_TLS = ENV_TOKENS.get('EMAIL_USE_TLS', False) # django default is Fals SITE_NAME = ENV_TOKENS['SITE_NAME'] SESSION_ENGINE = ENV_TOKENS.get('SESSION_ENGINE', SESSION_ENGINE) SESSION_COOKIE_DOMAIN = ENV_TOKENS.get('SESSION_COOKIE_DOMAIN') +REGISTRATION_OPTIONAL_FIELDS = ENV_TOKENS.get('REGISTRATION_OPTIONAL_FIELDS', REGISTRATION_OPTIONAL_FIELDS) CMS_BASE = ENV_TOKENS.get('CMS_BASE', 'studio.edx.org') diff --git a/lms/envs/common.py b/lms/envs/common.py index df83bc9218..33301d1f31 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1044,3 +1044,14 @@ if MITX_FEATURES.get('AUTH_USE_CAS'): ) INSTALLED_APPS += ('django_cas',) MIDDLEWARE_CLASSES += ('django_cas.middleware.CASMiddleware',) + +###################### Registration ################################## + +# Remove some of the fields from the list to not display them +REGISTRATION_OPTIONAL_FIELDS = set([ + 'level_of_education', + 'gender', + 'year_of_birth', + 'mailing_address', + 'goals', +]) diff --git a/lms/templates/register.html b/lms/templates/register.html index 54fdf34786..e0c1c333f9 100644 --- a/lms/templates/register.html +++ b/lms/templates/register.html @@ -185,6 +185,7 @@

${_("Optional Personal Information")}

    + % if 'level_of_education' in settings.REGISTRATION_OPTIONAL_FIELDS:
  1. @@ -195,7 +196,10 @@ %endfor
    - +
  2. + % endif + % if 'gender' in settings.REGISTRATION_OPTIONAL_FIELDS: +
  3. - +
  4. + % endif + % if 'year_of_birth' in settings.REGISTRATION_OPTIONAL_FIELDS: +
  5. + % endif
@@ -223,15 +231,19 @@

${_("Optional Personal Information")}

    + % if 'mailing_address' in settings.REGISTRATION_OPTIONAL_FIELDS:
  1. + % endif + % if 'goals' in settings.REGISTRATION_OPTIONAL_FIELDS:
  2. + % endif
diff --git a/lms/templates/signup_modal.html b/lms/templates/signup_modal.html index 4b13bebb04..345ce8bbf9 100644 --- a/lms/templates/signup_modal.html +++ b/lms/templates/signup_modal.html @@ -1,6 +1,7 @@ <%! from django.utils.translation import ugettext as _ %> <%namespace name='static' file='static_content.html'/> +<%! from django.conf import settings %> <%! from django.core.urlresolvers import reverse %> <%! from django_countries.countries import COUNTRIES %> <%! from student.models import UserProfile %> @@ -57,6 +58,8 @@
+ + % if 'level_of_education' in settings.REGISTRATION_OPTIONAL_FIELDS:
@@ -68,7 +71,9 @@
+ % endif + % if 'gender' in settings.REGISTRATION_OPTIONAL_FIELDS:
@@ -80,7 +85,9 @@
+ % endif + % if 'year_of_birth' in settings.REGISTRATION_OPTIONAL_FIELDS:
@@ -93,12 +100,17 @@ ##
+ % endif + % if 'mailing_address' in settings.REGISTRATION_OPTIONAL_FIELDS: + % endif + % if 'goals' in settings.REGISTRATION_OPTIONAL_FIELDS: + % endif