# HG changeset patch # User Timothy Clemans # Date 1218575416 25200 # Node ID 3c0bd2f627942c2ff20ed4f0c3570e68566d579a # Parent a070453197e497471745f4cae0ca64fb9e681707 #3619 View login times diff -r a070453197e4 -r 3c0bd2f62794 sage/server/notebook/avatars.py --- a/sage/server/notebook/avatars.py Tue Aug 05 11:43:04 2008 -0700 +++ b/sage/server/notebook/avatars.py Tue Aug 12 14:10:16 2008 -0700 @@ -61,6 +61,8 @@ return defer.succeed(FailedLogin(username, failure_type = 'user')) if U.password_is(password): + if twist.notebook.conf()['record_logins']: + U.record_login() return defer.succeed(username) else: return defer.succeed(FailedLogin(username,failure_type='password')) diff -r a070453197e4 -r 3c0bd2f62794 sage/server/notebook/server_conf.py --- a/sage/server/notebook/server_conf.py Tue Aug 05 11:43:04 2008 -0700 +++ b/sage/server/notebook/server_conf.py Tue Aug 12 14:10:16 2008 -0700 @@ -15,7 +15,8 @@ 'save_interval':360, # seconds 'doc_pool_size':128, - 'email':False + 'email':False, + 'record_logins':False } class ServerConfiguration(conf.Configuration): diff -r a070453197e4 -r 3c0bd2f62794 sage/server/notebook/twist.py --- a/sage/server/notebook/twist.py Tue Aug 05 11:43:04 2008 -0700 +++ b/sage/server/notebook/twist.py Tue Aug 12 14:10:16 2008 -0700 @@ -2065,15 +2065,31 @@ self.username = username def render(self, ctx): - if user_type(self.username) != 'admin': - s = message('You must an admin to manage other users.') + if 'logins' in ctx.args: + s = '
'.join(map(str, notebook.user(ctx.args['logins'][0]).login_times())) else: - s = """ - Users | Sage Notebook - - %s - - """ % '
'.join(['%s' % (i, i) for i in notebook.valid_login_names()]) + if user_type(self.username) != 'admin': + s = message('You must an admin to manage other users.') + else: + logins_th = 'Login times' if notebook.conf()['record_logins'] else '' + if notebook.conf()['record_logins']: + rows = '
'.join(['%sAccessAccess' % (i, i, i) for i in notebook.valid_login_names()]) + else: + rows = '
'.join(['%sAccess' % (i, i) for i in notebook.valid_login_names()]) + s = """ + User Management | Sage Notebook + + + + + %s + %s +
UsersWorksheets
+ + """ % (logins_th, rows) return http.Response(stream = s) class InvalidPage(resource.Resource): diff -r a070453197e4 -r 3c0bd2f62794 sage/server/notebook/user.py --- a/sage/server/notebook/user.py Tue Aug 05 11:43:04 2008 -0700 +++ b/sage/server/notebook/user.py Tue Aug 12 14:10:16 2008 -0700 @@ -21,6 +21,7 @@ raise ValueError, "account type must be one of admin, user, or guest" self.__account_type = account_type self.__conf = user_conf.UserConfiguration() + self.__login_times = None def __getstate__(self): d = copy.copy(self.__dict__) @@ -242,3 +243,21 @@ False """ return self.__account_type == 'guest' + + def record_login(self): + """ + """ + import datetime + try: + self.__login_times.append(datetime.today()) + except AttributeError: + self.__login_times = [datetime.datetime.today()] + + def login_times(self): + """ + """ + try: + return self.__login_times + except AttributeError: + self.__login_times = [] + return []