Jifty-Plugin-RecordHistory
view release on metacpan or search on metacpan
- Support two ways of overriding the collection of Changes displayed (trs)
0.06 2011-02-26
- Refactor change-update template so its components are reusable (Sartak)
- Bump Jifty dependency (Sartak)
0.05 2011-02-24
- Refactor current_user_can to be simpler and more correct (Sartak)
0.04 2011-02-18
- Allow control of cascaded_delete (Sartak)
- Allow control over current_user_can on Change and ChangeField by
implementing current_user_can_for_change in your record class (Sartak)
- Provide a way to create a delete_change for record delete (Sartak)
0.03 2011-02-17
- Provide a brief description of the object being viewed in the page title (trs)
- Rename the record template to record_type (trs)
t/TestApp-Plugin-RecordHistory/lib/TestApp/Plugin/RecordHistory/Model/Ticket.pm
t/TestApp-Plugin-RecordHistory/lib/TestApp/Plugin/RecordHistory/Model/User.pm
t/TestApp-Plugin-RecordHistory/lib/TestApp/Plugin/RecordHistory/View.pm
t/TestApp-Plugin-RecordHistory/Makefile.PL
t/TestApp-Plugin-RecordHistory/t/.007-delete-change.t.swp
t/TestApp-Plugin-RecordHistory/t/001-basic.t
t/TestApp-Plugin-RecordHistory/t/002-error.t
t/TestApp-Plugin-RecordHistory/t/003-action.t
t/TestApp-Plugin-RecordHistory/t/004-manual.t
t/TestApp-Plugin-RecordHistory/t/005-view.t
t/TestApp-Plugin-RecordHistory/t/006-no-cascaded-delete.t
t/TestApp-Plugin-RecordHistory/t/007-delete-change.t
t/TestApp-Plugin-RecordHistory/t/008-access-control.t
lib/Jifty/Plugin/RecordHistory.pm view on Meta::CPAN
and using the mixin to your record class(es) to enjoy transaction history. The
mixin even hooks into Jifty itself to observe record creation, updates, and
deletions.
=head2 Configuration
When you're importing the mixin you have several options to control the behavior
of history. Here are the defaults:
use Jifty::Plugin::RecordHistory::Mixin::Model::RecordHistory (
cascaded_delete => 1,
delete_change => 0,
);
If C<cascaded_delete> is true, then
L<Jifty::Plugin::RecordHistory::Model::Change> and
L<Jifty::Plugin::RecordHistory::Model::ChangeField> records are deleted at the
same time the original record they refer to is deleted. If C<cascaded_delete>
is false, then the Change and ChangeField records persist even if the original
record is deleted.
If C<delete_change> is true, then when your record is deleted we create a
L<Jifty::Plugin::RecordHistory::Model::Change> record whose type is C<delete>.
If C<delete_change> is false, then we do not record the deletion. If
both C<cascaded_delete> I<and> C<delete_change> are true, then you will end up
with only one change after the record is deleted -- the C<delete>.
=head2 Grouping
By default, the only mechanism that groups together change_fields onto a single
change object is L<Jifty::Action::Record::Update> (and its subclasses that do
not override C<take_action>). But if you want to make a number of field updates
that need to be grouped into a single logical change, you can call
C<start_change> and C<end_change> yourself on the record object.
lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm view on Meta::CPAN
our @EXPORT = qw(
changes
start_change end_change current_change
hide_change_field
);
sub import {
my $class = shift;
my %args = (
cascaded_delete => 1,
delete_change => 0,
@_,
);
my $caller = caller;
$class->export_to_level(1);
$caller->add_trigger(after_create => sub {
my $self = shift;
lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm view on Meta::CPAN
$change
};
$change->add_change_field(
field => $args{column},
old_value => $args{old_value},
new_value => $args{value},
);
});
if ($args{cascaded_delete}) {
# we hook into before_delete so we can still access ->changes etc
$caller->add_trigger(before_delete => sub {
my $self = shift;
my $changes = $self->changes;
$changes->current_user(Jifty::CurrentUser->superuser);
while (my $change = $changes->next) {
my $change_fields = $change->change_fields;
while (my $change_field = $change_fields->next) {
t/TestApp-Plugin-RecordHistory/lib/TestApp/Plugin/RecordHistory/Model/CD.pm view on Meta::CPAN
use Jifty::DBI::Schema;
use TestApp::Plugin::RecordHistory::Record schema {
column title =>
type is 'varchar';
column artist =>
type is 'varchar';
};
use Jifty::Plugin::RecordHistory::Mixin::Model::RecordHistory (
cascaded_delete => 0,
);
sub current_user_can { 1 }
1;
( run in 0.752 second using v1.01-cache-2.11-cpan-49f99fa48dc )