Add all required fields to the Account Creation page
Currently users are asked for the following fields when creating an account:

- first name
- last name
- username
- email
- organization

The following required fields are not included:
- user type
- country
- state/province

These three fields should be included in the Account Creation form.

This ticket breaks out the account creation implementation outlined in #3812  
diff --git a/hs_core/hydroshare/users.py b/hs_core/hydroshare/users.py
index 2c8ece586..796576a14 100755
--- a/hs_core/hydroshare/users.py
+++ b/hs_core/hydroshare/users.py
@@ -25,7 +25,7 @@ log = logging.getLogger(__name__)
 
 def create_account(
         email, username=None, first_name=None, last_name=None, superuser=None, groups=None,
-        password=None, active=True, organization=None, middle_name=None):
+        password=None, active=True, organization=None, middle_name=None, user_type=None, country=None, state=None):
     """
     Create a new user within the HydroShare system.
 
@@ -101,6 +101,17 @@ def create_account(
         user_profile.middle_name = middle_name
         user_profile.save()
 
+    if user_type:
+        user_profile.user_type = user_type
+        user_profile.save()
+
+    if country:
+        user_profile.country = country
+        user_profile.save()
+
+    if state:
+        user_profile.state = state
+        user_profile.save()
     # create default UserQuota object for the new user
     uq = UserQuota.objects.create(user=u)
     uq.save()
diff --git a/hs_core/tests/api/native/test_create_account.py b/hs_core/tests/api/native/test_create_account.py
index 8d2f807f0..6a5e08686 100755
--- a/hs_core/tests/api/native/test_create_account.py
+++ b/hs_core/tests/api/native/test_create_account.py
@@ -115,6 +115,26 @@ class CreateAccountTest(TestCase):
         for term in terms:
             self.assertTrue(term.name in organizations)
 
+    def test_with_usertype_country_state(self):
+        username = 'testuser'
+        usertype = 'University Faculty'
+        country = 'United States'
+        state = 'NC'
+        hydroshare.create_account(
+            'testuser@gmail.com',
+            username=username,
+            first_name='Test',
+            last_name='User',
+            organization='TestOrg',
+            user_type=usertype,
+            country=country,
+            state=state
+        )
+        user = UserProfile.objects.filter(user__username=username).first()
+        self.assertEqual(user.user_type, usertype)
+        self.assertEqual(user.country, country)
+        self.assertEqual(user.state, state)
+
     def test_case_in_username(self):
         username, first_name, last_name, password = 'shaunjl', 'shaun','joseph','mypass'
         user = hydroshare.create_account(
diff --git a/theme/forms.py b/theme/forms.py
index 9233410ab..b69349eef 100644
--- a/theme/forms.py
+++ b/theme/forms.py
@@ -231,6 +231,9 @@ class SignupForm(forms.ModelForm):
     password1 = forms.CharField(label="Password", widget=forms.PasswordInput())
     password2 = forms.CharField(label="Confirm Password", widget=forms.PasswordInput())
     organization = forms.CharField(required=True)
+    user_type = forms.CharField(required=True)
+    country = forms.CharField(label='Country', required=True)
+    state = forms.CharField(label='State/Province', required=True)
 
     def __init__(self, request, *args, **kwargs):
         self.request = request
@@ -263,6 +266,24 @@ class SignupForm(forms.ModelForm):
         else:
             raise forms.ValidationError("Password must be confirmed")
 
+    def clean_user_type(self):
+        data = self.cleaned_data['user_type']
+        if len(data.strip()) == 0:
+            raise forms.ValidationError("User type is a required field.")
+        return data
+
+    def clean_country(self):
+        data = self.cleaned_data['country']
+        if len(data.strip()) == 0:
+            raise forms.ValidationError("Country is a required field.")
+        return data
+
+    def clean_state(self):
+        data = self.cleaned_data['state']
+        if len(data.strip()) == 0:
+            raise forms.ValidationError("State is a required field.")
+        return data
+
     def save(self, *args, **kwargs):
         data = self.cleaned_data
         return create_account(
@@ -273,6 +294,9 @@ class SignupForm(forms.ModelForm):
             last_name=data['last_name'],
             superuser=False,
             password=data['password'],
+            user_type=data['user_type'],
+            country=data['country'],
+            state=data['state'],
             active=False,
         )
 
diff --git a/theme/static/js/profile.js b/theme/static/js/profile.js
index 18e41ae9f..591a1f996 100755
--- a/theme/static/js/profile.js
+++ b/theme/static/js/profile.js
@@ -245,11 +245,6 @@ function getUrlVars()
 }
 
 $(document).ready(function () {
-    // Change country first empty option to 'Unspecified'
-    var option = $("select[name='country'] option:first-child");
-    option.val("Unspecified");
-    option.text("Unspecified");
-
     $("#btn-create-irods-account").click(create_irods_account);
     $("#btn-delete-irods-account").click(delete_irods_account);
 
diff --git a/theme/templates/accounts/profile.html b/theme/templates/accounts/profile.html
index f15851541..78e74cdf2 100755
--- a/theme/templates/accounts/profile.html
+++ b/theme/templates/accounts/profile.html
@@ -386,7 +386,6 @@
                                             <fieldset>
                                                 <label for="selectUserType">User type *</label>
                                                 <select name="user_type" class="form-control form-required" id="selectUserType">
-                                                    <option value="Unspecified">Unspecified</option>
                                                     <option value="University Faculty">University Faculty</option>
                                                     <option value="University Professional or Research Staff">University Professional or Research Staff</option>
                                                     <option value="Post-Doctoral Fellow">Post-Doctoral Fellow</option>
@@ -415,7 +414,7 @@
                                             {#        State       #}
                                             <fieldset>
                                                 <label>State/Province *</label>
-                                                <input name="state" class="form-control form-required" {% if  profile.state %}value="{{ profile.state }}"{% else %}value="Unspecified"{% endif %}>
+                                                <input name="state" class="form-control form-required" {% if  profile.state and profile.state != 'None' %} value="{{ profile.state }}" {% endif %}>
                                             </fieldset>
 
                                             {#        Date Joined       #}
diff --git a/theme/templates/accounts/sign_up_form.html b/theme/templates/accounts/sign_up_form.html
index 8699177f1..d7600cc87 100644
--- a/theme/templates/accounts/sign_up_form.html
+++ b/theme/templates/accounts/sign_up_form.html
@@ -44,6 +44,41 @@
         <div class="form-group">
             {% include "includes/form_field.html" with field=form.password2 inline_label=True %}
         </div>
+        <div class="form-group">
+          <fieldset>
+            <small class="text-muted">Specify user type *</small>
+            <select name="user_type" class="form-control form-required" id="selectUserType">
+                <option value=""></option>
+                <option value="University Faculty">University Faculty</option>
+                <option value="University Professional or Research Staff">University Professional or Research Staff</option>
+                <option value="Post-Doctoral Fellow">Post-Doctoral Fellow</option>
+                <option value="University Graduate Student">University Graduate Student</option>
+                <option value="University Undergraduate Student">University Undergraduate Student</option>
+                <option value="Commercial/Professional">Commercial/Professional</option>
+                <option value="Government Official">Government Official</option>
+                <option value="School Student Kindergarten to 12th Grade">School Student Kindergarten to 12th Grade</option>
+                <option value="School Teacher Kindergarten to 12th Grade">School Teacher Kindergarten to 12th Grade</option>
+                <option value="Other">Other</option>
+            </select>
+          </fieldset>
+
+          {#        User Type - Other       #}
+          <fieldset id="user-type-other">
+              <small class="text-muted">Specify other user type: *</small>
+              <input name="user_type" class="form-control">
+          </fieldset>
+
+          {#        Country       #}
+          <fieldset>
+              <small class="text-muted">Country *</small>
+              <select id="id_country" name="country" class="form-control form-required input-medium bfh-countries" data-country=""></select>
+          </fieldset>
+
+          {#        State       #}
+          <div class="form-group">
+            <input id="id_state" class="form-control form-required" name="state" placeholder="State/Province *">
+          </div>
+        </div>
     </div>
     <div class="row">
       <script src='https://www.google.com/recaptcha/api.js'></script>
@@ -54,9 +89,25 @@
 </form>
 
 <script type="text/javascript" src="{{ STATIC_URL }}js/jquery.tagsinput-revisited.min.js"></script>
+<script type="text/javascript" src="{{ STATIC_URL }}js/bootstrap-formhelpers.js"></script>
 <script type="text/javascript">
     $(document).ready(function() {
          $('input[type="button"]').prop('disabled', false);
+         $("#selectUserType").change(function () {
+             var inputOther = $("#user-type-other input");
+             if ($(this).val() == "Other") {
+                 $("#user-type-other").show();
+                 $("#selectUserType").removeAttr("name");
+                 inputOther.attr("name", "user_type");
+                 inputOther.addClass("form-required");
+             }
+             else {
+                 $("#user-type-other").hide();
+                 inputOther.removeAttr("name");
+                 inputOther.removeClass("form-required");
+                 $("#selectUserType").attr("name", "user_type");
+             }
+         });
          // remove the content of the 'missing-data-div' upon data editing in any of the
         // form fields
          var fieldsToCheck = ["#id_first_name", "#id_last_name", "#id_username", "#id_email",
@@ -97,12 +148,24 @@
             var pwconfirm = $("#id_password2").val();
             // These are the required form fields
             var requiredFieldsToCheck = ["#id_username", "#id_email", "#id_password1",
-                "#id_password2",  "[name='organization']"];
-            var fieldNames = [ 'User name', 'Email', 'Password', 'Password (again)', "Organization"];
+                "#id_password2",  "[name='organization']", "#id_country", "#id_state"];
+            var fieldNames = [ 'User name', 'Email', 'Password', 'Password (again)', "Organization",
+                "Country", "State/Province"];
             var empty = false;
             var missingFields = 'Data missing for:';
             var missingFieldCount = 0;
             var j;
+            if($("#selectUserType").val() == 'Other' && $("#user-type-other  input").val() == '') {
+                empty = true;
+                missingFields += " " + 'User type Other';
+                missingFieldCount++;
+            }
+            else if ($("#selectUserType").val() == '') {
+                empty = true;
+                missingFields += " " + 'User type';
+                missingFieldCount++;
+            }
+
             for(j=0; j< requiredFieldsToCheck.length; j++) {
                 if ($(requiredFieldsToCheck[j]).val() == '') {
                     empty = true;
@@ -115,6 +178,7 @@
                     missingFieldCount++;
                 }
            }
+
            // validate username to make sure username not only passes django username validation
            // but also passed iRODS username validation
            var username_valid = validateUserName();
['hs_core/tests/api/native/test_create_account.py', 'theme/templates/accounts/profile.html', 'theme/templates/accounts/sign_up_form.html', 'theme/forms.py', 'hs_core/hydroshare/users.py', 'theme/static/js/profile.js']