Commit 08dffa12 by Xavier Antoviaque

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'
]
```
parent adddd75f
...@@ -119,6 +119,7 @@ EMAIL_USE_TLS = ENV_TOKENS.get('EMAIL_USE_TLS', False) # django default is Fals ...@@ -119,6 +119,7 @@ EMAIL_USE_TLS = ENV_TOKENS.get('EMAIL_USE_TLS', False) # django default is Fals
SITE_NAME = ENV_TOKENS['SITE_NAME'] SITE_NAME = ENV_TOKENS['SITE_NAME']
SESSION_ENGINE = ENV_TOKENS.get('SESSION_ENGINE', SESSION_ENGINE) SESSION_ENGINE = ENV_TOKENS.get('SESSION_ENGINE', SESSION_ENGINE)
SESSION_COOKIE_DOMAIN = ENV_TOKENS.get('SESSION_COOKIE_DOMAIN') 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') CMS_BASE = ENV_TOKENS.get('CMS_BASE', 'studio.edx.org')
......
...@@ -1044,3 +1044,14 @@ if MITX_FEATURES.get('AUTH_USE_CAS'): ...@@ -1044,3 +1044,14 @@ if MITX_FEATURES.get('AUTH_USE_CAS'):
) )
INSTALLED_APPS += ('django_cas',) INSTALLED_APPS += ('django_cas',)
MIDDLEWARE_CLASSES += ('django_cas.middleware.CASMiddleware',) 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',
])
...@@ -185,6 +185,7 @@ ...@@ -185,6 +185,7 @@
<h2 class="sr">${_("Optional Personal Information")}</h2> <h2 class="sr">${_("Optional Personal Information")}</h2>
<ol class="list-input"> <ol class="list-input">
% if 'level_of_education' in settings.REGISTRATION_OPTIONAL_FIELDS:
<li class="field-group"> <li class="field-group">
<div class="field select" id="field-education-level"> <div class="field select" id="field-education-level">
<label for="education-level">${_("Highest Level of Education Completed")}</label> <label for="education-level">${_("Highest Level of Education Completed")}</label>
...@@ -195,7 +196,10 @@ ...@@ -195,7 +196,10 @@
%endfor %endfor
</select> </select>
</div> </div>
</li>
% endif
% if 'gender' in settings.REGISTRATION_OPTIONAL_FIELDS:
<li class="field-group">
<div class="field select" id="field-gender"> <div class="field select" id="field-gender">
<label for="gender">${_("Gender")}</label> <label for="gender">${_("Gender")}</label>
<select id="gender" name="gender"> <select id="gender" name="gender">
...@@ -205,7 +209,10 @@ ...@@ -205,7 +209,10 @@
%endfor %endfor
</select> </select>
</div> </div>
</li>
% endif
% if 'year_of_birth' in settings.REGISTRATION_OPTIONAL_FIELDS:
<li class="field-group">
<div class="field select" id="field-yob"> <div class="field select" id="field-yob">
<label for="yob">${_("Year of Birth")}</label> <label for="yob">${_("Year of Birth")}</label>
<select id="yob" name="year_of_birth"> <select id="yob" name="year_of_birth">
...@@ -215,6 +222,7 @@ ...@@ -215,6 +222,7 @@
%endfor %endfor
</select> </select>
</div> </div>
% endif
</li> </li>
</ol> </ol>
</div> </div>
...@@ -223,15 +231,19 @@ ...@@ -223,15 +231,19 @@
<h2 class="sr">${_("Optional Personal Information")}</h2> <h2 class="sr">${_("Optional Personal Information")}</h2>
<ol class="list-input"> <ol class="list-input">
% if 'mailing_address' in settings.REGISTRATION_OPTIONAL_FIELDS:
<li class="field text" id="field-address-mailing"> <li class="field text" id="field-address-mailing">
<label for="address-mailing">${_("Mailing Address")}</label> <label for="address-mailing">${_("Mailing Address")}</label>
<textarea id="address-mailing" name="mailing_address" value=""></textarea> <textarea id="address-mailing" name="mailing_address" value=""></textarea>
</li> </li>
% endif
% if 'goals' in settings.REGISTRATION_OPTIONAL_FIELDS:
<li class="field text" id="field-goals"> <li class="field text" id="field-goals">
<label for="goals">${_("Please share with us your reasons for registering with {platform_name}").format(platform_name=settings.PLATFORM_NAME)}</label> <label for="goals">${_("Please share with us your reasons for registering with {platform_name}").format(platform_name=settings.PLATFORM_NAME)}</label>
<textarea id="goals" name="goals" value=""></textarea> <textarea id="goals" name="goals" value=""></textarea>
</li> </li>
% endif
</ol> </ol>
</div> </div>
......
<%! from django.utils.translation import ugettext as _ %> <%! from django.utils.translation import ugettext as _ %>
<%namespace name='static' file='static_content.html'/> <%namespace name='static' file='static_content.html'/>
<%! from django.conf import settings %>
<%! from django.core.urlresolvers import reverse %> <%! from django.core.urlresolvers import reverse %>
<%! from django_countries.countries import COUNTRIES %> <%! from django_countries.countries import COUNTRIES %>
<%! from student.models import UserProfile %> <%! from student.models import UserProfile %>
...@@ -57,6 +58,8 @@ ...@@ -57,6 +58,8 @@
</div> </div>
<div class="input-group"> <div class="input-group">
% if 'level_of_education' in settings.REGISTRATION_OPTIONAL_FIELDS:
<section class="citizenship"> <section class="citizenship">
<label data-field="level_of_education" for="signup_ed_level">${_("Ed. Completed")}</label> <label data-field="level_of_education" for="signup_ed_level">${_("Ed. Completed")}</label>
<div class="input-wrapper"> <div class="input-wrapper">
...@@ -68,7 +71,9 @@ ...@@ -68,7 +71,9 @@
</select> </select>
</div> </div>
</section> </section>
% endif
% if 'gender' in settings.REGISTRATION_OPTIONAL_FIELDS:
<section class="gender"> <section class="gender">
<label data-field="gender" for="signup_gender">${_("Gender")}</label> <label data-field="gender" for="signup_gender">${_("Gender")}</label>
<div class="input-wrapper"> <div class="input-wrapper">
...@@ -80,7 +85,9 @@ ...@@ -80,7 +85,9 @@
</select> </select>
</div> </div>
</section> </section>
% endif
% if 'year_of_birth' in settings.REGISTRATION_OPTIONAL_FIELDS:
<section class="date-of-birth"> <section class="date-of-birth">
<label data-field="date-of-birth" for="signup_birth_year">${_("Year of birth")}</label> <label data-field="date-of-birth" for="signup_birth_year">${_("Year of birth")}</label>
<div class="input-wrapper"> <div class="input-wrapper">
...@@ -93,12 +100,17 @@ ...@@ -93,12 +100,17 @@
##<input name="year_of_birth" type="text" placeholder="Year of birth"> ##<input name="year_of_birth" type="text" placeholder="Year of birth">
</div> </div>
</section> </section>
% endif
% if 'mailing_address' in settings.REGISTRATION_OPTIONAL_FIELDS:
<label data-field="mailing_address" for="signup_mailing_address">${_("Mailing address")}</label> <label data-field="mailing_address" for="signup_mailing_address">${_("Mailing address")}</label>
<textarea id="signup_mailing_address" name="mailing_address"></textarea> <textarea id="signup_mailing_address" name="mailing_address"></textarea>
% endif
% if 'goals' in settings.REGISTRATION_OPTIONAL_FIELDS:
<label data-field="goals" for="signup_goals">${_("Goals in signing up for {platform_name}").format(platform_name=settings.PLATFORM_NAME)}</label> <label data-field="goals" for="signup_goals">${_("Goals in signing up for {platform_name}").format(platform_name=settings.PLATFORM_NAME)}</label>
<textarea name="goals" id="signup_goals"></textarea> <textarea name="goals" id="signup_goals"></textarea>
% endif
</div> </div>
......
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