Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added product tables.
  • Loading branch information
davorg committed Oct 1, 2015
1 parent 7b542b4 commit 275559b
Show file tree
Hide file tree
Showing 5 changed files with 274 additions and 5 deletions.
19 changes: 17 additions & 2 deletions Literature/lib/Literature/Schema/Result/Production.pm
Expand Up @@ -111,6 +111,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 production_products
Type: has_many
Related object: L<Literature::Schema::Result::ProductionProduct>
=cut

__PACKAGE__->has_many(
"production_products",
"Literature::Schema::Result::ProductionProduct",
{ "foreign.production_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 work
Type: belongs_to
Expand All @@ -127,8 +142,8 @@ __PACKAGE__->belongs_to(
);


# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-10-01 20:37:37
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Pbb3FP5cA/ANMlrxEZkWiw
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-10-01 21:43:50
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:VKyKvC7VRvcrLrcmb7NMKA


# You can replace this text with custom code or comments, and it will be preserved on regeneration
Expand Down
106 changes: 106 additions & 0 deletions Literature/lib/Literature/Schema/Result/ProductionProduct.pm
@@ -0,0 +1,106 @@
use utf8;
package Literature::Schema::Result::ProductionProduct;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

=head1 NAME
Literature::Schema::Result::ProductionProduct
=cut

use strict;
use warnings;

use Moose;
use MooseX::NonMoose;
use MooseX::MarkAsMethods autoclean => 1;
extends 'DBIx::Class::Core';

=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=back
=cut

__PACKAGE__->load_components("InflateColumn::DateTime");

=head1 TABLE: C<production_product>
=cut

__PACKAGE__->table("production_product");

=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 production_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 asin
data_type: 'char'
is_nullable: 0
size: 20
=cut

__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"production_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"asin",
{ data_type => "char", is_nullable => 0, size => 20 },
);

=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut

__PACKAGE__->set_primary_key("id");

=head1 RELATIONS
=head2 production
Type: belongs_to
Related object: L<Literature::Schema::Result::Production>
=cut

__PACKAGE__->belongs_to(
"production",
"Literature::Schema::Result::Production",
{ id => "production_id" },
{ is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
);


# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-10-01 21:43:50
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vPLXwNMJRQWtSYhJyZgcKg


# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable;
1;
26 changes: 24 additions & 2 deletions Literature/lib/Literature/Schema/Result/Work.pm
Expand Up @@ -130,6 +130,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 work_products
Type: has_many
Related object: L<Literature::Schema::Result::WorkProduct>
=cut

__PACKAGE__->has_many(
"work_products",
"Literature::Schema::Result::WorkProduct",
{ "foreign.work_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 authors
Type: many_to_many
Expand All @@ -155,9 +170,16 @@ __PACKAGE__->many_to_many(
);


# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-10-01 20:37:37
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:P4SAb/GK/gfabamQ5HGNBA
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-10-01 21:43:50
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:iNlGbrhdinEjHcBTc609zg

sub asins {
my $self = shift;

return () unless $self->work_products->count;

return map { $_->asin } $self->work_products->all;
}

# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable;
Expand Down
106 changes: 106 additions & 0 deletions Literature/lib/Literature/Schema/Result/WorkProduct.pm
@@ -0,0 +1,106 @@
use utf8;
package Literature::Schema::Result::WorkProduct;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

=head1 NAME
Literature::Schema::Result::WorkProduct
=cut

use strict;
use warnings;

use Moose;
use MooseX::NonMoose;
use MooseX::MarkAsMethods autoclean => 1;
extends 'DBIx::Class::Core';

=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=back
=cut

__PACKAGE__->load_components("InflateColumn::DateTime");

=head1 TABLE: C<work_product>
=cut

__PACKAGE__->table("work_product");

=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 work_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 asin
data_type: 'char'
is_nullable: 0
size: 20
=cut

__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"work_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"asin",
{ data_type => "char", is_nullable => 0, size => 20 },
);

=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut

__PACKAGE__->set_primary_key("id");

=head1 RELATIONS
=head2 work
Type: belongs_to
Related object: L<Literature::Schema::Result::Work>
=cut

__PACKAGE__->belongs_to(
"work",
"Literature::Schema::Result::Work",
{ id => "work_id" },
{ is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
);


# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-10-01 21:43:50
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ejeRY+8ND9weKp9VO8W4bw


# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable;
1;
22 changes: 21 additions & 1 deletion Literature/views/work.tt
Expand Up @@ -22,7 +22,27 @@
[% ELSE %]
<p>No productions found</p>
[% END %]
[% IF work.work_products.all.size -%]
<h3>Buy the Book</h3>
<script type='text/javascript'>
var amzn_wdgt={widget:'MyFavorites'};
amzn_wdgt.tag='davblog-20';
amzn_wdgt.columns='6';
amzn_wdgt.rows='1';
amzn_wdgt.title='[% work.title %]';
amzn_wdgt.width='800';
amzn_wdgt.ASIN='[% work.asins.join(',') %]';
amzn_wdgt.showImage='True';
amzn_wdgt.showPrice='True';
amzn_wdgt.showRating='True';
amzn_wdgt.design='2';
amzn_wdgt.colorTheme='White';
amzn_wdgt.headerTextColor='#333333';
amzn_wdgt.marketPlace='GB';
</script>
<script type='text/javascript' src='http://wms-na.amazon-adsystem.com/20070822/US//js/AmazonWidgets.js'>
</script>
[% FOR p IN work.work_products %]
<iframe src="http://rcm-uk.amazon.co.uk/e/cm?lt1=_blank&bc1=FFFFFF&IS2=1&nou=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=davblog-21&o=2&p=8&l=as1&m=amazon&f=ifr&asins=[% p.asin %]" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>
[% END %]
[% END -%]
[% END -%]

0 comments on commit 275559b

Please sign in to comment.