Opened 4 years ago

Last modified 7 months ago

#6839 assigned enhancement

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

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


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 mwehr 4 years ago.

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by mwehr

comment:1 Changed 4 years ago by mwehr


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

have fun

comment:2 Changed 4 years ago by mwehr

  • Trac Release changed from 0.11 to 0.12


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

---	(revision 301)
+++	(revision 302)
@@ -10,7 +10,8 @@
 from import WikiMacroBase
 from import wiki_to_html
 from 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 =  -
+              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")
@@ -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 7 months ago by rjollos

  • Owner changed from cbalan to rjollos
  • Status changed from new to assigned

Add Comment

Modify Ticket

as assigned .

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

Note: See TracTickets for help on using tickets.