# HG changeset patch # User Marcin Kuzminski # Date 2017-03-15 11:51:59 # Node ID b45c2eaa3b1a3dee45c362fe2890da9ec75c7582 # Parent e40bd0a79de4701116e4b9a8f841d35fa47c6248 users: change last activity to re-use new column. diff --git a/rhodecode/apps/admin/views/users.py b/rhodecode/apps/admin/views/users.py --- a/rhodecode/apps/admin/views/users.py +++ b/rhodecode/apps/admin/views/users.py @@ -137,8 +137,7 @@ class AdminUsersView(BaseAppView): "first_name": h.escape(user.name), "last_name": h.escape(user.lastname), "last_login": h.format_date(user.last_login), - "last_activity": h.format_date( - h.time_to_datetime(user.user_data.get('last_activity', 0))), + "last_activity": h.format_date(user.last_activity), "active": h.bool2icon(user.active), "active_raw": user.active, "admin": h.bool2icon(user.admin), diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -846,12 +846,9 @@ class User(Base, BaseModel): def update_lastactivity(self): """Update user lastactivity""" - usr = self - old = usr.user_data - old.update({'last_activity': time.time()}) - usr.user_data = old - Session().add(usr) - log.debug('updated user %s lastactivity', usr.username) + self.last_activity = datetime.datetime.now() + Session().add(self) + log.debug('updated user %s lastactivity', self.username) def update_password(self, new_password): from rhodecode.lib.auth import get_crypt_password diff --git a/rhodecode/templates/admin/users/user_edit_advanced.mako b/rhodecode/templates/admin/users/user_edit_advanced.mako --- a/rhodecode/templates/admin/users/user_edit_advanced.mako +++ b/rhodecode/templates/admin/users/user_edit_advanced.mako @@ -6,7 +6,7 @@ (_('Source of Record'), c.user.extern_type, '', ''), (_('Last login'), c.user.last_login or '-', '', ''), - (_('Last activity'), h.format_date(h.time_to_datetime(c.user.user_data.get('last_activity', 0))), '', ''), + (_('Last activity'), c.user.last_activity, '', ''), (_('Repositories'), len(c.user.repositories), '', [x.repo_name for x in c.user.repositories]), (_('Repository groups'), len(c.user.repository_groups), '', [x.group_name for x in c.user.repository_groups]),