-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
347 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,57 @@ | ||
package LibreCat::Model::Publication; | ||
|
||
use Catmandu::Sane; | ||
use LibreCat; | ||
use LibreCat::App::Catalogue::Controller::File (); | ||
use LibreCat::App::Catalogue::Controller::Material (); | ||
use Catmandu::Fix::add_citation; | ||
use Moo; | ||
use namespace::clean; | ||
|
||
with 'LibreCat::Model'; | ||
|
||
sub BUILD { | ||
my ($self) = @_; | ||
$self->append_before_add( | ||
|
||
# TODO this is very dirty and executes even if validation fails | ||
file => '_store_file', | ||
related_material => '_store_related_material', | ||
|
||
# TODO move to config | ||
citation => Catmandu::Fix::add_citation->new, | ||
); | ||
} | ||
|
||
sub delete { | ||
my ($self, $id) = @_; | ||
|
||
my $rec = $self->get($id) || return; | ||
|
||
if ($rec->{oai_deleted} || $rec->{status} eq 'public') { | ||
$rec->{oai_deleted} = 1; | ||
$rec->{locked} = 1; | ||
} | ||
|
||
$rec->{date_deleted} = LibreCat->timestamp; | ||
$rec->{status} = 'deleted'; | ||
|
||
$self->add($rec); | ||
} | ||
|
||
sub _store_file { | ||
my ($self, $rec) = @_; | ||
LibreCat::App::Catalogue::Controller::File::handle_file($rec); | ||
$rec; | ||
} | ||
|
||
sub _store_related_material { | ||
my ($self, $rec) = @_; | ||
if ($rec->{related_material}) { | ||
LibreCat::App::Catalogue::Controller::Material::update_related_material( | ||
$rec); | ||
} | ||
$rec; | ||
} | ||
|
||
1; |
Oops, something went wrong.