prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Redirect a non-new user to Newsfeed instead of My Organisations
  
  
  </issue>
  <code>
  [start of ckanext-hdx_users/ckanext/hdx_users/controllers/login_controller.py]
  1 import datetime
  2 import dateutil
  3 
  4 import ckan.controllers.user as ckan_user
  5 import ckan.lib.helpers as h
  6 import ckan.lib.base as base
  7 from ckan.common import _, c, g, request
  8 import ckan.logic as logic
  9 from pylons import config
  10 
  11 get_action = logic.get_action
  12 
  13 class LoginController(ckan_user.UserController):
  14     def logged_in(self):
  15         # redirect if needed
  16         came_from = request.params.get('came_from', '')
  17         if self._sane_came_from(came_from):
  18             return h.redirect_to(str(came_from))
  19 
  20         if c.user:
  21             context = None
  22             data_dict = {'id': c.user}
  23 
  24             user_dict = get_action('user_show')(context, data_dict)
  25 
  26             if 'created' in user_dict:
  27                 time_passed = datetime.datetime.now() - dateutil.parser.parse( user_dict['created'] )
  28             else:
  29                 time_passed = None 
  30             
  31             if not user_dict['activity'] and time_passed and time_passed.days < 3:
  32                 #/dataset/new 
  33                 contribute_url  = h.url_for(controller='package', action='new')
  34                 # message = ''' Now that you've registered an account , you can <a href="%s">start adding datasets</a>. 
  35                 #    If you want to associate this dataset with an organization, either click on "My Organizations" below 
  36                 #    to create a new organization or ask the admin of an existing organization to add you as a member.''' % contribute_url
  37                 #h.flash_success(_(message), True)
  38             else:
  39                 h.flash_success(_("%s is now logged in") %
  40                             user_dict['display_name'])
  41             #return self.me()
  42             # Instead redirect to My orgs page
  43             return h.redirect_to(controller='user',
  44                               action='dashboard_organizations')
  45         else:
  46             err = _('Login failed. Bad username or password.')
  47             if g.openid_enabled:
  48                 err += _(' (Or if using OpenID, it hasn\'t been associated '
  49                          'with a user account.)')
  50             if h.asbool(config.get('ckan.legacy_templates', 'false')):
  51                 h.flash_error(err)
  52                 h.redirect_to(controller='user',
  53                               action='login', came_from=came_from)
  54             else:
  55                 return self.login(error=err)
  56     
  57     def contribute(self, error=None):
  58         self.login(error)
  59         vars = {'contribute':True}
  60         return base.render('user/login.html', extra_vars=vars)
  [end of ckanext-hdx_users/ckanext/hdx_users/controllers/login_controller.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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 @@
               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 @@
                                 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)
  
