From 8af94ec72a1c400bb43e454667a7cab91f449f28 Mon Sep 17 00:00:00 2001
From: Ahtisham Shahid <ahtisham300@gmail.com>
Date: Fri, 17 Apr 2020 14:17:34 +0500
Subject: [PATCH] Disabled copy/paste in confirm email

Created sorting for email field

updated tests

Fixed sorting issue in registration form

Fixed sorting issue in registration form

Fixed sorting issue in registration form

Added missing items in env and updated order logic

Added missing items in env and updated order logic
---
 lms/envs/common.py                                         | 2 ++
 lms/static/js/student_account/views/RegisterView.js        | 3 +++
 .../core/djangoapps/user_authn/views/registration_form.py  | 7 ++++---
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/lms/envs/common.py b/lms/envs/common.py
index 86fafd70d7b..4cfa792cdd6 100644
--- a/lms/envs/common.py
+++ b/lms/envs/common.py
@@ -2815,6 +2815,8 @@ REGISTRATION_FIELD_ORDER = [
     "gender",
     "year_of_birth",
     "level_of_education",
+    "specialty",
+    "profession"
     "company",
     "title",
     "mailing_address",
diff --git a/lms/static/js/student_account/views/RegisterView.js b/lms/static/js/student_account/views/RegisterView.js
index c0ae569e8f0..7bd7e5aef39 100644
--- a/lms/static/js/student_account/views/RegisterView.js
+++ b/lms/static/js/student_account/views/RegisterView.js
@@ -274,6 +274,9 @@
                             handleInputBehavior($input);
                         }
                     });
+                    $('#register-confirm_email').bind('cut copy paste', function(e) {
+                        e.preventDefault();
+                    });
                     setTimeout(handleAutocomplete, 1000);
                 },
 
diff --git a/openedx/core/djangoapps/user_authn/views/registration_form.py b/openedx/core/djangoapps/user_authn/views/registration_form.py
index 6c29b4756d3..4ce0a8917c2 100644
--- a/openedx/core/djangoapps/user_authn/views/registration_form.py
+++ b/openedx/core/djangoapps/user_authn/views/registration_form.py
@@ -350,10 +350,11 @@ class RegistrationFormFactory(object):
         field_order = configuration_helpers.get_value('REGISTRATION_FIELD_ORDER')
         if not field_order:
             field_order = settings.REGISTRATION_FIELD_ORDER or valid_fields
-
-        # Check that all of the valid_fields are in the field order and vice versa, if not set to the default order
+        # Check that all of the valid_fields are in the field order and vice versa,
+        # if not append missing fields at end of field order
         if set(valid_fields) != set(field_order):
-            field_order = valid_fields
+            difference = set(valid_fields).difference(set(field_order))
+            field_order.extend(difference)
 
         self.field_order = field_order
 
-- 
GitLab