Skip to content

Commit 0f79cbd

Browse files
authored
Merge pull request #51 from iquiw/last_login_on
Add user's last_login_on time to ViewCustomize context
2 parents 6545f21 + d8cfa22 commit 0f79cbd

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

README.ja.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ ViewCustomize = {
9595
"admin": true,
9696
"firstname": "Redmine",
9797
"lastname": "Admin",
98+
"last_login_on": "2019-09-22T14:44:53Z",
9899
"groups": [
99100
{"id": 5, "name": "Group1"}
100101
],

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ ViewCustomize = {
101101
"admin": true,
102102
"firstname": "Redmine",
103103
"lastname": "Admin",
104+
"last_login_on": "2019-09-22T14:44:53Z",
104105
"groups": [
105106
{"id": 5, "name": "Group1"}
106107
],

lib/view_customize/view_hook.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'time'
2+
13
module RedmineViewCustomize
24
class ViewHook < Redmine::Hook::ViewListener
35
def view_layouts_base_html_head(context={})
@@ -82,6 +84,7 @@ def create_view_customize_context(view_hook_context)
8284
"admin" => user.admin?,
8385
"firstname" => user.firstname,
8486
"lastname" => user.lastname,
87+
"last_login_on" => (user.last_login_on.iso8601 unless user.last_login_on.nil?),
8588
"groups" => user.groups.map {|group| { "id" => group.id, "name" => group.name }},
8689
"apiKey" => (user.api_token.value unless user.api_token.nil?),
8790
"customFields" => user.custom_field_values.map {|field| { "id" => field.custom_field.id, "name" => field.custom_field.name, "value" => field.value }}

0 commit comments

Comments
 (0)