diff --git a/app/helpers/admin/users_helper.rb b/app/helpers/admin/users_helper.rb new file mode 100644 index 000000000..3876346fe --- /dev/null +++ b/app/helpers/admin/users_helper.rb @@ -0,0 +1,25 @@ +module Admin + module UsersHelper + def format_last_activity_timestamp(timestamp) + return if timestamp.blank? + + if timestamp.today? + "Today, #{timestamp.strftime('%d %b')}" + elsif timestamp.yesterday? + "Yesterday, #{timestamp.strftime('%d %b')}" + else + timestamp.strftime("%d %b, %Y") + end + end + + def cascading_high_level_roles(user) + if user.super_admin? + "Super Admin" + elsif user.admin? + "Admin" + elsif user.single_resource_admin_for?(:any) + "Resource Admin" + end + end + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 79c736803..2f07dc7fd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -554,6 +554,13 @@ class User < ApplicationRecord Reaction.for_user(self) end + def last_activity + return unless registered == true + + [registered_at, last_comment_at, last_article_at, latest_article_updated_at, last_reacted_at, profile_updated_at, + last_moderation_notification, last_notification_activity].compact.max + end + protected # Send emails asynchronously diff --git a/app/views/admin/users/_member_index.html.erb b/app/views/admin/users/_member_index.html.erb index 2cb382495..ab96ffdf0 100644 --- a/app/views/admin/users/_member_index.html.erb +++ b/app/views/admin/users/_member_index.html.erb @@ -7,34 +7,59 @@
-

Members

-