Commit ab912fa8 by Muzaffar yousaf

Merge pull request #7956 from edx/muzaffar/tnl2047-profile-tweaks

Learner Profile page tweaks.
parents 36060f3f cae5623f
......@@ -47,7 +47,7 @@ class LearnerProfileTestMixin(EventsTestMixin):
Fill in the public profile fields of a user.
"""
profile_page.value_for_dropdown_field('language_proficiencies', 'English')
profile_page.value_for_dropdown_field('country', 'United Kingdom')
profile_page.value_for_dropdown_field('country', 'United Arab Emirates')
profile_page.value_for_textarea_field('bio', 'Nothing Special')
def visit_profile_page(self, username, privacy=None):
......
......@@ -338,13 +338,6 @@ def account_settings_context(request):
"""
user = request.user
country_options = [
(country_code, _(country_name)) # pylint: disable=translation-of-non-string
for country_code, country_name in sorted(
countries.countries, key=lambda(__, name): unicode(name)
)
]
year_of_birth_options = [(unicode(year), unicode(year)) for year in UserProfile.VALID_YEARS]
context = {
......@@ -352,7 +345,7 @@ def account_settings_context(request):
'duplicate_provider': None,
'fields': {
'country': {
'options': country_options,
'options': list(countries),
}, 'gender': {
'options': [(choice[0], _(choice[1])) for choice in UserProfile.GENDER_CHOICES], # pylint: disable=translation-of-non-string
}, 'language': {
......
......@@ -4,6 +4,7 @@
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.client import RequestFactory
from util.testing import UrlResetMixin
from student.tests.factories import UserFactory
......@@ -25,6 +26,8 @@ class LearnerProfileViewTest(UrlResetMixin, TestCase):
'own_profile',
'country_options',
'language_options',
'account_settings_data',
'preferences_data',
]
def setUp(self):
......@@ -36,7 +39,9 @@ class LearnerProfileViewTest(UrlResetMixin, TestCase):
"""
Verify learner profile page context data.
"""
context = learner_profile_context(self.user.username, self.USERNAME, self.user.is_staff)
request = RequestFactory().get('/url')
context = learner_profile_context(self.user, self.USERNAME, self.user.is_staff, request.build_absolute_uri)
self.assertEqual(
context['data']['default_public_account_fields'],
......
......@@ -6,12 +6,15 @@ from django_countries import countries
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.http import Http404
from django.views.decorators.http import require_http_methods
from edxmako.shortcuts import render_to_response
from openedx.core.djangoapps.user_api.accounts.api import get_account_settings
from openedx.core.djangoapps.user_api.accounts.serializers import PROFILE_IMAGE_KEY_PREFIX
from openedx.core.djangoapps.user_api.errors import UserNotFound, UserNotAuthorized
from openedx.core.djangoapps.user_api.preferences.api import get_user_preferences
from student.models import User
from microsite_configuration import microsite
from django.utils.translation import ugettext as _
......@@ -29,8 +32,9 @@ def learner_profile(request, username):
Returns:
HttpResponse: 200 if the page was sent successfully
HttpResponse: 302 if not logged in (redirect to login page)
HttpResponse: 404 if the specified username does not exist
HttpResponse: 405 if using an unsupported HTTP method
Raises:
Http404: 404 if the specified user is not authorized or does not exist
Example usage:
GET /account/profile
......@@ -38,19 +42,20 @@ def learner_profile(request, username):
try:
return render_to_response(
'student_profile/learner_profile.html',
learner_profile_context(request.user.username, username, request.user.is_staff)
learner_profile_context(request.user, username, request.user.is_staff, request.build_absolute_uri)
)
except ObjectDoesNotExist:
return HttpResponse(status=404)
except (UserNotAuthorized, UserNotFound, ObjectDoesNotExist):
raise Http404
def learner_profile_context(logged_in_username, profile_username, user_is_staff):
def learner_profile_context(logged_in_user, profile_username, user_is_staff, build_absolute_uri_func):
"""Context for the learner profile page.
Args:
logged_in_username (str): Username of user logged In user.
logged_in_user (object): Logged In user.
profile_username (str): username of user whose profile is requested.
user_is_staff (bool): Logged In user has staff access.
build_absolute_uri_func ():
Returns:
dict
......@@ -60,12 +65,15 @@ def learner_profile_context(logged_in_username, profile_username, user_is_staff)
"""
profile_user = User.objects.get(username=profile_username)
country_options = [
(country_code, _(country_name)) # pylint: disable=translation-of-non-string
for country_code, country_name in sorted(
countries.countries, key=lambda(__, name): unicode(name)
)
]
own_profile = (logged_in_user.username == profile_username)
account_settings_data = get_account_settings(logged_in_user, profile_username)
# Account for possibly relative URLs.
for key, value in account_settings_data['profile_image'].items():
if key.startswith(PROFILE_IMAGE_KEY_PREFIX):
account_settings_data['profile_image'][key] = build_absolute_uri_func(value)
preferences_data = get_user_preferences(profile_user, profile_username)
context = {
'data': {
......@@ -74,17 +82,18 @@ def learner_profile_context(logged_in_username, profile_username, user_is_staff)
'default_visibility': settings.ACCOUNT_VISIBILITY_CONFIGURATION['default_visibility'],
'accounts_api_url': reverse("accounts_api", kwargs={'username': profile_username}),
'preferences_api_url': reverse('preferences_api', kwargs={'username': profile_username}),
'preferences_data': preferences_data,
'account_settings_data': account_settings_data,
'profile_image_upload_url': reverse('profile_image_upload', kwargs={'username': profile_username}),
'profile_image_remove_url': reverse('profile_image_remove', kwargs={'username': profile_username}),
'profile_image_max_bytes': settings.PROFILE_IMAGE_MAX_BYTES,
'profile_image_min_bytes': settings.PROFILE_IMAGE_MIN_BYTES,
'account_settings_page_url': reverse('account_settings'),
'has_preferences_access': (logged_in_username == profile_username or user_is_staff),
'own_profile': (logged_in_username == profile_username),
'country_options': country_options,
'has_preferences_access': (logged_in_user.username == profile_username or user_is_staff),
'own_profile': own_profile,
'country_options': list(countries),
'language_options': settings.ALL_LANGUAGES,
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
}
}
return context
......@@ -27,7 +27,7 @@ define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'j
TemplateHelpers.installTemplate('templates/student_profile/learner_profile');
});
var createProfilePage = function(ownProfile) {
var createProfilePage = function(ownProfile, options) {
return new LearnerProfilePage({
'accounts_api_url': Helpers.USER_ACCOUNTS_API_URL,
'preferences_api_url': Helpers.USER_PREFERENCES_API_URL,
......@@ -41,55 +41,13 @@ define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'j
'profile_image_upload_url': Helpers.IMAGE_UPLOAD_API_URL,
'profile_image_remove_url': Helpers.IMAGE_REMOVE_API_URL,
'default_visibility': 'all_users',
'platform_name': 'edX'
'platform_name': 'edX',
'account_settings_data': Helpers.createAccountSettingsData(options),
'preferences_data': Helpers.createUserPreferencesData()
});
};
it("show loading error when UserAccountModel fails to load", function() {
requests = AjaxHelpers.requests(this);
var context = createProfilePage(true),
learnerProfileView = context.learnerProfileView;
var userAccountRequest = requests[0];
expect(userAccountRequest.method).toBe('GET');
expect(userAccountRequest.url).toBe(Helpers.USER_ACCOUNTS_API_URL);
AjaxHelpers.respondWithError(requests, 500);
Helpers.expectLoadingErrorIsVisible(learnerProfileView, true);
Helpers.expectLoadingIndicatorIsVisible(learnerProfileView, false);
LearnerProfileHelpers.expectProfileSectionsNotToBeRendered(learnerProfileView);
});
it("shows loading error when UserPreferencesModel fails to load", function() {
requests = AjaxHelpers.requests(this);
var context = createProfilePage(true),
learnerProfileView = context.learnerProfileView;
var userAccountRequest = requests[0];
expect(userAccountRequest.method).toBe('GET');
expect(userAccountRequest.url).toBe(Helpers.USER_ACCOUNTS_API_URL);
AjaxHelpers.respondWithJson(requests, Helpers.createAccountSettingsData());
Helpers.expectLoadingIndicatorIsVisible(learnerProfileView, true);
Helpers.expectLoadingErrorIsVisible(learnerProfileView, false);
LearnerProfileHelpers.expectProfileSectionsNotToBeRendered(learnerProfileView);
var userPreferencesRequest = requests[1];
expect(userPreferencesRequest.method).toBe('GET');
expect(userPreferencesRequest.url).toBe(Helpers.USER_PREFERENCES_API_URL);
AjaxHelpers.respondWithError(requests, 500);
Helpers.expectLoadingIndicatorIsVisible(learnerProfileView, false);
Helpers.expectLoadingErrorIsVisible(learnerProfileView, true);
LearnerProfileHelpers.expectProfileSectionsNotToBeRendered(learnerProfileView);
});
it("renders the full profile after models are successfully fetched", function() {
it("renders the full profile after data is successfully fetched", function() {
requests = AjaxHelpers.requests(this);
......@@ -106,33 +64,19 @@ define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'j
it("renders the limited profile for undefined 'year_of_birth'", function() {
requests = AjaxHelpers.requests(this);
var context = createProfilePage(true),
var context = createProfilePage(true, {year_of_birth: '', requires_parental_consent: true}),
learnerProfileView = context.learnerProfileView;
AjaxHelpers.respondWithJson(requests, Helpers.createAccountSettingsData({
year_of_birth: '',
requires_parental_consent: true
}));
AjaxHelpers.respondWithJson(requests, Helpers.createUserPreferencesData());
LearnerProfileHelpers.expectLimitedProfileSectionsAndFieldsToBeRendered(learnerProfileView);
});
it("renders the limited profile for under 13 users", function() {
requests = AjaxHelpers.requests(this);
var context = createProfilePage(true),
learnerProfileView = context.learnerProfileView;
AjaxHelpers.respondWithJson(requests, Helpers.createAccountSettingsData({
year_of_birth: new Date().getFullYear() - 10,
requires_parental_consent: true
}));
AjaxHelpers.respondWithJson(requests, Helpers.createUserPreferencesData());
var context = createProfilePage(
true,
{year_of_birth: new Date().getFullYear() - 10, requires_parental_consent: true}
);
var learnerProfileView = context.learnerProfileView;
LearnerProfileHelpers.expectLimitedProfileSectionsAndFieldsToBeRendered(learnerProfileView);
});
});
......
......@@ -34,8 +34,8 @@
// Currently when a non-staff user A access user B's profile, the only way to tell whether user B's
// profile is public is to check if the api has returned fields other than the default public fields
// specified in settings.ACCOUNT_VISIBILITY_CONFIGURATION.
var profileIsPublic = _.size(_.difference(_.keys(response), this.get('default_public_account_fields'))) > 0;
this.set({'profile_is_public': profileIsPublic}, { silent: true });
var responseKeys = _.filter(_.keys(response), function (key) {return key !== 'default_public_account_fields'});
response.profile_is_public = _.size(_.difference(responseKeys, response.default_public_account_fields)) > 0;
return response;
},
......
......@@ -15,19 +15,23 @@
return function (options) {
var learnerProfileElement = $('.wrapper-profile');
var defaultVisibility = options.default_visibility;
var accountSettingsModel = new AccountSettingsModel(
_.extend(
options.account_settings_data,
{'default_public_account_fields': options.default_public_account_fields}
),
{parse: true}
);
var AccountPreferencesModelWithDefaults = AccountPreferencesModel.extend({
defaults: {
account_privacy: defaultVisibility
account_privacy: options.default_visibility
}
});
var accountPreferencesModel = new AccountPreferencesModelWithDefaults();
accountPreferencesModel.url = options.preferences_api_url;
var accountPreferencesModel = new AccountPreferencesModelWithDefaults(options.preferences_data);
var accountSettingsModel = new AccountSettingsModel({
'default_public_account_fields': options.default_public_account_fields
});
accountSettingsModel.url = options.accounts_api_url;
accountPreferencesModel.url = options.preferences_api_url;
var editable = options.own_profile ? 'toggle' : 'never';
......@@ -122,10 +126,6 @@
sectionTwoFieldViews: sectionTwoFieldViews
});
var showLoadingError = function () {
learnerProfileView.showLoadingError();
};
var getProfileVisibility = function() {
if (options.has_preferences_access) {
return accountPreferencesModel.get('account_privacy');
......@@ -146,26 +146,12 @@
learnerProfileView.render();
};
accountSettingsModel.fetch({
success: function () {
// Fetch the preferences model if the user has access
if (options.has_preferences_access) {
accountPreferencesModel.fetch({
success: function() {
if (accountSettingsModel.get('requires_parental_consent')) {
accountPreferencesModel.set('account_privacy', 'private');
}
showLearnerProfileView();
},
error: showLoadingError
});
}
else {
showLearnerProfileView();
}
},
error: showLoadingError
});
if (options.has_preferences_access) {
if (accountSettingsModel.get('requires_parental_consent')) {
accountPreferencesModel.set('account_privacy', 'private');
}
}
showLearnerProfileView();
return {
accountSettingsModel: accountSettingsModel,
......
......@@ -114,7 +114,11 @@
setTimeout(function () {
if ((context === view.lastSuccessMessageContext) && (view.getNotificationMessage() === successMessage)) {
view.showHelpMessage();
if (view.editable === 'toggle') {
view.showCanEditMessage(true);
} else {
view.showHelpMessage();
}
}
}, messageRevertDelay);
},
......
......@@ -218,7 +218,6 @@
.wrapper-profile-section-two {
width: flex-grid(8, 12);
margin-top: ($baseline*1.5);
}
.profile-section-two-fields {
......
......@@ -256,7 +256,7 @@
<label for="country">${_("Country")}</label>
<select id="country" name="country" ${'required aria-required="true"' if settings.REGISTRATION_EXTRA_FIELDS['country'] == 'required' else ''}>
<option value="">--</option>
%for code, country_name in sorted(countries.countries, key=lambda (__, name): unicode(name)):
%for code, country_name in countries:
<option value="${code}">${ unicode(country_name) }</option>
%endfor
</select>
......
<%! import json %>
<%! from django.core.urlresolvers import reverse %>
<%! from django.utils.translation import ugettext as _ %>
<%! from xmodule.modulestore import EdxJSONEncoder %>
<%inherit file="/main.html" />
<%namespace name='static' file='/static_content.html'/>
......@@ -38,7 +39,7 @@
<script>
(function (require) {
require(['js/student_profile/views/learner_profile_factory'], function(setupLearnerProfile) {
var options = ${ json.dumps(data) };
var options = ${ json.dumps(data, cls=EdxJSONEncoder) };
setupLearnerProfile(options);
});
}).call(this, require || RequireJS.require);
......
# -*- coding: utf-8 -*-
"""Constants used in the test suite. """
SORTED_COUNTRIES = [
(u'AF', u'Afghanistan'),
(u'AL', u'Albania'),
(u'DZ', u'Algeria'),
(u'AS', u'American Samoa'),
(u'AD', u'Andorra'),
(u'AO', u'Angola'),
(u'AI', u'Anguilla'),
(u'AQ', u'Antarctica'),
(u'AG', u'Antigua and Barbuda'),
(u'AR', u'Argentina'),
(u'AM', u'Armenia'),
(u'AW', u'Aruba'),
(u'AU', u'Australia'),
(u'AT', u'Austria'),
(u'AZ', u'Azerbaijan'),
(u'BS', u'Bahamas'),
(u'BH', u'Bahrain'),
(u'BD', u'Bangladesh'),
(u'BB', u'Barbados'),
(u'BY', u'Belarus'),
(u'BE', u'Belgium'),
(u'BZ', u'Belize'),
(u'BJ', u'Benin'),
(u'BM', u'Bermuda'),
(u'BT', u'Bhutan'),
(u'BO', u'Bolivia, Plurinational State of'),
(u'BQ', u'Bonaire, Sint Eustatius and Saba'),
(u'BA', u'Bosnia and Herzegovina'),
(u'BW', u'Botswana'),
(u'BV', u'Bouvet Island'),
(u'BR', u'Brazil'),
(u'IO', u'British Indian Ocean Territory'),
(u'BN', u'Brunei Darussalam'),
(u'BG', u'Bulgaria'),
(u'BF', u'Burkina Faso'),
(u'BI', u'Burundi'),
(u'KH', u'Cambodia'),
(u'CM', u'Cameroon'),
(u'CA', u'Canada'),
(u'CV', u'Cape Verde'),
(u'KY', u'Cayman Islands'),
(u'CF', u'Central African Republic'),
(u'TD', u'Chad'),
(u'CL', u'Chile'),
(u'CN', u'China'),
(u'CX', u'Christmas Island'),
(u'CC', u'Cocos (Keeling) Islands'),
(u'CO', u'Colombia'),
(u'KM', u'Comoros'),
(u'CG', u'Congo'),
(u'CD', u'Congo (the Democratic Republic of the)'),
(u'CK', u'Cook Islands'),
(u'CR', u'Costa Rica'),
(u'HR', u'Croatia'),
(u'CU', u'Cuba'),
(u'CW', u'Cura\xe7ao'),
(u'CY', u'Cyprus'),
(u'CZ', u'Czech Republic'),
(u'CI', u"C\xf4te d'Ivoire"),
(u'DK', u'Denmark'),
(u'DJ', u'Djibouti'),
(u'DM', u'Dominica'),
(u'DO', u'Dominican Republic'),
(u'EC', u'Ecuador'),
(u'EG', u'Egypt'),
(u'SV', u'El Salvador'),
(u'GQ', u'Equatorial Guinea'),
(u'ER', u'Eritrea'),
(u'EE', u'Estonia'),
(u'ET', u'Ethiopia'),
(u'FK', u'Falkland Islands [Malvinas]'),
(u'FO', u'Faroe Islands'),
(u'FJ', u'Fiji'),
(u'FI', u'Finland'),
(u'FR', u'France'),
(u'GF', u'French Guiana'),
(u'PF', u'French Polynesia'),
(u'TF', u'French Southern Territories'),
(u'GA', u'Gabon'),
(u'GM', u'Gambia (The)'),
(u'GE', u'Georgia'),
(u'DE', u'Germany'),
(u'GH', u'Ghana'),
(u'GI', u'Gibraltar'),
(u'GR', u'Greece'),
(u'GL', u'Greenland'),
(u'GD', u'Grenada'),
(u'GP', u'Guadeloupe'),
(u'GU', u'Guam'),
(u'GT', u'Guatemala'),
(u'GG', u'Guernsey'),
(u'GN', u'Guinea'),
(u'GW', u'Guinea-Bissau'),
(u'GY', u'Guyana'),
(u'HT', u'Haiti'),
(u'HM', u'Heard Island and McDonald Islands'),
(u'VA', u'Holy See [Vatican City State]'),
(u'HN', u'Honduras'),
(u'HK', u'Hong Kong'),
(u'HU', u'Hungary'),
(u'IS', u'Iceland'),
(u'IN', u'India'),
(u'ID', u'Indonesia'),
(u'IR', u'Iran (the Islamic Republic of)'),
(u'IQ', u'Iraq'),
(u'IE', u'Ireland'),
(u'IM', u'Isle of Man'),
(u'IL', u'Israel'),
(u'IT', u'Italy'),
(u'JM', u'Jamaica'),
(u'JP', u'Japan'),
(u'JE', u'Jersey'),
(u'JO', u'Jordan'),
(u'KZ', u'Kazakhstan'),
(u'KE', u'Kenya'),
(u'KI', u'Kiribati'),
(u'KP', u"Korea (the Democratic People's Republic of)"),
(u'KR', u'Korea (the Republic of)'),
(u'KW', u'Kuwait'),
(u'KG', u'Kyrgyzstan'),
(u'LA', u"Lao People's Democratic Republic"),
(u'LV', u'Latvia'),
(u'LB', u'Lebanon'),
(u'LS', u'Lesotho'),
(u'LR', u'Liberia'),
(u'LY', u'Libya'),
(u'LI', u'Liechtenstein'),
(u'LT', u'Lithuania'),
(u'LU', u'Luxembourg'),
(u'MO', u'Macao'),
(u'MK', u'Macedonia (the former Yugoslav Republic of)'),
(u'MG', u'Madagascar'),
(u'MW', u'Malawi'),
(u'MY', u'Malaysia'),
(u'MV', u'Maldives'),
(u'ML', u'Mali'),
(u'MT', u'Malta'),
(u'MH', u'Marshall Islands'),
(u'MQ', u'Martinique'),
(u'MR', u'Mauritania'),
(u'MU', u'Mauritius'),
(u'YT', u'Mayotte'),
(u'MX', u'Mexico'),
(u'FM', u'Micronesia (the Federated States of)'),
(u'MD', u'Moldova (the Republic of)'),
(u'MC', u'Monaco'),
(u'MN', u'Mongolia'),
(u'ME', u'Montenegro'),
(u'MS', u'Montserrat'),
(u'MA', u'Morocco'),
(u'MZ', u'Mozambique'),
(u'MM', u'Myanmar'),
(u'NA', u'Namibia'),
(u'NR', u'Nauru'),
(u'NP', u'Nepal'),
(u'NL', u'Netherlands'),
(u'NC', u'New Caledonia'),
(u'NZ', u'New Zealand'),
(u'NI', u'Nicaragua'),
(u'NE', u'Niger'),
(u'NG', u'Nigeria'),
(u'NU', u'Niue'),
(u'NF', u'Norfolk Island'),
(u'MP', u'Northern Mariana Islands'),
(u'NO', u'Norway'),
(u'OM', u'Oman'),
(u'PK', u'Pakistan'),
(u'PW', u'Palau'),
(u'PS', u'Palestine, State of'),
(u'PA', u'Panama'),
(u'PG', u'Papua New Guinea'),
(u'PY', u'Paraguay'),
(u'PE', u'Peru'),
(u'PH', u'Philippines'),
(u'PN', u'Pitcairn'),
(u'PL', u'Poland'),
(u'PT', u'Portugal'),
(u'PR', u'Puerto Rico'),
(u'QA', u'Qatar'),
(u'RO', u'Romania'),
(u'RU', u'Russian Federation'),
(u'RW', u'Rwanda'),
(u'RE', u'R\xe9union'),
(u'BL', u'Saint Barth\xe9lemy'),
(u'SH', u'Saint Helena, Ascension and Tristan da Cunha'),
(u'KN', u'Saint Kitts and Nevis'),
(u'LC', u'Saint Lucia'),
(u'MF', u'Saint Martin (French part)'),
(u'PM', u'Saint Pierre and Miquelon'),
(u'VC', u'Saint Vincent and the Grenadines'),
(u'WS', u'Samoa'),
(u'SM', u'San Marino'),
(u'ST', u'Sao Tome and Principe'),
(u'SA', u'Saudi Arabia'),
(u'SN', u'Senegal'),
(u'RS', u'Serbia'),
(u'SC', u'Seychelles'),
(u'SL', u'Sierra Leone'),
(u'SG', u'Singapore'),
(u'SX', u'Sint Maarten (Dutch part)'),
(u'SK', u'Slovakia'),
(u'SI', u'Slovenia'),
(u'SB', u'Solomon Islands'),
(u'SO', u'Somalia'),
(u'ZA', u'South Africa'),
(u'GS', u'South Georgia and the South Sandwich Islands'),
(u'SS', u'South Sudan'),
(u'ES', u'Spain'),
(u'LK', u'Sri Lanka'),
(u'SD', u'Sudan'),
(u'SR', u'Suriname'),
(u'SJ', u'Svalbard and Jan Mayen'),
(u'SZ', u'Swaziland'),
(u'SE', u'Sweden'),
(u'CH', u'Switzerland'),
(u'SY', u'Syrian Arab Republic'),
(u'TW', u'Taiwan'),
(u'TJ', u'Tajikistan'),
(u'TZ', u'Tanzania, United Republic of'),
(u'TH', u'Thailand'),
(u'TL', u'Timor-Leste'),
(u'TG', u'Togo'),
(u'TK', u'Tokelau'),
(u'TO', u'Tonga'),
(u'TT', u'Trinidad and Tobago'),
(u'TN', u'Tunisia'),
(u'TR', u'Turkey'),
(u'TM', u'Turkmenistan'),
(u'TC', u'Turks and Caicos Islands'),
(u'TV', u'Tuvalu'),
(u'UG', u'Uganda'),
(u'UA', u'Ukraine'),
(u'AE', u'United Arab Emirates'),
(u'GB', u'United Kingdom'),
(u'US', u'United States'),
(u'UM', u'United States Minor Outlying Islands'),
(u'UY', u'Uruguay'),
(u'UZ', u'Uzbekistan'),
(u'VU', u'Vanuatu'),
(u'VE', u'Venezuela, Bolivarian Republic of'),
(u'VN', u'Viet Nam'),
(u'VG', u'Virgin Islands (British)'),
(u'VI', u'Virgin Islands (U.S.)'),
(u'WF', u'Wallis and Futuna'),
(u'EH', u'Western Sahara'),
(u'YE', u'Yemen'),
(u'ZM', u'Zambia'),
(u'ZW', u'Zimbabwe'),
(u'AX', u'\xc5land Islands')
(u"AF", u"Afghanistan"),
(u"AX", u"Åland Islands"),
(u"AL", u"Albania"),
(u"DZ", u"Algeria"),
(u"AS", u"American Samoa"),
(u"AD", u"Andorra"),
(u"AO", u"Angola"),
(u"AI", u"Anguilla"),
(u"AQ", u"Antarctica"),
(u"AG", u"Antigua and Barbuda"),
(u"AR", u"Argentina"),
(u"AM", u"Armenia"),
(u"AW", u"Aruba"),
(u"AU", u"Australia"),
(u"AT", u"Austria"),
(u"AZ", u"Azerbaijan"),
(u"BS", u"Bahamas"),
(u"BH", u"Bahrain"),
(u"BD", u"Bangladesh"),
(u"BB", u"Barbados"),
(u"BY", u"Belarus"),
(u"BE", u"Belgium"),
(u"BZ", u"Belize"),
(u"BJ", u"Benin"),
(u"BM", u"Bermuda"),
(u"BT", u"Bhutan"),
(u"BO", u"Bolivia"),
(u"BQ", u"Bonaire, Sint Eustatius and Saba"),
(u"BA", u"Bosnia and Herzegovina"),
(u"BW", u"Botswana"),
(u"BV", u"Bouvet Island"),
(u"BR", u"Brazil"),
(u"IO", u"British Indian Ocean Territory"),
(u"BN", u"Brunei"),
(u"BG", u"Bulgaria"),
(u"BF", u"Burkina Faso"),
(u"BI", u"Burundi"),
(u"CV", u"Cabo Verde"),
(u"KH", u"Cambodia"),
(u"CM", u"Cameroon"),
(u"CA", u"Canada"),
(u"KY", u"Cayman Islands"),
(u"CF", u"Central African Republic"),
(u"TD", u"Chad"),
(u"CL", u"Chile"),
(u"CN", u"China"),
(u"CX", u"Christmas Island"),
(u"CC", u"Cocos (Keeling) Islands"),
(u"CO", u"Colombia"),
(u"KM", u"Comoros"),
(u"CG", u"Congo"),
(u"CD", u"Congo (the Democratic Republic of the)"),
(u"CK", u"Cook Islands"),
(u"CR", u"Costa Rica"),
(u"CI", u"Côte d'Ivoire"),
(u"HR", u"Croatia"),
(u"CU", u"Cuba"),
(u"CW", u"Curaçao"),
(u"CY", u"Cyprus"),
(u"CZ", u"Czech Republic"),
(u"DK", u"Denmark"),
(u"DJ", u"Djibouti"),
(u"DM", u"Dominica"),
(u"DO", u"Dominican Republic"),
(u"EC", u"Ecuador"),
(u"EG", u"Egypt"),
(u"SV", u"El Salvador"),
(u"GQ", u"Equatorial Guinea"),
(u"ER", u"Eritrea"),
(u"EE", u"Estonia"),
(u"ET", u"Ethiopia"),
(u"FK", u"Falkland Islands [Malvinas]"),
(u"FO", u"Faroe Islands"),
(u"FJ", u"Fiji"),
(u"FI", u"Finland"),
(u"FR", u"France"),
(u"GF", u"French Guiana"),
(u"PF", u"French Polynesia"),
(u"TF", u"French Southern Territories"),
(u"GA", u"Gabon"),
(u"GM", u"Gambia"),
(u"GE", u"Georgia"),
(u"DE", u"Germany"),
(u"GH", u"Ghana"),
(u"GI", u"Gibraltar"),
(u"GR", u"Greece"),
(u"GL", u"Greenland"),
(u"GD", u"Grenada"),
(u"GP", u"Guadeloupe"),
(u"GU", u"Guam"),
(u"GT", u"Guatemala"),
(u"GG", u"Guernsey"),
(u"GN", u"Guinea"),
(u"GW", u"Guinea-Bissau"),
(u"GY", u"Guyana"),
(u"HT", u"Haiti"),
(u"HM", u"Heard Island and McDonald Islands"),
(u"VA", u"Holy See"),
(u"HN", u"Honduras"),
(u"HK", u"Hong Kong"),
(u"HU", u"Hungary"),
(u"IS", u"Iceland"),
(u"IN", u"India"),
(u"ID", u"Indonesia"),
(u"IR", u"Iran"),
(u"IQ", u"Iraq"),
(u"IE", u"Ireland"),
(u"IM", u"Isle of Man"),
(u"IL", u"Israel"),
(u"IT", u"Italy"),
(u"JM", u"Jamaica"),
(u"JP", u"Japan"),
(u"JE", u"Jersey"),
(u"JO", u"Jordan"),
(u"KZ", u"Kazakhstan"),
(u"KE", u"Kenya"),
(u"KI", u"Kiribati"),
(u"KW", u"Kuwait"),
(u"KG", u"Kyrgyzstan"),
(u"LA", u"Laos"),
(u"LV", u"Latvia"),
(u"LB", u"Lebanon"),
(u"LS", u"Lesotho"),
(u"LR", u"Liberia"),
(u"LY", u"Libya"),
(u"LI", u"Liechtenstein"),
(u"LT", u"Lithuania"),
(u"LU", u"Luxembourg"),
(u"MO", u"Macao"),
(u"MK", u"Macedonia"),
(u"MG", u"Madagascar"),
(u"MW", u"Malawi"),
(u"MY", u"Malaysia"),
(u"MV", u"Maldives"),
(u"ML", u"Mali"),
(u"MT", u"Malta"),
(u"MH", u"Marshall Islands"),
(u"MQ", u"Martinique"),
(u"MR", u"Mauritania"),
(u"MU", u"Mauritius"),
(u"YT", u"Mayotte"),
(u"MX", u"Mexico"),
(u"FM", u"Micronesia (Federated States of)"),
(u"MD", u"Moldovia"),
(u"MC", u"Monaco"),
(u"MN", u"Mongolia"),
(u"ME", u"Montenegro"),
(u"MS", u"Montserrat"),
(u"MA", u"Morocco"),
(u"MZ", u"Mozambique"),
(u"MM", u"Myanmar"),
(u"NA", u"Namibia"),
(u"NR", u"Nauru"),
(u"NP", u"Nepal"),
(u"NL", u"Netherlands"),
(u"NC", u"New Caledonia"),
(u"NZ", u"New Zealand"),
(u"NI", u"Nicaragua"),
(u"NE", u"Niger"),
(u"NG", u"Nigeria"),
(u"NU", u"Niue"),
(u"NF", u"Norfolk Island"),
(u"KP", u"North Korea"),
(u"MP", u"Northern Mariana Islands"),
(u"NO", u"Norway"),
(u"OM", u"Oman"),
(u"PK", u"Pakistan"),
(u"PW", u"Palau"),
(u"PS", u"Palestine, State of"),
(u"PA", u"Panama"),
(u"PG", u"Papua New Guinea"),
(u"PY", u"Paraguay"),
(u"PE", u"Peru"),
(u"PH", u"Philippines"),
(u"PN", u"Pitcairn"),
(u"PL", u"Poland"),
(u"PT", u"Portugal"),
(u"PR", u"Puerto Rico"),
(u"QA", u"Qatar"),
(u"RE", u"Réunion"),
(u"RO", u"Romania"),
(u"RU", u"Russia"),
(u"RW", u"Rwanda"),
(u"BL", u"Saint Barthélemy"),
(u"SH", u"Saint Helena, Ascension and Tristan da Cunha"),
(u"KN", u"Saint Kitts and Nevis"),
(u"LC", u"Saint Lucia"),
(u"MF", u"Saint Martin (French part)"),
(u"PM", u"Saint Pierre and Miquelon"),
(u"VC", u"Saint Vincent and the Grenadines"),
(u"WS", u"Samoa"),
(u"SM", u"San Marino"),
(u"ST", u"Sao Tome and Principe"),
(u"SA", u"Saudi Arabia"),
(u"SN", u"Senegal"),
(u"RS", u"Serbia"),
(u"SC", u"Seychelles"),
(u"SL", u"Sierra Leone"),
(u"SG", u"Singapore"),
(u"SX", u"Sint Maarten (Dutch part)"),
(u"SK", u"Slovakia"),
(u"SI", u"Slovenia"),
(u"SB", u"Solomon Islands"),
(u"SO", u"Somalia"),
(u"ZA", u"South Africa"),
(u"GS", u"South Georgia and the South Sandwich Islands"),
(u"KR", u"South Korea"),
(u"SS", u"South Sudan"),
(u"ES", u"Spain"),
(u"LK", u"Sri Lanka"),
(u"SD", u"Sudan"),
(u"SR", u"Suriname"),
(u"SJ", u"Svalbard and Jan Mayen"),
(u"SZ", u"Swaziland"),
(u"SE", u"Sweden"),
(u"CH", u"Switzerland"),
(u"SY", u"Syria"),
(u"TW", u"Taiwan"),
(u"TJ", u"Tajikistan"),
(u"TZ", u"Tanzania"),
(u"TH", u"Thailand"),
(u"TL", u"Timor-Leste"),
(u"TG", u"Togo"),
(u"TK", u"Tokelau"),
(u"TO", u"Tonga"),
(u"TT", u"Trinidad and Tobago"),
(u"TN", u"Tunisia"),
(u"TR", u"Turkey"),
(u"TM", u"Turkmenistan"),
(u"TC", u"Turks and Caicos Islands"),
(u"TV", u"Tuvalu"),
(u"UG", u"Uganda"),
(u"UA", u"Ukraine"),
(u"AE", u"United Arab Emirates"),
(u"GB", u"United Kingdom of Great Britain and Northern Ireland"),
(u"UM", u"United States Minor Outlying Islands"),
(u"US", u"United States of America"),
(u"UY", u"Uruguay"),
(u"UZ", u"Uzbekistan"),
(u"VU", u"Vanuatu"),
(u"VE", u"Venezuela"),
(u"VN", u"Vietnam"),
(u"VG", u"Virgin Islands (British)"),
(u"VI", u"Virgin Islands (U.S.)"),
(u"WF", u"Wallis and Futuna"),
(u"EH", u"Western Sahara"),
(u"YE", u"Yemen"),
(u"ZM", u"Zambia"),
(u"ZW", u"Zimbabwe"),
]
......@@ -581,22 +581,13 @@ class RegistrationView(APIView):
# Translators: This label appears above a dropdown menu on the registration
# form used to select the country in which the user lives.
country_label = _(u"Country")
sorted_countries = sorted(
countries.countries, key=lambda(__, name): unicode(name)
)
options = [
(country_code, unicode(country_name))
for country_code, country_name in sorted_countries
]
error_msg = _(u"Please select your Country.")
form_desc.add_field(
"country",
label=country_label,
field_type="select",
options=options,
options=list(countries),
include_default_option=True,
required=required,
error_messages={
......
......@@ -16,7 +16,7 @@ defusedxml==0.4.1
distribute>=0.6.28, <0.7
django-babel-underscore==0.1.0
django-celery==3.1.16
django-countries==2.1.2
django-countries==3.3
django-extensions==1.2.5
django-filter==0.6.0
django-followit==0.0.3
......@@ -88,6 +88,7 @@ xmltodict==0.4.1
django-ratelimit-backend==0.6
unicodecsv==0.9.4
django-require==1.0.6
pyuca==1.1
# Used for shopping cart's pdf invoice/receipt generation
reportlab==3.1.44
......
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