Repository: OCHA-DAP/hdx-ckan

Issue:
Redirect a non-new user to Newsfeed instead of My Organisations



Discussion:

Resolving patch:
diff --git a/ckanext-hdx_users/ckanext/hdx_users/controllers/login_controller.py b/ckanext-hdx_users/ckanext/hdx_users/controllers/login_controller.py
--- a/ckanext-hdx_users/ckanext/hdx_users/controllers/login_controller.py
+++ b/ckanext-hdx_users/ckanext/hdx_users/controllers/login_controller.py
@@ -10,7 +10,9 @@
 
 get_action = logic.get_action
 
+
 class LoginController(ckan_user.UserController):
+
     def logged_in(self):
         # redirect if needed
         came_from = request.params.get('came_from', '')
@@ -24,24 +26,22 @@ def logged_in(self):
             user_dict = get_action('user_show')(context, data_dict)
 
             if 'created' in user_dict:
-                time_passed = datetime.datetime.now() - dateutil.parser.parse( user_dict['created'] )
+                time_passed = datetime.datetime.now(
+                ) - dateutil.parser.parse(user_dict['created'])
             else:
-                time_passed = None 
-            
+                time_passed = None
             if not user_dict['activity'] and time_passed and time_passed.days < 3:
-                #/dataset/new 
-                contribute_url  = h.url_for(controller='package', action='new')
-                # message = ''' Now that you've registered an account , you can <a href="%s">start adding datasets</a>. 
-                #    If you want to associate this dataset with an organization, either click on "My Organizations" below 
+                #/dataset/new
+                contribute_url = h.url_for(controller='package', action='new')
+                # message = ''' Now that you've registered an account , you can <a href="%s">start adding datasets</a>.
+                #    If you want to associate this dataset with an organization, either click on "My Organizations" below
                 #    to create a new organization or ask the admin of an existing organization to add you as a member.''' % contribute_url
                 #h.flash_success(_(message), True)
+                return h.redirect_to(controller='user', action='dashboard_organizations')
             else:
                 h.flash_success(_("%s is now logged in") %
-                            user_dict['display_name'])
-            #return self.me()
-            # Instead redirect to My orgs page
-            return h.redirect_to(controller='user',
-                              action='dashboard_organizations')
+                                user_dict['display_name'])
+                return self.me()
         else:
             err = _('Login failed. Bad username or password.')
             if g.openid_enabled:
@@ -53,8 +53,8 @@ def logged_in(self):
                               action='login', came_from=came_from)
             else:
                 return self.login(error=err)
-    
+
     def contribute(self, error=None):
         self.login(error)
-        vars = {'contribute':True}
-        return base.render('user/login.html', extra_vars=vars)
\ No newline at end of file
+        vars = {'contribute': True}
+        return base.render('user/login.html', extra_vars=vars)


Test patch: