Modify ↓
Opened 15 years ago
Last modified 5 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)
Change History (5)
Changed 14 years ago by
Attachment: | macro.patch added |
---|
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
Trac Release: | 0.11 → 0.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 11 years ago by
Owner: | changed from Catalin BALAN to Ryan J Ollos |
---|---|
Status: | new → assigned |
comment:4 Changed 5 years ago by
Owner: | Ryan J Ollos deleted |
---|---|
Status: | assigned → new |
Note: See
TracTickets for help on using
tickets.
Hi,
I added a "last visit" section to the !userProfileList macro. see attached macro.patch for details.
have fun