verification_info: {"golden_diff": "diff --git a/ckanext-hdx_users/ckanext/hdx_users/controllers/login_controller.py b/ckanext-hdx_users/ckanext/hdx_users/controllers/login_controller.py\n--- a/ckanext-hdx_users/ckanext/hdx_users/controllers/login_controller.py\n+++ b/ckanext-hdx_users/ckanext/hdx_users/controllers/login_controller.py\n@@ -10,7 +10,9 @@\n \n get_action = logic.get_action\n \n+\n class LoginController(ckan_user.UserController):\n+\n     def logged_in(self):\n         # redirect if needed\n         came_from = request.params.get('came_from', '')\n@@ -24,24 +26,22 @@\n             user_dict = get_action('user_show')(context, data_dict)\n \n             if 'created' in user_dict:\n-                time_passed = datetime.datetime.now() - dateutil.parser.parse( user_dict['created'] )\n+                time_passed = datetime.datetime.now(\n+                ) - dateutil.parser.parse(user_dict['created'])\n             else:\n-                time_passed = None \n-            \n+                time_passed = None\n             if not user_dict['activity'] and time_passed and time_passed.days < 3:\n-                #/dataset/new \n-                contribute_url  = h.url_for(controller='package', action='new')\n-                # message = ''' Now that you've registered an account , you can <a href=\"%s\">start adding datasets</a>. \n-                #    If you want to associate this dataset with an organization, either click on \"My Organizations\" below \n+                #/dataset/new\n+                contribute_url = h.url_for(controller='package', action='new')\n+                # message = ''' Now that you've registered an account , you can <a href=\"%s\">start adding datasets</a>.\n+                #    If you want to associate this dataset with an organization, either click on \"My Organizations\" below\n                 #    to create a new organization or ask the admin of an existing organization to add you as a member.''' % contribute_url\n                 #h.flash_success(_(message), True)\n+                return h.redirect_to(controller='user', action='dashboard_organizations')\n             else:\n                 h.flash_success(_(\"%s is now logged in\") %\n-                            user_dict['display_name'])\n-            #return self.me()\n-            # Instead redirect to My orgs page\n-            return h.redirect_to(controller='user',\n-                              action='dashboard_organizations')\n+                                user_dict['display_name'])\n+                return self.me()\n         else:\n             err = _('Login failed. Bad username or password.')\n             if g.openid_enabled:\n@@ -53,8 +53,8 @@\n                               action='login', came_from=came_from)\n             else:\n                 return self.login(error=err)\n-    \n+\n     def contribute(self, error=None):\n         self.login(error)\n-        vars = {'contribute':True}\n-        return base.render('user/login.html', extra_vars=vars)\n\\ No newline at end of file\n+        vars = {'contribute': True}\n+        return base.render('user/login.html', extra_vars=vars)\n", "issue": "Redirect a non-new user to Newsfeed instead of My Organisations\n\n", "before_files": [{"content": "import datetime\nimport dateutil\n\nimport ckan.controllers.user as ckan_user\nimport ckan.lib.helpers as h\nimport ckan.lib.base as base\nfrom ckan.common import _, c, g, request\nimport ckan.logic as logic\nfrom pylons import config\n\nget_action = logic.get_action\n\nclass LoginController(ckan_user.UserController):\n    def logged_in(self):\n        # redirect if needed\n        came_from = request.params.get('came_from', '')\n        if self._sane_came_from(came_from):\n            return h.redirect_to(str(came_from))\n\n        if c.user:\n            context = None\n            data_dict = {'id': c.user}\n\n            user_dict = get_action('user_show')(context, data_dict)\n\n            if 'created' in user_dict:\n                time_passed = datetime.datetime.now() - dateutil.parser.parse( user_dict['created'] )\n            else:\n                time_passed = None \n            \n            if not user_dict['activity'] and time_passed and time_passed.days < 3:\n                #/dataset/new \n                contribute_url  = h.url_for(controller='package', action='new')\n                # message = ''' Now that you've registered an account , you can <a href=\"%s\">start adding datasets</a>. \n                #    If you want to associate this dataset with an organization, either click on \"My Organizations\" below \n                #    to create a new organization or ask the admin of an existing organization to add you as a member.''' % contribute_url\n                #h.flash_success(_(message), True)\n            else:\n                h.flash_success(_(\"%s is now logged in\") %\n                            user_dict['display_name'])\n            #return self.me()\n            # Instead redirect to My orgs page\n            return h.redirect_to(controller='user',\n                              action='dashboard_organizations')\n        else:\n            err = _('Login failed. Bad username or password.')\n            if g.openid_enabled:\n                err += _(' (Or if using OpenID, it hasn\\'t been associated '\n                         'with a user account.)')\n            if h.asbool(config.get('ckan.legacy_templates', 'false')):\n                h.flash_error(err)\n                h.redirect_to(controller='user',\n                              action='login', came_from=came_from)\n            else:\n                return self.login(error=err)\n    \n    def contribute(self, error=None):\n        self.login(error)\n        vars = {'contribute':True}\n        return base.render('user/login.html', extra_vars=vars)", "path": "ckanext-hdx_users/ckanext/hdx_users/controllers/login_controller.py"}]}