Opened 8 years ago

Last modified 4 years ago

#6839 assigned enhancement

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

Reported by: lkraav Owned by: Ryan J Ollos
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 Mario 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by Mario

Attachment: macro.patch added

comment:1 Changed 7 years ago by Mario


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

have fun

comment:2 Changed 7 years ago by Mario

Trac Release: 0.110.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 4 years ago by Ryan J Ollos

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

Modify Ticket

Change Properties
Set your email in Preferences
as assigned The owner will remain Ryan J Ollos.

Add Comment

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

Note: See TracTickets for help on using tickets.