use OpenSRF::Utils::SettingsClient;
use OpenILS::Application::AppUtils;
use OpenSRF::Utils::Logger qw(:logger);
+use OpenILS::Utils::CStoreEditor qw/:funcs/;
use base 'OpenSRF::Application';
my $U = "OpenILS::Application::AppUtils";
my $penalties = $args{penalties};
my $pid = $patron->id;
+
$logger->debug("updating penalties for patron $pid => @$penalties");
+ my $editor = new_editor(xact =>1);
- my $session = $U->start_db_session();
# - fetch the current penalties
- my $existing = $session->request(
- 'open-ils.storage.direct.actor.'.
- 'user_standing_penalty.search.usr.atomic', $pid )->gather(1);
+ my $existing = $editor->search_actor_user_standing_penalty({usr=>$pid});
my @types;
push( @types, $_->penalty_type ) for @$existing;
$logger->activity("penalty: removing user penalty ".
$e->penalty_type . " from user $pid");
- my $s = $session->request(
- 'open-ils.storage.direct.actor.user_standing_penalty.delete', $e->id )->gather(1);
- return $U->DB_UPDATE_FAILED($e) unless defined($s);
+ $editor->delete_actor_user_standing_penalty($e)
+ or return $editor->event;
}
}
$newp->penalty_type( $p );
$newp->usr( $pid );
- my $s = $session->request(
- 'open-ils.storage.direct.actor.user_standing_penalty.create', $newp )->gather(1);
- return $U->DB_UPDATE_FAILED($p) unless $s;
+ $editor->create_actor_user_standing_penalty($newp)
+ or return $editor->event;
}
}
- $U->commit_db_session($session);
+ $editor->commit;
return undef;
}