[Bps-public-commit] jifty-plugin-recordhistory branch, master, updated. 1d89c0e07b22806640be274b2a17e34d98734023
Shawn Moore
sartak at bestpractical.com
Wed Feb 9 22:57:14 EST 2011
The branch, master has been updated
via 1d89c0e07b22806640be274b2a17e34d98734023 (commit)
via e6b40f2b74a175bb22439489b2e3371b3cedcd77 (commit)
from b8ebcbe438f3a4cee885b5ce1dab0d3895f70de1 (commit)
Summary of changes:
lib/Jifty/Plugin/RecordHistory/Model/Change.pm | 13 +++++++++++++
lib/Jifty/Plugin/RecordHistory/View.pm | 2 ++
2 files changed, 15 insertions(+), 0 deletions(-)
- Log -----------------------------------------------------------------
commit e6b40f2b74a175bb22439489b2e3371b3cedcd77
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Feb 9 22:56:59 2011 -0500
Promote created_by to a user object if we can
diff --git a/lib/Jifty/Plugin/RecordHistory/Model/Change.pm b/lib/Jifty/Plugin/RecordHistory/Model/Change.pm
index 138ae7c..6d38ca3 100644
--- a/lib/Jifty/Plugin/RecordHistory/Model/Change.pm
+++ b/lib/Jifty/Plugin/RecordHistory/Model/Change.pm
@@ -82,5 +82,18 @@ sub add_change_field {
);
}
+sub created_by {
+ my $self = shift;
+ my $id = $self->_value('created_by');
+ my $class = Jifty->app_class('Model', 'User');
+
+ # if there's no User class then just continue returning the id
+ return $id unless $class->can('new');
+
+ my $user = $class->new;
+ $user->load($id);
+ return $user;
+}
+
1;
commit 1d89c0e07b22806640be274b2a17e34d98734023
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Feb 9 22:57:06 2011 -0500
If we get a string actor just pass it through
diff --git a/lib/Jifty/Plugin/RecordHistory/View.pm b/lib/Jifty/Plugin/RecordHistory/View.pm
index cedb97f..4233020 100644
--- a/lib/Jifty/Plugin/RecordHistory/View.pm
+++ b/lib/Jifty/Plugin/RecordHistory/View.pm
@@ -168,6 +168,8 @@ template 'actor' => sub {
my $self = shift;
my $actor = shift;
+ return outs $actor if !ref($actor);
+
return outs _('somebody') if !$actor->id || !$actor->current_user_can('read');
return outs $actor->email if $actor->can('email');
return outs _('user #%1', $actor->id);
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list