diff --git a/installAdspace.pl b/installAdspace.pl
new file mode 100644
index 000000000..9bafb32df
--- /dev/null
+++ b/installAdspace.pl
@@ -0,0 +1,143 @@
+print "start of script\n";
+use lib '/data/WebGUI/lib';
+use WebGUI::Session;
+use WebGUI::Asset::Sku::Ad ;
+sub install {
+ print "inside install function\n";
+ my $confg = $ARGV[0];
+ my $home = $ARGV[1] || "/data/WebGUI";
+ my $className = "WebGUI::Asset::SKu::Ad";
+ unless ($home && $confg) {
+ die "usage: Perl -M$className -e install yoursite.conf\n";
+ }
+ print "Installing asset.\n";
+ my $session = WebGUI::Session->open($home, $confg);
+ print "Add wobject to confg fle\n";
+ $session->config->addToHash("assets",$className => { category => 'shop' } );
+ print "Create database tables\n";
+ $session->db->write("CREATE TABLE AdSku (
+ assetId VARCHAR(22) BINARY NOT NULL,
+ revisionDate BIGINT NOT NULL,
+ purchaseTemplate VARCHAR(22) BINARY NOT NULL,
+ manageTemplate VARCHAR(22) BINARY NOT NULL,
+ adSpace VARCHAR(22) BINARY NOT NULL,
+ priority INTEGER DEFAULT '1',
+ pricePerClick Float DEFAULT '0',
+ pricePerImpression Float DEFAULT '0',
+ clickDiscounts VARCHAR(1024) default '',
+ impressionDiscounts VARCHAR(1024) default '',
+ PRIMARY KEY (assetId,revisionDate)
+ )");
+ print "Create a folder asset to store the default templates\n";
+ my $importNode = WebGUI::Asset->getImportNode($session);
+ my $newFolder = $importNode->addChild({
+ className => "WebGUI::Asset::Wobject::Folder",
+ title => "AdSku",
+ menuTitle => "AdSku",
+ url => "ad_sku_folder",
+ groupIdView => "3"
+ },"AdSkuFolder001");
+ #Create the templates
+ print "create purchase Ad Template\n";
+ my $purchaseAdTmpl = q|
+
+
+
+
+ TODO:Manage my ads link
+
+
+
+
+
+
+ | Ad Title |
+ |
+
+
+ | Ad Link |
+ |
+
+
+ | Image |
+ |
+
+
+ | number of clicks |
+ @ per click |
+ |
+
+
+ | number of impressions |
+ @ per impression |
+ |
+
+
+ |
+
+
+
+
+ |;
+ print "Manage Ads Template\n";
+ my $manageAdTmpl = q|
+ Manage My Ads
+ TODO:Buy Ad Space link
+
+
+
+ Title|
+ |
Clicks|
+ |
impressions|
+ |
renew|
+ |
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ |;
+ print "Add the templates to the folder\n";
+ $newFolder->addChild({
+ className=>"WebGUI::Asset::Template",
+ ownerUserId=>'3',
+ groupIdView=>'7',
+ groupIdEdit=>'12',
+ title=>"Default Purchase Ad Sku Template",
+ menuTitle=>"Default Purchase Ad Sku Template",
+ url=>"default_purchase_adsku_template",
+ namespace=>"AdSku/purchase",
+ template=>$purchaseAdTmpl,
+ },'AdSku000000001');
+ $newFolder->addChild({
+ className=>"WebGUI::Asset::Template",
+ ownerUserId=>'3',
+ groupIdView=>'7',
+ groupIdEdit=>'12',
+ title=>"Default Manage AdSku Template",
+ menuTitle=>"Default Manage AdSku Template",
+ url=>"default_manage_adsku_template",
+ namespace=>"AdSku/manage",
+ template=>$manageAdTmpl,
+ },'AdSku000000002');
+ print "Commit the working version tag\n";
+ my $workingTag = WebGUI::VersionTag->getWorking($session);
+ my $workingTagId = $workingTag->getId;
+ my $tag = WebGUI::VersionTag->new($session,$workingTagId);
+ if (defined $tag) {
+ print "Committing tag\n";
+ $tag->set({comments=>"Folder created by Asset Install Process"});
+ $tag->requestCommit;
+ }
+ $session->var->end;
+ $session->close;
+ print "Done. Please restart Apache.\n";
+}
+print "end of function\n";
+install();
+print "end of script\n";
diff --git a/lib/WebGUI/Asset/Sku/Ad.pm b/lib/WebGUI/Asset/Sku/Ad.pm
index 92c4eeed2..55f0f3ad2 100644
--- a/lib/WebGUI/Asset/Sku/Ad.pm
+++ b/lib/WebGUI/Asset/Sku/Ad.pm
@@ -159,7 +159,7 @@ Prepares the template.
sub prepareView {
my $self = shift;
$self->SUPER::prepareView();
- my $templateId = $self->get("templateId");
+ my $templateId = $self->get("purchaseTemplate");
my $template = WebGUI::Asset::Template->new($self->session, $templateId);
$template->prepare($self->getMetaDataAsTemplateVariables);
$self->{_viewTemplate} = $template;