Repository: OCHA-DAP/hdx-ckan

Issue:
Org Create/Edit: Even out the spacing between fields
The spacing between URL and Description looks about right.  Please make the others match.  

![image](https://cloud.githubusercontent.com/assets/1654485/5394241/2c28a928-813b-11e4-9816-70a391e2b8c4.png)



Discussion:

Resolving patch:
diff --git a/ckan/lib/authenticator.py b/ckan/lib/authenticator.py
--- a/ckan/lib/authenticator.py
+++ b/ckan/lib/authenticator.py
@@ -31,6 +31,15 @@ def authenticate(self, environ, identity):
         login = identity['login']
         user = User.by_name(login)
 
+        ## HDX HACK ##
+        if user is None:
+            users = User.by_email(login)
+            try:
+                user = users[0]
+            except:
+                user = None
+        ## END HDX HACK ##
+
         if user is None:
             log.debug('Login failed - username %r not found', login)
         elif not user.is_active():
diff --git a/ckan/logic/schema.py b/ckan/logic/schema.py
--- a/ckan/logic/schema.py
+++ b/ckan/logic/schema.py
@@ -25,6 +25,8 @@
                                    no_http,
                                    tag_not_uppercase,
                                    user_name_validator,
+                                   ## HDX HACK - ADD user_email_validator
+                                   user_email_validator,
                                    user_password_validator,
                                    user_both_passwords_entered,
                                    user_passwords_match,
@@ -395,13 +397,13 @@ def default_update_relationship_schema():
 
 
 def default_user_schema():
-
+    ## HDX HACK - ADD user_email_validator
     schema = {
         'id': [ignore_missing, unicode],
         'name': [not_empty, name_validator, user_name_validator, unicode],
         'fullname': [ignore_missing, unicode],
         'password': [user_password_validator, user_password_not_empty, ignore_missing, unicode],
-        'email': [not_empty, unicode],
+        'email': [not_empty, user_email_validator, unicode],
         'about': [ignore_missing, user_about_validator, unicode],
         'created': [ignore],
         'openid': [ignore_missing],
diff --git a/ckan/logic/validators.py b/ckan/logic/validators.py
--- a/ckan/logic/validators.py
+++ b/ckan/logic/validators.py
@@ -542,6 +542,31 @@ def user_name_validator(key, data, errors, context):
             # existing user's name to that name.
             errors[key].append(_('That login name is not available.'))
 
+## ADDED FOR HDX, HDX HACK
+def user_email_validator(key, data, errors, context):
+    model = context['model']
+    email = data[key]
+
+    from validate_email import validate_email
+    if not validate_email(email, verify=True):
+        raise Invalid(_('Email address is not valid'))
+    
+    if not isinstance(email, basestring):
+        raise Invalid(_('User names must be strings'))
+
+    users = model.User.by_email(email)
+    if users:
+         # A user with new_user_name already exists in the database.
+        user_obj_from_context = context.get('user_obj')
+        for user in users:
+            if user_obj_from_context and user_obj_from_context.id == user.id:
+             # If there's a user_obj in context with the same id as the user
+             # found in the db, then we must be doing a user_update and not
+             # updating the user name, so don't return an error.
+                return
+        errors[key].append(_('That login email is not available.'))
+
+
 def user_both_passwords_entered(key, data, errors, context):
 
     password1 = data.get(('password1',),None)


Test patch: