Modify

Opened 14 years ago

Last modified 4 years ago

#6839 new enhancement

Insert "Last logged in" column in [[UserProfilesList]]

Reported by: lkraav Owned by:
Priority: normal Component: UserManagerPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

This information is already shown in Admin panel "Session Management" section. I'd also like to see it in the macro output.

Attachments (1)

macro.patch (1.7 KB) - added by Mario 13 years ago.

Download all attachments as: .zip

Change History (5)

Changed 13 years ago by Mario

Attachment: macro.patch added

comment:1 Changed 13 years ago by Mario

Hi,

I added a "last visit" section to the !userProfileList macro. see attached macro.patch for details.

have fun

comment:2 Changed 13 years ago by Mario

Trac Release: 0.110.12

Hi,

If you want just want to show the lasf login in days,.....

--- macros.py	(revision 301)
+++ macros.py	(revision 302)
@@ -10,7 +10,8 @@
 from trac.wiki.macros import WikiMacroBase
 from trac.wiki.formatter import wiki_to_html
 from trac.web.chrome import Chrome, add_stylesheet, add_script
-from trac.util.datefmt import format_datetime
+from trac.util.datefmt import format_datetime, to_datetime
+from datetime import datetime 
 
 from tracusermanager.api import UserManager, User
 from tracusermanager.profile.api import UserProfileManager, IUserProfilesListMacroCellContributor
@@ -81,7 +82,15 @@
         for username, last_visit in cursor: 
           for user in  data['user_profiles']:
             if user.username == username:
-              user['last_visit'] = format_datetime(last_visit,"%b %e.%m.%Y %H:%M:%S")
+              date_diff = datetime.now().date()  - datetime.date(to_datetime(last_visit))
+              if date_diff.days > 1:
+                user['last_visit'] = "%d days ago" % date_diff.days
+              elif date_diff.days == 1:
+                  user['last_visit'] = "%d day ago" % date_diff.days
+              else:
+                  user['last_visit'] = "today"
+
+              #user['last_visit'] = format_datetime(last_visit,"%b %d.%m.%Y %H:%M:%S")
        
 
         data['cells']=list(self._get_cells(data['user_profiles']))
@@ -113,7 +122,7 @@
         yield ('name', _('Name'),0)
         yield ('email', _('Email'),1)
         yield ('role', _('Role'),2)
-        yield ('last_visit', _('Last visit'),3)
+        yield ('last_visit', _('Last login'),3)
     def render_userlistmacro_cell(self, cell_name, user):
         """Should render user cell""" 
         return user[cell_name]

comment:3 Changed 10 years ago by Ryan J Ollos

Owner: changed from Catalin BALAN to Ryan J Ollos
Status: newassigned

comment:4 Changed 4 years ago by Ryan J Ollos

Owner: Ryan J Ollos deleted
Status: assignednew

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.