[Jifty-commit] r6217 - in jifty/trunk: . lib/Jifty/Plugin
Jifty commits
jifty-commit at lists.jifty.org
Fri Jan 9 02:46:18 EST 2009
Author: sunnavy
Date: Fri Jan 9 02:46:18 2009
New Revision: 6217
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Plugin/ActorMetadata.pm
jifty/trunk/lib/Jifty/Plugin/ActorMetadata/Mixin/Model/ActorMetadata.pm
Log:
r6228 at sunnavys-mb: sunnavy | 2009-01-09 15:45:24 +0800
add updated_by column for ActorMetadata
Modified: jifty/trunk/lib/Jifty/Plugin/ActorMetadata.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/ActorMetadata.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/ActorMetadata.pm Fri Jan 9 02:46:18 2009
@@ -6,13 +6,11 @@
=head1 NAME
-Jifty::Plugin::ActorMetadata - add created_by created_on updated_on columns to
-a model class
+Jifty::Plugin::ActorMetadata - add created_by created_on updated_by updated_on columns to a model class
=head1 DESCRIPTION
-This plugin adds a model mixin which adds C<created_by>, C<created_on> and
-C<updated_on> columns to a model class.
+This plugin adds a model mixin which adds C<created_by>, C<created_on>, C<updated_by> and C<updated_on> columns to a model class.
=head1 EXAMPLE
@@ -27,7 +25,7 @@
...
};
- use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on
+ use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_by and updated_on
=cut
Modified: jifty/trunk/lib/Jifty/Plugin/ActorMetadata/Mixin/Model/ActorMetadata.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/ActorMetadata/Mixin/Model/ActorMetadata.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/ActorMetadata/Mixin/Model/ActorMetadata.pm Fri Jan 9 02:46:18 2009
@@ -19,7 +19,7 @@
# custom column defrinitions
};
- use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on
+ use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on and updated_by
=head1 DESCRIPTION
@@ -33,6 +33,8 @@
=head2 updated_on
+=head2 updated_by
+
=cut
# XXX: move this to somewhere
@@ -62,6 +64,10 @@
render_as 'hidden',
refers_to $app_user;
+column updated_by =>
+#refers_to $app_user, # TODO this weirdly doesn't work, need dig
+ render_as 'hidden';
+
column created_on => is TimeStamp,
render_as 'hidden';
column updated_on => is TimeStamp,
@@ -92,7 +98,7 @@
my $self = shift;
my $column = shift;
- return unless $column eq 'updated_on';
+ return unless $column eq 'updated_on' || $column eq 'updated_by';
$self->add_trigger(name => 'after_set', callback => \&after_set);
return 1;
@@ -100,7 +106,7 @@
=head2 before_create
-Sets C<created_by>, C<created_on>, C<updated_on> based on the current user and time.
+Sets C<created_by>, C<created_on>, C<updated_on> and C<updated_by> based on the current user and time.
=cut
@@ -108,7 +114,7 @@
my $self = shift;
my $args = shift;
- $args->{'created_by'} = $self->current_user->id;
+ $args->{'created_by'} = $args->{'updated_by'} = $self->current_user->id;
$args->{'created_on'} = $args->{'updated_on'} = Jifty::DateTime->now;
return 1;
@@ -116,13 +122,14 @@
=head2 after_set
-update C<updated_on> based on the current time.
+update C<updated_on> and C<updated_by> based on the current user and current time.
=cut
sub after_set {
my $self = shift;
$self->__set( column => 'updated_on', value => Jifty::DateTime->now );
+ $self->__set( column => 'updated_by', value => $self->current_user->id );
return 1;
}
More information about the Jifty-commit
mailing list