Commit cae5623f by muzaffaryousaf

Updating the django-countries version to support sorting.

Adding the pyuca to support sorting in differnet languages.

TNL-2047
parent 378cf9bb
......@@ -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):
......
......@@ -3,7 +3,6 @@
import logging
import json
from ipware.ip import get_ip
import pyuca
from django.conf import settings
from django.contrib import messages
......@@ -339,16 +338,6 @@ def account_settings_context(request):
"""
user = request.user
collator = pyuca.Collator()
sort_key = lambda item: collator.sort_key(unicode(item[1]))
country_options = [
(country_code, _(country_name)) # pylint: disable=translation-of-non-string
for country_code, country_name in sorted(
countries.countries, key=sort_key
)
]
year_of_birth_options = [(unicode(year), unicode(year)) for year in UserProfile.VALID_YEARS]
context = {
......@@ -356,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': {
......
""" Views for a student's profile information. """
import pyuca
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django_countries import countries
......@@ -67,15 +65,6 @@ def learner_profile_context(logged_in_user, profile_username, user_is_staff, bui
"""
profile_user = User.objects.get(username=profile_username)
collator = pyuca.Collator()
sort_key = lambda item: collator.sort_key(unicode(item[1]))
country_options = [
(country_code, _(country_name)) # pylint: disable=translation-of-non-string
for country_code, country_name in sorted(
countries.countries, key=sort_key
)
]
own_profile = (logged_in_user.username == profile_username)
account_settings_data = get_account_settings(logged_in_user, profile_username)
......@@ -102,7 +91,7 @@ def learner_profile_context(logged_in_user, profile_username, user_is_staff, bui
'account_settings_page_url': reverse('account_settings'),
'has_preferences_access': (logged_in_user.username == profile_username or user_is_staff),
'own_profile': own_profile,
'country_options': country_options,
'country_options': list(countries),
'language_options': settings.ALL_LANGUAGES,
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
}
......
......@@ -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>
......
......@@ -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
......
......@@ -21,8 +21,6 @@
git+https://github.com/mitocw/django-cas.git@60a5b8e5a62e63e0d5d224a87f0b489201a0c695#egg=django-cas
-e git+https://github.com/dgrtwo/ParsePy.git@7949b9f754d1445eff8e8f20d0e967b9a6420639#egg=parse_rest
git+https://github.com/mfogel/django-settings-context-processor.git@b758c3930862761216267715a70bbefd206ac03a#egg=django-settings-context-processor==0.2
git+https://github.com/SmileyChris/pyuca.git@555292b39692e2c8a13fbba02a284fb89c9940e4#egg=pyuca==1.0
# Master pyfs has a bug working with VPC auth. This is a fix. We should switch
# back to master when and if this fix is merged back.
# fs==0.4.0
......
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