-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted Organization alternate names in DB and added object.
- Table now has an identifier as primary key and an index on org + alt name - Object has basic routes - Object DB model can stringify nicely (better search results) - Object controller Show redirects to the main Organization. - List view displays nicely Bumps #471 Signed-off-by: Kathryn Tipton <[email protected]>
- Loading branch information
Showing
5 changed files
with
88 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
ALTER TABLE organization_alternate_name | ||
ADD COLUMN identifier SERIAL; | ||
ALTER TABLE organization_alternate_name | ||
DROP CONSTRAINT organization_alternate_name_pkey; | ||
ALTER TABLE organization_alternate_name | ||
ADD PRIMARY KEY (identifier); | ||
ALTER TABLE organization_alternate_name | ||
ADD UNIQUE (organization_identifier, alternate_name); | ||
|
||
|
||
COMMENT ON COLUMN organization_alternate_name.identifier IS 'An automatically-generated unique numeric identifier.'; |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package Tuba::DB::Object::OrganizationAlternateName; | ||
use strict; | ||
|
||
sub stringify { | ||
my $c = shift; | ||
return $c->alternate_name | ||
|| $c->organization_identifier | ||
|| $c->SUPER::stringify(@_); | ||
} | ||
|
||
1; | ||
|
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
=head1 NAME | ||
Tuba::OrganizationAlternateName : Controller class for Alternate Names for Organizations. | ||
=cut | ||
|
||
package Tuba::OrganizationAlternateName; | ||
use Mojo::Base qw/Tuba::Controller/; | ||
use Tuba::DB::Objects qw/-nicknames/; | ||
|
||
=head1 show | ||
Show redirects to the Organization | ||
=cut | ||
|
||
sub _default_list_order { | ||
return "organization_identifier"; | ||
} | ||
|
||
sub show { | ||
my $c = shift; | ||
my $identifier = $c->stash('organization_alternate_name_identifier'); | ||
|
||
my $object = OrganizationAlternateName->new( identifier => $identifier ) | ||
->load( speculative => 1 ) or return $c->reply->not_found; | ||
|
||
$c->redirect_to('show_organization' => { organization_identifier => $object->organization_identifier } ); | ||
} | ||
|
||
1; | ||
|
31 changes: 31 additions & 0 deletions
31
lib/Tuba/files/templates/organization_alternate_name/objects.html.ep
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
% layout 'default'; | ||
|
||
<center> | ||
<h2> | ||
%= (stash 'title'); | ||
</h2> | ||
</center> | ||
|
||
%= include 'list_formats'; | ||
|
||
% if (my $page = stash 'page') { | ||
%= include 'pager', page => $page; | ||
% } | ||
|
||
<table class='table table-responsive table-condensed table-bordered table-striped'> | ||
<tr> | ||
<th>Organization</th> | ||
<th>Alternate Name</th> | ||
</th> | ||
% for my $alt_name (@$objects) { | ||
<tr> | ||
<td><%= obj_link_to $alt_name, 'show' => begin %><%= $alt_name->organization_identifier %><%= end %></td> | ||
<td><%= obj_link_to $alt_name, 'show' => begin %><%= $alt_name->alternate_name %><%= end %></td> | ||
</tr> | ||
% } | ||
</table> | ||
|
||
% if (my $page = stash 'page') { | ||
%= include 'pager', page => $page, bottom => 1; | ||
% } | ||
|