|
3 | 3 | """
|
4 | 4 |
|
5 | 5 | import copy
|
6 |
| -from importlib import import_module |
7 |
| -from eventtracking import tracker |
8 | 6 | import re
|
| 7 | +from importlib import import_module |
9 | 8 |
|
10 | 9 | from django import forms
|
11 | 10 | from django.conf import settings
|
|
16 | 15 | from django.urls import reverse
|
17 | 16 | from django.utils.translation import gettext as _
|
18 | 17 | from django_countries import countries
|
| 18 | +from eventtracking import tracker |
19 | 19 |
|
20 | 20 | from common.djangoapps import third_party_auth
|
21 | 21 | from common.djangoapps.edxmako.shortcuts import marketing_link
|
| 22 | +from common.djangoapps.student.models import CourseEnrollmentAllowed, UserProfile, email_exists_or_retired |
| 23 | +from common.djangoapps.util.password_policy_validators import ( |
| 24 | + password_validators_instruction_texts, |
| 25 | + password_validators_restrictions, |
| 26 | + validate_password |
| 27 | +) |
| 28 | +from openedx.core.djangoapps.embargo.models import GlobalRestrictedCountry |
22 | 29 | from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
23 | 30 | from openedx.core.djangoapps.user_api import accounts
|
24 | 31 | from openedx.core.djangoapps.user_api.helpers import FormDescription
|
25 |
| -from openedx.core.djangoapps.user_authn.utils import check_pwned_password, is_registration_api_v1 as is_api_v1 |
| 32 | +from openedx.core.djangoapps.user_authn.utils import check_pwned_password |
| 33 | +from openedx.core.djangoapps.user_authn.utils import is_registration_api_v1 as is_api_v1 |
26 | 34 | from openedx.core.djangoapps.user_authn.views.utils import remove_disabled_country_from_list
|
27 | 35 | from openedx.core.djangolib.markup import HTML, Text
|
28 | 36 | from openedx.features.enterprise_support.api import enterprise_customer_for_request
|
29 |
| -from common.djangoapps.student.models import ( |
30 |
| - CourseEnrollmentAllowed, |
31 |
| - UserProfile, |
32 |
| - email_exists_or_retired, |
33 |
| -) |
34 |
| -from common.djangoapps.util.password_policy_validators import ( |
35 |
| - password_validators_instruction_texts, |
36 |
| - password_validators_restrictions, |
37 |
| - validate_password, |
38 |
| -) |
39 | 37 |
|
40 | 38 |
|
41 | 39 | class TrueCheckbox(widgets.CheckboxInput):
|
@@ -306,7 +304,10 @@ def clean_country(self):
|
306 | 304 | Check if the user's country is in the embargoed countries list.
|
307 | 305 | """
|
308 | 306 | country = self.cleaned_data.get("country")
|
309 |
| - if country in settings.DISABLED_COUNTRIES: |
| 307 | + if ( |
| 308 | + settings.FEATURES.get('EMBARGO', False) and |
| 309 | + country in GlobalRestrictedCountry.get_countries() |
| 310 | + ): |
310 | 311 | raise ValidationError(_("Registration from this country is not allowed due to restrictions."))
|
311 | 312 | return self.cleaned_data.get("country")
|
312 | 313 |
|
@@ -981,7 +982,6 @@ def _add_country_field(self, form_desc, required=True):
|
981 | 982 | 'country',
|
982 | 983 | default=default_country.upper()
|
983 | 984 | )
|
984 |
| - |
985 | 985 | form_desc.add_field(
|
986 | 986 | "country",
|
987 | 987 | label=country_label,
|
|
0 commit comments